@oneuptime/common 12.0.17 → 12.0.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Models/DatabaseModels/EnterpriseLicense.ts +23 -0
- package/Models/DatabaseModels/Index.ts +4 -2
- package/Models/DatabaseModels/Monitor.ts +39 -9
- package/Models/DatabaseModels/UserMicrosoftTeams.ts +344 -0
- package/Models/DatabaseModels/UserNotificationRule.ts +144 -8
- package/Models/DatabaseModels/UserNotificationSetting.ts +34 -0
- package/Models/DatabaseModels/UserOnCallLogTimeline.ts +95 -0
- package/Models/DatabaseModels/UserSlack.ts +341 -0
- package/Models/DatabaseModels/WorkspaceProjectAuthToken.ts +9 -0
- package/Server/API/UserMicrosoftTeamsAPI.ts +127 -0
- package/Server/API/UserSlackAPI.ts +125 -0
- package/Server/EnvironmentConfig.ts +12 -107
- package/Server/Infrastructure/Postgres/SchemaMigrations/1788700000000-RemoveMarketingConversionUploadState.ts +33 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/1788800000000-DropMarketingConversionAddEnterpriseLicenseEmail.ts +51 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/1788900000000-RedactStoredMonitorIngestSecrets.ts +117 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/1789000000000-AddUserSlackAndMicrosoftTeams.ts +197 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/Index.ts +8 -0
- package/Server/Infrastructure/Queue.ts +7 -0
- package/Server/Services/BillingService.ts +8 -0
- package/Server/Services/EnterpriseLicenseService.ts +60 -0
- package/Server/Services/Index.ts +6 -2
- package/Server/Services/LlmLogService.ts +25 -9
- package/Server/Services/OnCallReadinessService.ts +86 -2
- package/Server/Services/ProjectService.ts +67 -0
- package/Server/Services/UserMicrosoftTeamsService.ts +208 -0
- package/Server/Services/UserNotificationMethodAdminService.ts +167 -5
- package/Server/Services/UserNotificationRuleAdminService.ts +40 -6
- package/Server/Services/UserNotificationRuleService.ts +589 -11
- package/Server/Services/UserNotificationSettingService.ts +138 -0
- package/Server/Services/UserService.ts +28 -0
- package/Server/Services/UserSlackService.ts +218 -0
- package/Server/Services/WorkspaceProjectAuthTokenService.ts +67 -1
- package/Server/Services/WorkspaceUserAuthTokenService.ts +73 -0
- package/Server/Services/WorkspaceUserNotificationService.ts +190 -0
- package/Server/Utils/Marketing/MarketingEventUtil.ts +145 -0
- package/Server/Utils/Marketing/MarketingEventWebhook.ts +114 -0
- package/Server/Utils/Monitor/MonitorLogUtil.ts +14 -1
- package/Server/Utils/Monitor/MonitorPayloadRedaction.ts +321 -0
- package/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeams.ts +191 -4
- package/Tests/App/Dashboard/AdminNotificationRulesPage.test.tsx +22 -14
- package/Tests/App/Dashboard/AdminUserNotificationMethodsPage.test.tsx +22 -11
- package/Tests/App/Dashboard/OnCallPreventionGuards.test.tsx +37 -1
- package/Tests/App/Dashboard/OnCallRulesTable.test.tsx +18 -10
- package/Tests/App/Dashboard/PayAsYouGoNotices.test.tsx +17 -0
- package/Tests/Models/DatabaseModels/DomainRoleTierCoverage.test.ts +27 -1
- package/Tests/Models/DatabaseModels/MonitorSecretKeyColumnAccessControl.test.ts +214 -0
- package/Tests/Server/API/OnCallReadinessAPI.test.ts +145 -26
- package/Tests/Server/API/UserNotificationMethodAdminAPI.test.ts +2 -2
- package/Tests/Server/Services/AIServiceDailyBudget.test.ts +11 -1
- package/Tests/Server/Services/AdminRuleEditGuards.test.ts +22 -8
- package/Tests/Server/Services/BillingService.test.ts +20 -0
- package/Tests/Server/Services/DeliverNotificationForRuleExtraction.test.ts +18 -2
- package/Tests/Server/Services/EpisodeRuleSeverityRepair.test.ts +5 -1
- package/Tests/Server/Services/LlmLogServiceTokenAggregateParams.test.ts +640 -0
- package/Tests/Server/Services/NotificationChannelEventCoverage.test.ts +246 -22
- package/Tests/Server/Services/NotificationDeletionImpact.test.ts +136 -8
- package/Tests/Server/Services/OnCallNotificationFallback.test.ts +191 -8
- package/Tests/Server/Services/OnCallReadinessService.test.ts +343 -18
- package/Tests/Server/Services/SeverityRuleBackfill.test.ts +5 -1
- package/Tests/Server/Services/UserMicrosoftTeamsService.test.ts +343 -0
- package/Tests/Server/Services/UserNotificationMethodAdminService.test.ts +209 -8
- package/Tests/Server/Services/UserNotificationRuleAdminGuards.test.ts +22 -6
- package/Tests/Server/Services/UserNotificationRuleDefaultCreation.test.ts +12 -6
- package/Tests/Server/Services/UserNotificationRuleExecuteItem.test.ts +37 -3
- package/Tests/Server/Services/UserNotificationRuleWorkspaceDelivery.test.ts +669 -0
- package/Tests/Server/Services/UserNotificationSettingWorkspaceChannels.test.ts +410 -0
- package/Tests/Server/Services/UserSlackService.test.ts +407 -0
- package/Tests/Server/Services/WorkspaceProjectAuthTokenDisconnectCascade.test.ts +224 -0
- package/Tests/Server/Services/WorkspaceUserAuthTokenNotificationMethodCascade.test.ts +189 -0
- package/Tests/Server/Services/WorkspaceUserNotificationService.test.ts +496 -0
- package/Tests/Server/Types/Database/Permissions/AdminNotificationRuleAccess.test.ts +30 -17
- package/Tests/Server/Types/Database/Permissions/CreateOwnershipScoping.test.ts +8 -3
- package/Tests/Server/Types/Database/Permissions/OwnerOnlyColumns.test.ts +72 -3
- package/Tests/Server/Types/Database/Permissions/UserNotificationRuleScoping.test.ts +22 -18
- package/Tests/Server/Types/Database/Permissions/WorkspaceMethodStampedColumnCreate.test.ts +178 -0
- package/Tests/Server/Utils/Marketing/MarketingEventUtil.test.ts +259 -0
- package/Tests/Server/Utils/Marketing/MarketingEventWebhook.test.ts +257 -0
- package/Tests/Server/Utils/Monitor/MonitorLogUtilRedaction.test.ts +300 -0
- package/Tests/Server/Utils/Monitor/MonitorPayloadRedaction.test.ts +381 -0
- package/Tests/Server/Utils/Runbook/RunbookExecutePermission.test.ts +228 -0
- package/Tests/Server/Utils/SessionReplay/SessionReplayErasureTombstone.test.ts +189 -0
- package/Tests/Server/Utils/SessionReplay/SessionReplayUsage.test.ts +205 -0
- package/Tests/Server/Utils/Telemetry/AppMetrics.test.ts +275 -0
- package/Tests/Server/Utils/Telemetry/TelemetryContext.test.ts +279 -0
- package/Tests/Server/Utils/Workspace/MicrosoftTeamsDirectMessage.test.ts +454 -0
- package/Tests/Types/Kubernetes/KubernetesObjectParsers.test.ts +794 -0
- package/Tests/Types/Kubernetes/KubernetesRightSizing.test.ts +53 -0
- package/Tests/Types/Measurement/MeasurementAggregationType.test.ts +100 -0
- package/Tests/Types/Monitor/MonitorStepConfigHelpers.test.ts +114 -0
- package/Tests/Types/Workspace/WorkspaceType.test.ts +53 -0
- package/Tests/UI/Utils/NotificationMethodUtil.test.ts +137 -9
- package/Tests/UI/Utils/PermissionGate.test.ts +105 -0
- package/Tests/Utils/Dashboard/Components/DashboardComponentDefaults.test.ts +257 -0
- package/Types/Billing/PayAsYouGoPricing.ts +1 -1
- package/Types/Marketing/MarketingEvent.ts +97 -0
- package/UI/Utils/NotificationMethodUtil.ts +41 -1
- package/UI/Utils/PermissionGate.ts +56 -0
- package/build/dist/Models/DatabaseModels/EnterpriseLicense.js +24 -0
- package/build/dist/Models/DatabaseModels/EnterpriseLicense.js.map +1 -1
- package/build/dist/Models/DatabaseModels/Index.js +4 -2
- package/build/dist/Models/DatabaseModels/Index.js.map +1 -1
- package/build/dist/Models/DatabaseModels/Monitor.js +39 -9
- package/build/dist/Models/DatabaseModels/Monitor.js.map +1 -1
- package/build/dist/Models/DatabaseModels/UserMicrosoftTeams.js +363 -0
- package/build/dist/Models/DatabaseModels/UserMicrosoftTeams.js.map +1 -0
- package/build/dist/Models/DatabaseModels/UserNotificationRule.js +145 -8
- package/build/dist/Models/DatabaseModels/UserNotificationRule.js.map +1 -1
- package/build/dist/Models/DatabaseModels/UserNotificationSetting.js +38 -0
- package/build/dist/Models/DatabaseModels/UserNotificationSetting.js.map +1 -1
- package/build/dist/Models/DatabaseModels/UserOnCallLogTimeline.js +96 -0
- package/build/dist/Models/DatabaseModels/UserOnCallLogTimeline.js.map +1 -1
- package/build/dist/Models/DatabaseModels/UserSlack.js +361 -0
- package/build/dist/Models/DatabaseModels/UserSlack.js.map +1 -0
- package/build/dist/Models/DatabaseModels/WorkspaceProjectAuthToken.js.map +1 -1
- package/build/dist/Server/API/UserMicrosoftTeamsAPI.js +82 -0
- package/build/dist/Server/API/UserMicrosoftTeamsAPI.js.map +1 -0
- package/build/dist/Server/API/UserSlackAPI.js +81 -0
- package/build/dist/Server/API/UserSlackAPI.js.map +1 -0
- package/build/dist/Server/EnvironmentConfig.js +10 -70
- package/build/dist/Server/EnvironmentConfig.js.map +1 -1
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1788700000000-RemoveMarketingConversionUploadState.js +26 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1788700000000-RemoveMarketingConversionUploadState.js.map +1 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1788800000000-DropMarketingConversionAddEnterpriseLicenseEmail.js +37 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1788800000000-DropMarketingConversionAddEnterpriseLicenseEmail.js.map +1 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1788900000000-RedactStoredMonitorIngestSecrets.js +106 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1788900000000-RedactStoredMonitorIngestSecrets.js.map +1 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1789000000000-AddUserSlackAndMicrosoftTeams.js +78 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1789000000000-AddUserSlackAndMicrosoftTeams.js.map +1 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/Index.js +8 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/Index.js.map +1 -1
- package/build/dist/Server/Infrastructure/Queue.js +7 -0
- package/build/dist/Server/Infrastructure/Queue.js.map +1 -1
- package/build/dist/Server/Services/BillingService.js +6 -0
- package/build/dist/Server/Services/BillingService.js.map +1 -1
- package/build/dist/Server/Services/EnterpriseLicenseService.js +65 -0
- package/build/dist/Server/Services/EnterpriseLicenseService.js.map +1 -1
- package/build/dist/Server/Services/Index.js +6 -2
- package/build/dist/Server/Services/Index.js.map +1 -1
- package/build/dist/Server/Services/LlmLogService.js +25 -9
- package/build/dist/Server/Services/LlmLogService.js.map +1 -1
- package/build/dist/Server/Services/OnCallReadinessService.js +74 -2
- package/build/dist/Server/Services/OnCallReadinessService.js.map +1 -1
- package/build/dist/Server/Services/ProjectService.js +56 -0
- package/build/dist/Server/Services/ProjectService.js.map +1 -1
- package/build/dist/Server/Services/UserMicrosoftTeamsService.js +183 -0
- package/build/dist/Server/Services/UserMicrosoftTeamsService.js.map +1 -0
- package/build/dist/Server/Services/UserNotificationMethodAdminService.js +138 -2
- package/build/dist/Server/Services/UserNotificationMethodAdminService.js.map +1 -1
- package/build/dist/Server/Services/UserNotificationRuleAdminService.js +32 -4
- package/build/dist/Server/Services/UserNotificationRuleAdminService.js.map +1 -1
- package/build/dist/Server/Services/UserNotificationRuleService.js +499 -67
- package/build/dist/Server/Services/UserNotificationRuleService.js.map +1 -1
- package/build/dist/Server/Services/UserNotificationSettingService.js +118 -0
- package/build/dist/Server/Services/UserNotificationSettingService.js.map +1 -1
- package/build/dist/Server/Services/UserService.js +26 -1
- package/build/dist/Server/Services/UserService.js.map +1 -1
- package/build/dist/Server/Services/UserSlackService.js +195 -0
- package/build/dist/Server/Services/UserSlackService.js.map +1 -0
- package/build/dist/Server/Services/WorkspaceProjectAuthTokenService.js +64 -1
- package/build/dist/Server/Services/WorkspaceProjectAuthTokenService.js.map +1 -1
- package/build/dist/Server/Services/WorkspaceUserAuthTokenService.js +70 -0
- package/build/dist/Server/Services/WorkspaceUserAuthTokenService.js.map +1 -1
- package/build/dist/Server/Services/WorkspaceUserNotificationService.js +129 -0
- package/build/dist/Server/Services/WorkspaceUserNotificationService.js.map +1 -0
- package/build/dist/Server/Utils/Marketing/MarketingEventUtil.js +94 -0
- package/build/dist/Server/Utils/Marketing/MarketingEventUtil.js.map +1 -0
- package/build/dist/Server/Utils/Marketing/MarketingEventWebhook.js +93 -0
- package/build/dist/Server/Utils/Marketing/MarketingEventWebhook.js.map +1 -0
- package/build/dist/Server/Utils/Monitor/MonitorLogUtil.js +12 -1
- package/build/dist/Server/Utils/Monitor/MonitorLogUtil.js.map +1 -1
- package/build/dist/Server/Utils/Monitor/MonitorPayloadRedaction.js +233 -0
- package/build/dist/Server/Utils/Monitor/MonitorPayloadRedaction.js.map +1 -0
- package/build/dist/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeams.js +141 -4
- package/build/dist/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeams.js.map +1 -1
- package/build/dist/Types/Billing/PayAsYouGoPricing.js +1 -1
- package/build/dist/Types/Billing/PayAsYouGoPricing.js.map +1 -1
- package/build/dist/Types/Marketing/MarketingEvent.js +43 -0
- package/build/dist/Types/Marketing/MarketingEvent.js.map +1 -0
- package/build/dist/UI/Utils/NotificationMethodUtil.js +33 -1
- package/build/dist/UI/Utils/NotificationMethodUtil.js.map +1 -1
- package/build/dist/UI/Utils/PermissionGate.js +32 -0
- package/build/dist/UI/Utils/PermissionGate.js.map +1 -1
- package/package.json +1 -1
- package/Models/DatabaseModels/MarketingConversion.ts +0 -410
- package/Server/Services/MarketingConversionService.ts +0 -10
- package/Server/Utils/Marketing/ConversionUploadProvider.ts +0 -215
- package/Server/Utils/Marketing/ConversionUploadProviders.ts +0 -22
- package/Server/Utils/Marketing/Providers/GoogleAds.ts +0 -333
- package/Server/Utils/Marketing/Providers/LinkedIn.ts +0 -185
- package/Server/Utils/Marketing/Providers/Meta.ts +0 -182
- package/Server/Utils/Marketing/Providers/MicrosoftAds.ts +0 -223
- package/Server/Utils/Marketing/Providers/Reddit.ts +0 -208
- package/Tests/Server/Utils/Marketing/AdUploadableConversionTypes.test.ts +0 -315
- package/Tests/Server/Utils/Marketing/ConversionUploadProvider.test.ts +0 -300
- package/Tests/Server/Utils/Marketing/GoogleAds.test.ts +0 -592
- package/Tests/Server/Utils/Marketing/LinkedIn.test.ts +0 -282
- package/Tests/Server/Utils/Marketing/Meta.test.ts +0 -304
- package/Tests/Server/Utils/Marketing/MicrosoftAds.test.ts +0 -263
- package/Tests/Server/Utils/Marketing/Reddit.test.ts +0 -259
- package/Types/Marketing/MarketingConversion.ts +0 -53
- package/build/dist/Models/DatabaseModels/MarketingConversion.js +0 -445
- package/build/dist/Models/DatabaseModels/MarketingConversion.js.map +0 -1
- package/build/dist/Server/Services/MarketingConversionService.js +0 -9
- package/build/dist/Server/Services/MarketingConversionService.js.map +0 -1
- package/build/dist/Server/Utils/Marketing/ConversionUploadProvider.js +0 -93
- package/build/dist/Server/Utils/Marketing/ConversionUploadProvider.js.map +0 -1
- package/build/dist/Server/Utils/Marketing/ConversionUploadProviders.js +0 -20
- package/build/dist/Server/Utils/Marketing/ConversionUploadProviders.js.map +0 -1
- package/build/dist/Server/Utils/Marketing/Providers/GoogleAds.js +0 -221
- package/build/dist/Server/Utils/Marketing/Providers/GoogleAds.js.map +0 -1
- package/build/dist/Server/Utils/Marketing/Providers/LinkedIn.js +0 -137
- package/build/dist/Server/Utils/Marketing/Providers/LinkedIn.js.map +0 -1
- package/build/dist/Server/Utils/Marketing/Providers/Meta.js +0 -133
- package/build/dist/Server/Utils/Marketing/Providers/Meta.js.map +0 -1
- package/build/dist/Server/Utils/Marketing/Providers/MicrosoftAds.js +0 -143
- package/build/dist/Server/Utils/Marketing/Providers/MicrosoftAds.js.map +0 -1
- package/build/dist/Server/Utils/Marketing/Providers/Reddit.js +0 -145
- package/build/dist/Server/Utils/Marketing/Providers/Reddit.js.map +0 -1
- package/build/dist/Types/Marketing/MarketingConversion.js +0 -52
- package/build/dist/Types/Marketing/MarketingConversion.js.map +0 -1
|
@@ -11,8 +11,10 @@ import UserNotificationRuleService, {
|
|
|
11
11
|
} from "../../../Server/Services/UserNotificationRuleService";
|
|
12
12
|
import UserOnCallLogService from "../../../Server/Services/UserOnCallLogService";
|
|
13
13
|
import UserOnCallLogTimelineService from "../../../Server/Services/UserOnCallLogTimelineService";
|
|
14
|
+
import UserMicrosoftTeamsService from "../../../Server/Services/UserMicrosoftTeamsService";
|
|
14
15
|
import UserPushService from "../../../Server/Services/UserPushService";
|
|
15
16
|
import UserService from "../../../Server/Services/UserService";
|
|
17
|
+
import UserSlackService from "../../../Server/Services/UserSlackService";
|
|
16
18
|
import UserSmsService from "../../../Server/Services/UserSmsService";
|
|
17
19
|
import UserTelegramService from "../../../Server/Services/UserTelegramService";
|
|
18
20
|
import UserWebhookService from "../../../Server/Services/UserWebhookService";
|
|
@@ -66,8 +68,8 @@ import { afterEach, beforeEach, describe, expect, test } from "@jest/globals";
|
|
|
66
68
|
* R1 a target user id from ANOTHER project, presented by a caller who is a
|
|
67
69
|
* legitimate administrator of THIS one.
|
|
68
70
|
* R3 a method FK pointing at somebody else's row — on create, on update, in
|
|
69
|
-
* the FK slot, in the relation slot, and on all
|
|
70
|
-
* a guard covering
|
|
71
|
+
* the FK slot, in the relation slot, and on all nine channels, because
|
|
72
|
+
* a guard covering eight of nine covers none.
|
|
71
73
|
* R3 on update specifically: a body that LIES about the rule's owner, to
|
|
72
74
|
* check that the owner is re-read from the database rather than believed.
|
|
73
75
|
* R6 an audit trail and an owner notification keyed on the server-resolved
|
|
@@ -111,7 +113,7 @@ const INCIDENT_ID: ObjectID = new ObjectID(
|
|
|
111
113
|
);
|
|
112
114
|
|
|
113
115
|
/*
|
|
114
|
-
* The
|
|
116
|
+
* The nine channels, each with the FK column a rule carries it in, the
|
|
115
117
|
* relation slot that is the same write spelled differently, the service the
|
|
116
118
|
* guard must consult, and the word the rejection message has to contain.
|
|
117
119
|
*
|
|
@@ -163,6 +165,20 @@ const CHANNELS: Array<ChannelFixture> = [
|
|
|
163
165
|
service: UserTelegramService as unknown as ChannelFixture["service"],
|
|
164
166
|
relationProperty: "userTelegram",
|
|
165
167
|
},
|
|
168
|
+
{
|
|
169
|
+
idColumn: "userSlackId",
|
|
170
|
+
relationColumn: "userSlack",
|
|
171
|
+
label: "Slack",
|
|
172
|
+
service: UserSlackService as unknown as ChannelFixture["service"],
|
|
173
|
+
relationProperty: "userSlack",
|
|
174
|
+
},
|
|
175
|
+
{
|
|
176
|
+
idColumn: "userMicrosoftTeamsId",
|
|
177
|
+
relationColumn: "userMicrosoftTeams",
|
|
178
|
+
label: "Microsoft Teams",
|
|
179
|
+
service: UserMicrosoftTeamsService as unknown as ChannelFixture["service"],
|
|
180
|
+
relationProperty: "userMicrosoftTeams",
|
|
181
|
+
},
|
|
166
182
|
{
|
|
167
183
|
idColumn: "userPushId",
|
|
168
184
|
relationColumn: "userPush",
|
|
@@ -644,7 +660,7 @@ describe("UserNotificationRule administrative write guards", () => {
|
|
|
644
660
|
* R3 on create - the method a rule names must belong to the rule's owner.
|
|
645
661
|
* ---------------------------------------------------------------------
|
|
646
662
|
*/
|
|
647
|
-
describe("R3 on create - method ownership, all
|
|
663
|
+
describe("R3 on create - method ownership, all nine channels", () => {
|
|
648
664
|
test.each(
|
|
649
665
|
CHANNELS.map((channel: ChannelFixture): [string, ChannelFixture] => {
|
|
650
666
|
return [channel.label, channel];
|
|
@@ -720,9 +736,9 @@ describe("UserNotificationRule administrative write guards", () => {
|
|
|
720
736
|
},
|
|
721
737
|
);
|
|
722
738
|
|
|
723
|
-
test("the guard covers exactly the
|
|
739
|
+
test("the guard covers exactly the nine notification method columns the model has", () => {
|
|
724
740
|
/*
|
|
725
|
-
* The count is the assertion.
|
|
741
|
+
* The count is the assertion. A tenth channel added to the model
|
|
726
742
|
* without an entry in the guard's table is a channel with no ownership
|
|
727
743
|
* check at all, and the attacker only needs one.
|
|
728
744
|
*/
|
|
@@ -19,9 +19,11 @@ import { afterEach, beforeEach, describe, expect, test } from "@jest/globals";
|
|
|
19
19
|
* The defaults a brand-new responder is given.
|
|
20
20
|
*
|
|
21
21
|
* Everything about "will this person actually be paged?" starts here. When a
|
|
22
|
-
* user joins a project (TeamMemberService),
|
|
22
|
+
* user joins a project (TeamMemberService), verifies a phone / push / e-mail
|
|
23
23
|
* / Telegram / WhatsApp / webhook identity (the UserXxxAPI verify endpoints),
|
|
24
|
-
*
|
|
24
|
+
* or links a Slack / Microsoft Teams account (born verified from the OAuth
|
|
25
|
+
* workspace link), UserNotificationRuleService seeds a set of notification
|
|
26
|
+
* rules for them. If the
|
|
25
27
|
* seeding is wrong — a severity skipped, a rule type missed, a delay that is not
|
|
26
28
|
* zero, or the method id written onto the wrong foreign key — the user is on an
|
|
27
29
|
* on-call policy that pages nobody, and nothing tells them so.
|
|
@@ -93,13 +95,15 @@ const CREATED_EMAIL_ID: ObjectID = new ObjectID(
|
|
|
93
95
|
|
|
94
96
|
const USER_EMAIL: Email = new Email("responder@company.com");
|
|
95
97
|
|
|
96
|
-
/* The
|
|
98
|
+
/* The nine FK columns a NotificationMethodDescriptor can drive. */
|
|
97
99
|
type ChannelColumn =
|
|
98
100
|
| "userEmailId"
|
|
99
101
|
| "userSmsId"
|
|
100
102
|
| "userCallId"
|
|
101
103
|
| "userWhatsAppId"
|
|
102
104
|
| "userTelegramId"
|
|
105
|
+
| "userSlackId"
|
|
106
|
+
| "userMicrosoftTeamsId"
|
|
103
107
|
| "userWebhookId"
|
|
104
108
|
| "userPushId";
|
|
105
109
|
|
|
@@ -109,6 +113,8 @@ const ALL_CHANNELS: Array<ChannelColumn> = [
|
|
|
109
113
|
"userCallId",
|
|
110
114
|
"userWhatsAppId",
|
|
111
115
|
"userTelegramId",
|
|
116
|
+
"userSlackId",
|
|
117
|
+
"userMicrosoftTeamsId",
|
|
112
118
|
"userWebhookId",
|
|
113
119
|
"userPushId",
|
|
114
120
|
];
|
|
@@ -587,9 +593,9 @@ describe("addDefaultNotificationRulesForVerifiedMethod - the method lands on the
|
|
|
587
593
|
* KNOWN DEFECT, pinned as-is. With no id on the descriptor the duplicate
|
|
588
594
|
* check degenerates to (projectId, userId, ruleType) and the created rows
|
|
589
595
|
* carry no notification method at all - onBeforeCreate would reject them
|
|
590
|
-
* with "Call, SMS, WhatsApp, Telegram,
|
|
591
|
-
* is required" against a real database. Nothing
|
|
592
|
-
* against being handed an empty descriptor.
|
|
596
|
+
* with "Call, SMS, WhatsApp, Telegram, Slack, Microsoft Teams, Webhook,
|
|
597
|
+
* Email, or Push notification is required" against a real database. Nothing
|
|
598
|
+
* in this method guards against being handed an empty descriptor.
|
|
593
599
|
*/
|
|
594
600
|
await runForDescriptor({});
|
|
595
601
|
|
|
@@ -14,6 +14,7 @@ import TelegramService from "../../../Server/Services/TelegramService";
|
|
|
14
14
|
import WebhookService from "../../../Server/Services/WebhookService";
|
|
15
15
|
import PushNotificationService from "../../../Server/Services/PushNotificationService";
|
|
16
16
|
import WorkspaceNotificationRuleService from "../../../Server/Services/WorkspaceNotificationRuleService";
|
|
17
|
+
import WorkspaceUserNotificationService from "../../../Server/Services/WorkspaceUserNotificationService";
|
|
17
18
|
import logger from "../../../Server/Utils/Logger";
|
|
18
19
|
import Incident from "../../../Models/DatabaseModels/Incident";
|
|
19
20
|
import Alert from "../../../Models/DatabaseModels/Alert";
|
|
@@ -212,6 +213,7 @@ interface DeliverySpies {
|
|
|
212
213
|
call: jest.SpyInstance;
|
|
213
214
|
whatsApp: jest.SpyInstance;
|
|
214
215
|
telegram: jest.SpyInstance;
|
|
216
|
+
workspaceMessage: jest.SpyInstance;
|
|
215
217
|
webhook: jest.SpyInstance;
|
|
216
218
|
push: jest.SpyInstance;
|
|
217
219
|
emailTemplateForIncident: jest.SpyInstance;
|
|
@@ -294,6 +296,10 @@ describe("UserNotificationRuleService.executeNotificationRuleItem", () => {
|
|
|
294
296
|
telegram: jest
|
|
295
297
|
.spyOn(TelegramService, "sendTelegramMessage")
|
|
296
298
|
.mockResolvedValue(undefined as never),
|
|
299
|
+
// Slack and Microsoft Teams both deliver through this one service.
|
|
300
|
+
workspaceMessage: jest
|
|
301
|
+
.spyOn(WorkspaceUserNotificationService, "sendDirectMessageToUser")
|
|
302
|
+
.mockResolvedValue(undefined as never),
|
|
297
303
|
webhook: jest
|
|
298
304
|
.spyOn(WebhookService, "sendWebhook")
|
|
299
305
|
.mockResolvedValue(undefined as never),
|
|
@@ -320,6 +326,7 @@ describe("UserNotificationRuleService.executeNotificationRuleItem", () => {
|
|
|
320
326
|
spies.call,
|
|
321
327
|
spies.whatsApp,
|
|
322
328
|
spies.telegram,
|
|
329
|
+
spies.workspaceMessage,
|
|
323
330
|
spies.webhook,
|
|
324
331
|
spies.push,
|
|
325
332
|
];
|
|
@@ -572,7 +579,7 @@ describe("UserNotificationRuleService.executeNotificationRuleItem", () => {
|
|
|
572
579
|
* the loaded relation's userId against the rule's, and it can only report
|
|
573
580
|
* a mismatch it can SEE - an unselected column arrives as `undefined` and
|
|
574
581
|
* is deliberately read as "no evidence", so dropping any one of these
|
|
575
|
-
*
|
|
582
|
+
* nine silently disables the backstop for that channel.
|
|
576
583
|
*
|
|
577
584
|
* Kept as an exact-shape assertion on purpose. This test caught the
|
|
578
585
|
* column being added, which is the whole argument for not relaxing it
|
|
@@ -603,6 +610,18 @@ describe("UserNotificationRuleService.executeNotificationRuleItem", () => {
|
|
|
603
610
|
isVerified: true,
|
|
604
611
|
userId: true,
|
|
605
612
|
},
|
|
613
|
+
userSlack: {
|
|
614
|
+
slackUserId: true,
|
|
615
|
+
slackUserName: true,
|
|
616
|
+
isVerified: true,
|
|
617
|
+
userId: true,
|
|
618
|
+
},
|
|
619
|
+
userMicrosoftTeams: {
|
|
620
|
+
microsoftTeamsUserId: true,
|
|
621
|
+
microsoftTeamsUserName: true,
|
|
622
|
+
isVerified: true,
|
|
623
|
+
userId: true,
|
|
624
|
+
},
|
|
606
625
|
userWebhook: {
|
|
607
626
|
webhookUrl: true,
|
|
608
627
|
name: true,
|
|
@@ -629,6 +648,8 @@ describe("UserNotificationRuleService.executeNotificationRuleItem", () => {
|
|
|
629
648
|
["userSms"],
|
|
630
649
|
["userWhatsApp"],
|
|
631
650
|
["userTelegram"],
|
|
651
|
+
["userSlack"],
|
|
652
|
+
["userMicrosoftTeams"],
|
|
632
653
|
["userEmail"],
|
|
633
654
|
["userPush"],
|
|
634
655
|
])(
|
|
@@ -647,6 +668,8 @@ describe("UserNotificationRuleService.executeNotificationRuleItem", () => {
|
|
|
647
668
|
["userSms", "phone"],
|
|
648
669
|
["userWhatsApp", "phone"],
|
|
649
670
|
["userTelegram", "telegramChatId"],
|
|
671
|
+
["userSlack", "slackUserId"],
|
|
672
|
+
["userMicrosoftTeams", "microsoftTeamsUserId"],
|
|
650
673
|
["userEmail", "email"],
|
|
651
674
|
["userPush", "deviceToken"],
|
|
652
675
|
])(
|
|
@@ -777,6 +800,16 @@ describe("UserNotificationRuleService.executeNotificationRuleItem", () => {
|
|
|
777
800
|
telegramChatId: "123456",
|
|
778
801
|
isVerified: false,
|
|
779
802
|
},
|
|
803
|
+
userSlack: {
|
|
804
|
+
id: METHOD_ID,
|
|
805
|
+
slackUserId: "U0123456789",
|
|
806
|
+
isVerified: false,
|
|
807
|
+
},
|
|
808
|
+
userMicrosoftTeams: {
|
|
809
|
+
id: METHOD_ID,
|
|
810
|
+
microsoftTeamsUserId: "teams-user-1",
|
|
811
|
+
isVerified: false,
|
|
812
|
+
},
|
|
780
813
|
userCall: {
|
|
781
814
|
id: METHOD_ID,
|
|
782
815
|
phone: new Phone("+11234567892"),
|
|
@@ -801,10 +834,11 @@ describe("UserNotificationRuleService.executeNotificationRuleItem", () => {
|
|
|
801
834
|
expect(spies.call).not.toHaveBeenCalled();
|
|
802
835
|
expect(spies.whatsApp).not.toHaveBeenCalled();
|
|
803
836
|
expect(spies.telegram).not.toHaveBeenCalled();
|
|
837
|
+
expect(spies.workspaceMessage).not.toHaveBeenCalled();
|
|
804
838
|
expect(spies.push).not.toHaveBeenCalled();
|
|
805
839
|
|
|
806
|
-
// One "not verified" Error row per unverified channel:
|
|
807
|
-
expect(timelineRows).toHaveLength(
|
|
840
|
+
// One "not verified" Error row per unverified channel: 8 in total.
|
|
841
|
+
expect(timelineRows).toHaveLength(8);
|
|
808
842
|
for (const row of timelineRows) {
|
|
809
843
|
expect(row.status).toBe(UserNotificationStatus.Error);
|
|
810
844
|
expect(row.statusMessage).toContain("not verified");
|