@oneuptime/common 12.0.18 → 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.
Files changed (206) hide show
  1. package/Models/DatabaseModels/EnterpriseLicense.ts +23 -0
  2. package/Models/DatabaseModels/Index.ts +4 -2
  3. package/Models/DatabaseModels/Monitor.ts +39 -9
  4. package/Models/DatabaseModels/UserMicrosoftTeams.ts +344 -0
  5. package/Models/DatabaseModels/UserNotificationRule.ts +144 -8
  6. package/Models/DatabaseModels/UserNotificationSetting.ts +34 -0
  7. package/Models/DatabaseModels/UserOnCallLogTimeline.ts +95 -0
  8. package/Models/DatabaseModels/UserSlack.ts +341 -0
  9. package/Models/DatabaseModels/WorkspaceProjectAuthToken.ts +9 -0
  10. package/Server/API/UserMicrosoftTeamsAPI.ts +127 -0
  11. package/Server/API/UserSlackAPI.ts +125 -0
  12. package/Server/EnvironmentConfig.ts +12 -107
  13. package/Server/Infrastructure/Postgres/SchemaMigrations/1788700000000-RemoveMarketingConversionUploadState.ts +33 -0
  14. package/Server/Infrastructure/Postgres/SchemaMigrations/1788800000000-DropMarketingConversionAddEnterpriseLicenseEmail.ts +51 -0
  15. package/Server/Infrastructure/Postgres/SchemaMigrations/1788900000000-RedactStoredMonitorIngestSecrets.ts +117 -0
  16. package/Server/Infrastructure/Postgres/SchemaMigrations/1789000000000-AddUserSlackAndMicrosoftTeams.ts +197 -0
  17. package/Server/Infrastructure/Postgres/SchemaMigrations/Index.ts +8 -0
  18. package/Server/Infrastructure/Queue.ts +7 -0
  19. package/Server/Services/EnterpriseLicenseService.ts +60 -0
  20. package/Server/Services/Index.ts +6 -2
  21. package/Server/Services/LlmLogService.ts +25 -9
  22. package/Server/Services/OnCallReadinessService.ts +86 -2
  23. package/Server/Services/ProjectService.ts +67 -0
  24. package/Server/Services/UserMicrosoftTeamsService.ts +208 -0
  25. package/Server/Services/UserNotificationMethodAdminService.ts +167 -5
  26. package/Server/Services/UserNotificationRuleAdminService.ts +40 -6
  27. package/Server/Services/UserNotificationRuleService.ts +589 -11
  28. package/Server/Services/UserNotificationSettingService.ts +138 -0
  29. package/Server/Services/UserService.ts +28 -0
  30. package/Server/Services/UserSlackService.ts +218 -0
  31. package/Server/Services/WorkspaceProjectAuthTokenService.ts +67 -1
  32. package/Server/Services/WorkspaceUserAuthTokenService.ts +73 -0
  33. package/Server/Services/WorkspaceUserNotificationService.ts +190 -0
  34. package/Server/Utils/Marketing/MarketingEventUtil.ts +145 -0
  35. package/Server/Utils/Marketing/MarketingEventWebhook.ts +114 -0
  36. package/Server/Utils/Monitor/MonitorLogUtil.ts +14 -1
  37. package/Server/Utils/Monitor/MonitorPayloadRedaction.ts +321 -0
  38. package/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeams.ts +191 -4
  39. package/Tests/App/Dashboard/AdminNotificationRulesPage.test.tsx +22 -14
  40. package/Tests/App/Dashboard/AdminUserNotificationMethodsPage.test.tsx +22 -11
  41. package/Tests/App/Dashboard/OnCallPreventionGuards.test.tsx +37 -1
  42. package/Tests/App/Dashboard/OnCallRulesTable.test.tsx +18 -10
  43. package/Tests/Models/DatabaseModels/DomainRoleTierCoverage.test.ts +27 -1
  44. package/Tests/Models/DatabaseModels/MonitorSecretKeyColumnAccessControl.test.ts +214 -0
  45. package/Tests/Server/API/OnCallReadinessAPI.test.ts +145 -26
  46. package/Tests/Server/API/UserNotificationMethodAdminAPI.test.ts +2 -2
  47. package/Tests/Server/Services/AIServiceDailyBudget.test.ts +11 -1
  48. package/Tests/Server/Services/AdminRuleEditGuards.test.ts +22 -8
  49. package/Tests/Server/Services/DeliverNotificationForRuleExtraction.test.ts +18 -2
  50. package/Tests/Server/Services/EpisodeRuleSeverityRepair.test.ts +5 -1
  51. package/Tests/Server/Services/LlmLogServiceTokenAggregateParams.test.ts +640 -0
  52. package/Tests/Server/Services/NotificationChannelEventCoverage.test.ts +246 -22
  53. package/Tests/Server/Services/NotificationDeletionImpact.test.ts +136 -8
  54. package/Tests/Server/Services/OnCallNotificationFallback.test.ts +191 -8
  55. package/Tests/Server/Services/OnCallReadinessService.test.ts +343 -18
  56. package/Tests/Server/Services/SeverityRuleBackfill.test.ts +5 -1
  57. package/Tests/Server/Services/UserMicrosoftTeamsService.test.ts +343 -0
  58. package/Tests/Server/Services/UserNotificationMethodAdminService.test.ts +209 -8
  59. package/Tests/Server/Services/UserNotificationRuleAdminGuards.test.ts +22 -6
  60. package/Tests/Server/Services/UserNotificationRuleDefaultCreation.test.ts +12 -6
  61. package/Tests/Server/Services/UserNotificationRuleExecuteItem.test.ts +37 -3
  62. package/Tests/Server/Services/UserNotificationRuleWorkspaceDelivery.test.ts +669 -0
  63. package/Tests/Server/Services/UserNotificationSettingWorkspaceChannels.test.ts +410 -0
  64. package/Tests/Server/Services/UserSlackService.test.ts +407 -0
  65. package/Tests/Server/Services/WorkspaceProjectAuthTokenDisconnectCascade.test.ts +224 -0
  66. package/Tests/Server/Services/WorkspaceUserAuthTokenNotificationMethodCascade.test.ts +189 -0
  67. package/Tests/Server/Services/WorkspaceUserNotificationService.test.ts +496 -0
  68. package/Tests/Server/Types/Database/Permissions/AdminNotificationRuleAccess.test.ts +30 -17
  69. package/Tests/Server/Types/Database/Permissions/CreateOwnershipScoping.test.ts +8 -3
  70. package/Tests/Server/Types/Database/Permissions/OwnerOnlyColumns.test.ts +72 -3
  71. package/Tests/Server/Types/Database/Permissions/UserNotificationRuleScoping.test.ts +22 -18
  72. package/Tests/Server/Types/Database/Permissions/WorkspaceMethodStampedColumnCreate.test.ts +178 -0
  73. package/Tests/Server/Utils/Marketing/MarketingEventUtil.test.ts +259 -0
  74. package/Tests/Server/Utils/Marketing/MarketingEventWebhook.test.ts +257 -0
  75. package/Tests/Server/Utils/Monitor/MonitorLogUtilRedaction.test.ts +300 -0
  76. package/Tests/Server/Utils/Monitor/MonitorPayloadRedaction.test.ts +381 -0
  77. package/Tests/Server/Utils/Runbook/RunbookExecutePermission.test.ts +228 -0
  78. package/Tests/Server/Utils/SessionReplay/SessionReplayErasureTombstone.test.ts +189 -0
  79. package/Tests/Server/Utils/SessionReplay/SessionReplayUsage.test.ts +205 -0
  80. package/Tests/Server/Utils/Telemetry/AppMetrics.test.ts +275 -0
  81. package/Tests/Server/Utils/Telemetry/TelemetryContext.test.ts +279 -0
  82. package/Tests/Server/Utils/Workspace/MicrosoftTeamsDirectMessage.test.ts +454 -0
  83. package/Tests/UI/Utils/NotificationMethodUtil.test.ts +137 -9
  84. package/Tests/UI/Utils/PermissionGate.test.ts +105 -0
  85. package/Types/Marketing/MarketingEvent.ts +97 -0
  86. package/UI/Utils/NotificationMethodUtil.ts +41 -1
  87. package/UI/Utils/PermissionGate.ts +56 -0
  88. package/build/dist/Models/DatabaseModels/EnterpriseLicense.js +24 -0
  89. package/build/dist/Models/DatabaseModels/EnterpriseLicense.js.map +1 -1
  90. package/build/dist/Models/DatabaseModels/Index.js +4 -2
  91. package/build/dist/Models/DatabaseModels/Index.js.map +1 -1
  92. package/build/dist/Models/DatabaseModels/Monitor.js +39 -9
  93. package/build/dist/Models/DatabaseModels/Monitor.js.map +1 -1
  94. package/build/dist/Models/DatabaseModels/UserMicrosoftTeams.js +363 -0
  95. package/build/dist/Models/DatabaseModels/UserMicrosoftTeams.js.map +1 -0
  96. package/build/dist/Models/DatabaseModels/UserNotificationRule.js +145 -8
  97. package/build/dist/Models/DatabaseModels/UserNotificationRule.js.map +1 -1
  98. package/build/dist/Models/DatabaseModels/UserNotificationSetting.js +38 -0
  99. package/build/dist/Models/DatabaseModels/UserNotificationSetting.js.map +1 -1
  100. package/build/dist/Models/DatabaseModels/UserOnCallLogTimeline.js +96 -0
  101. package/build/dist/Models/DatabaseModels/UserOnCallLogTimeline.js.map +1 -1
  102. package/build/dist/Models/DatabaseModels/UserSlack.js +361 -0
  103. package/build/dist/Models/DatabaseModels/UserSlack.js.map +1 -0
  104. package/build/dist/Models/DatabaseModels/WorkspaceProjectAuthToken.js.map +1 -1
  105. package/build/dist/Server/API/UserMicrosoftTeamsAPI.js +82 -0
  106. package/build/dist/Server/API/UserMicrosoftTeamsAPI.js.map +1 -0
  107. package/build/dist/Server/API/UserSlackAPI.js +81 -0
  108. package/build/dist/Server/API/UserSlackAPI.js.map +1 -0
  109. package/build/dist/Server/EnvironmentConfig.js +10 -70
  110. package/build/dist/Server/EnvironmentConfig.js.map +1 -1
  111. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1788700000000-RemoveMarketingConversionUploadState.js +26 -0
  112. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1788700000000-RemoveMarketingConversionUploadState.js.map +1 -0
  113. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1788800000000-DropMarketingConversionAddEnterpriseLicenseEmail.js +37 -0
  114. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1788800000000-DropMarketingConversionAddEnterpriseLicenseEmail.js.map +1 -0
  115. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1788900000000-RedactStoredMonitorIngestSecrets.js +106 -0
  116. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1788900000000-RedactStoredMonitorIngestSecrets.js.map +1 -0
  117. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1789000000000-AddUserSlackAndMicrosoftTeams.js +78 -0
  118. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1789000000000-AddUserSlackAndMicrosoftTeams.js.map +1 -0
  119. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/Index.js +8 -0
  120. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/Index.js.map +1 -1
  121. package/build/dist/Server/Infrastructure/Queue.js +7 -0
  122. package/build/dist/Server/Infrastructure/Queue.js.map +1 -1
  123. package/build/dist/Server/Services/EnterpriseLicenseService.js +65 -0
  124. package/build/dist/Server/Services/EnterpriseLicenseService.js.map +1 -1
  125. package/build/dist/Server/Services/Index.js +6 -2
  126. package/build/dist/Server/Services/Index.js.map +1 -1
  127. package/build/dist/Server/Services/LlmLogService.js +25 -9
  128. package/build/dist/Server/Services/LlmLogService.js.map +1 -1
  129. package/build/dist/Server/Services/OnCallReadinessService.js +74 -2
  130. package/build/dist/Server/Services/OnCallReadinessService.js.map +1 -1
  131. package/build/dist/Server/Services/ProjectService.js +56 -0
  132. package/build/dist/Server/Services/ProjectService.js.map +1 -1
  133. package/build/dist/Server/Services/UserMicrosoftTeamsService.js +183 -0
  134. package/build/dist/Server/Services/UserMicrosoftTeamsService.js.map +1 -0
  135. package/build/dist/Server/Services/UserNotificationMethodAdminService.js +138 -2
  136. package/build/dist/Server/Services/UserNotificationMethodAdminService.js.map +1 -1
  137. package/build/dist/Server/Services/UserNotificationRuleAdminService.js +32 -4
  138. package/build/dist/Server/Services/UserNotificationRuleAdminService.js.map +1 -1
  139. package/build/dist/Server/Services/UserNotificationRuleService.js +499 -67
  140. package/build/dist/Server/Services/UserNotificationRuleService.js.map +1 -1
  141. package/build/dist/Server/Services/UserNotificationSettingService.js +118 -0
  142. package/build/dist/Server/Services/UserNotificationSettingService.js.map +1 -1
  143. package/build/dist/Server/Services/UserService.js +26 -1
  144. package/build/dist/Server/Services/UserService.js.map +1 -1
  145. package/build/dist/Server/Services/UserSlackService.js +195 -0
  146. package/build/dist/Server/Services/UserSlackService.js.map +1 -0
  147. package/build/dist/Server/Services/WorkspaceProjectAuthTokenService.js +64 -1
  148. package/build/dist/Server/Services/WorkspaceProjectAuthTokenService.js.map +1 -1
  149. package/build/dist/Server/Services/WorkspaceUserAuthTokenService.js +70 -0
  150. package/build/dist/Server/Services/WorkspaceUserAuthTokenService.js.map +1 -1
  151. package/build/dist/Server/Services/WorkspaceUserNotificationService.js +129 -0
  152. package/build/dist/Server/Services/WorkspaceUserNotificationService.js.map +1 -0
  153. package/build/dist/Server/Utils/Marketing/MarketingEventUtil.js +94 -0
  154. package/build/dist/Server/Utils/Marketing/MarketingEventUtil.js.map +1 -0
  155. package/build/dist/Server/Utils/Marketing/MarketingEventWebhook.js +93 -0
  156. package/build/dist/Server/Utils/Marketing/MarketingEventWebhook.js.map +1 -0
  157. package/build/dist/Server/Utils/Monitor/MonitorLogUtil.js +12 -1
  158. package/build/dist/Server/Utils/Monitor/MonitorLogUtil.js.map +1 -1
  159. package/build/dist/Server/Utils/Monitor/MonitorPayloadRedaction.js +233 -0
  160. package/build/dist/Server/Utils/Monitor/MonitorPayloadRedaction.js.map +1 -0
  161. package/build/dist/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeams.js +141 -4
  162. package/build/dist/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeams.js.map +1 -1
  163. package/build/dist/Types/Marketing/MarketingEvent.js +43 -0
  164. package/build/dist/Types/Marketing/MarketingEvent.js.map +1 -0
  165. package/build/dist/UI/Utils/NotificationMethodUtil.js +33 -1
  166. package/build/dist/UI/Utils/NotificationMethodUtil.js.map +1 -1
  167. package/build/dist/UI/Utils/PermissionGate.js +32 -0
  168. package/build/dist/UI/Utils/PermissionGate.js.map +1 -1
  169. package/package.json +1 -1
  170. package/Models/DatabaseModels/MarketingConversion.ts +0 -410
  171. package/Server/Services/MarketingConversionService.ts +0 -10
  172. package/Server/Utils/Marketing/ConversionUploadProvider.ts +0 -215
  173. package/Server/Utils/Marketing/ConversionUploadProviders.ts +0 -22
  174. package/Server/Utils/Marketing/Providers/GoogleAds.ts +0 -333
  175. package/Server/Utils/Marketing/Providers/LinkedIn.ts +0 -185
  176. package/Server/Utils/Marketing/Providers/Meta.ts +0 -182
  177. package/Server/Utils/Marketing/Providers/MicrosoftAds.ts +0 -223
  178. package/Server/Utils/Marketing/Providers/Reddit.ts +0 -208
  179. package/Tests/Server/Utils/Marketing/AdUploadableConversionTypes.test.ts +0 -315
  180. package/Tests/Server/Utils/Marketing/ConversionUploadProvider.test.ts +0 -300
  181. package/Tests/Server/Utils/Marketing/GoogleAds.test.ts +0 -592
  182. package/Tests/Server/Utils/Marketing/LinkedIn.test.ts +0 -282
  183. package/Tests/Server/Utils/Marketing/Meta.test.ts +0 -304
  184. package/Tests/Server/Utils/Marketing/MicrosoftAds.test.ts +0 -263
  185. package/Tests/Server/Utils/Marketing/Reddit.test.ts +0 -259
  186. package/Types/Marketing/MarketingConversion.ts +0 -53
  187. package/build/dist/Models/DatabaseModels/MarketingConversion.js +0 -445
  188. package/build/dist/Models/DatabaseModels/MarketingConversion.js.map +0 -1
  189. package/build/dist/Server/Services/MarketingConversionService.js +0 -9
  190. package/build/dist/Server/Services/MarketingConversionService.js.map +0 -1
  191. package/build/dist/Server/Utils/Marketing/ConversionUploadProvider.js +0 -93
  192. package/build/dist/Server/Utils/Marketing/ConversionUploadProvider.js.map +0 -1
  193. package/build/dist/Server/Utils/Marketing/ConversionUploadProviders.js +0 -20
  194. package/build/dist/Server/Utils/Marketing/ConversionUploadProviders.js.map +0 -1
  195. package/build/dist/Server/Utils/Marketing/Providers/GoogleAds.js +0 -221
  196. package/build/dist/Server/Utils/Marketing/Providers/GoogleAds.js.map +0 -1
  197. package/build/dist/Server/Utils/Marketing/Providers/LinkedIn.js +0 -137
  198. package/build/dist/Server/Utils/Marketing/Providers/LinkedIn.js.map +0 -1
  199. package/build/dist/Server/Utils/Marketing/Providers/Meta.js +0 -133
  200. package/build/dist/Server/Utils/Marketing/Providers/Meta.js.map +0 -1
  201. package/build/dist/Server/Utils/Marketing/Providers/MicrosoftAds.js +0 -143
  202. package/build/dist/Server/Utils/Marketing/Providers/MicrosoftAds.js.map +0 -1
  203. package/build/dist/Server/Utils/Marketing/Providers/Reddit.js +0 -145
  204. package/build/dist/Server/Utils/Marketing/Providers/Reddit.js.map +0 -1
  205. package/build/dist/Types/Marketing/MarketingConversion.js +0 -52
  206. package/build/dist/Types/Marketing/MarketingConversion.js.map +0 -1
@@ -27,8 +27,11 @@ import UserCallService from "./UserCallService";
27
27
  import UserPushService from "./UserPushService";
28
28
  import UserSmsService from "./UserSmsService";
29
29
  import UserTelegramService from "./UserTelegramService";
30
+ import UserSlackService from "./UserSlackService";
31
+ import UserMicrosoftTeamsService from "./UserMicrosoftTeamsService";
30
32
  import UserWebhookService from "./UserWebhookService";
31
33
  import UserWhatsAppService from "./UserWhatsAppService";
34
+ import WorkspaceUserNotificationService from "./WorkspaceUserNotificationService";
32
35
  import ProjectService from "./ProjectService";
33
36
  import UserNotificationRuleAdminService from "./UserNotificationRuleAdminService";
34
37
  import OnCallReadinessService, { ReadinessMethodType, ReadinessStatus, ResponderSource, } from "./OnCallReadinessService";
@@ -68,6 +71,7 @@ import IncidentEpisodeMemberService from "./IncidentEpisodeMemberService";
68
71
  import WorkspaceNotificationRuleService from "./WorkspaceNotificationRuleService";
69
72
  import PushNotificationService from "./PushNotificationService";
70
73
  import NotificationRuleEventType from "../../Types/Workspace/NotificationRules/EventType";
74
+ import WorkspaceType, { getWorkspaceTypeDisplayName, } from "../../Types/Workspace/WorkspaceType";
71
75
  import PushNotificationUtil from "../Utils/PushNotificationUtil";
72
76
  import logger from "../Utils/Logger";
73
77
  import CaptureSpan from "../Utils/Telemetry/CaptureSpan";
@@ -266,12 +270,13 @@ const HANDOFF_RULE_TYPES = [
266
270
  NotificationRuleType.WHEN_USER_GOES_OFF_CALL,
267
271
  ];
268
272
  /**
269
- * The three channels no project setting can switch off. Push and Email are
270
- * zero-cost and Webhook is somebody else's endpoint, so nothing gates them
271
- * which is what makes "a verified one of these survives" a CERTAIN answer to
272
- * "can this person still be paged" rather than a hopeful one. Kept in step with
273
- * OnCallReadinessService.isChannelEnabled, which returns true for exactly these
274
- * three unconditionally.
273
+ * The channels no project setting can switch off. Push and Email are
274
+ * zero-cost, Webhook is somebody else's endpoint, and Slack / Microsoft Teams
275
+ * ride on the project's own workspace connection at no per-message cost, so
276
+ * nothing gates them which is what makes "a verified one of these survives"
277
+ * a CERTAIN answer to "can this person still be paged" rather than a hopeful
278
+ * one. Kept in step with OnCallReadinessService.isChannelEnabled, which
279
+ * returns true for exactly these five unconditionally.
275
280
  *
276
281
  * A FUNCTION rather than a module-level constant, and that is load-bearing
277
282
  * rather than stylistic: this module and OnCallReadinessService import each
@@ -287,6 +292,8 @@ const channelsWithNoProjectSwitch = () => {
287
292
  return [
288
293
  ReadinessMethodType.Push,
289
294
  ReadinessMethodType.Email,
295
+ ReadinessMethodType.Slack,
296
+ ReadinessMethodType.MicrosoftTeams,
290
297
  ReadinessMethodType.Webhook,
291
298
  ];
292
299
  };
@@ -374,6 +381,18 @@ export class Service extends DatabaseService {
374
381
  isVerified: true,
375
382
  userId: true,
376
383
  },
384
+ userSlack: {
385
+ slackUserId: true,
386
+ slackUserName: true,
387
+ isVerified: true,
388
+ userId: true,
389
+ },
390
+ userMicrosoftTeams: {
391
+ microsoftTeamsUserId: true,
392
+ microsoftTeamsUserName: true,
393
+ isVerified: true,
394
+ userId: true,
395
+ },
377
396
  userWebhook: {
378
397
  webhookUrl: true,
379
398
  name: true,
@@ -439,7 +458,7 @@ export class Service extends DatabaseService {
439
458
  * is the only safe default for a check that can suppress a page.
440
459
  */
441
460
  getNotificationMethodsNotOwnedByRuleOwner(notificationRuleItem) {
442
- var _a, _b, _c, _d, _e, _f, _g;
461
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
443
462
  const ruleOwnerUserId = notificationRuleItem.userId;
444
463
  if (!ruleOwnerUserId) {
445
464
  /*
@@ -461,10 +480,18 @@ export class Service extends DatabaseService {
461
480
  label: "Telegram",
462
481
  ownerUserId: (_e = notificationRuleItem.userTelegram) === null || _e === void 0 ? void 0 : _e.userId,
463
482
  },
464
- { label: "Push", ownerUserId: (_f = notificationRuleItem.userPush) === null || _f === void 0 ? void 0 : _f.userId },
483
+ {
484
+ label: "Slack",
485
+ ownerUserId: (_f = notificationRuleItem.userSlack) === null || _f === void 0 ? void 0 : _f.userId,
486
+ },
487
+ {
488
+ label: "Microsoft Teams",
489
+ ownerUserId: (_g = notificationRuleItem.userMicrosoftTeams) === null || _g === void 0 ? void 0 : _g.userId,
490
+ },
491
+ { label: "Push", ownerUserId: (_h = notificationRuleItem.userPush) === null || _h === void 0 ? void 0 : _h.userId },
465
492
  {
466
493
  label: "Webhook",
467
- ownerUserId: (_g = notificationRuleItem.userWebhook) === null || _g === void 0 ? void 0 : _g.userId,
494
+ ownerUserId: (_j = notificationRuleItem.userWebhook) === null || _j === void 0 ? void 0 : _j.userId,
468
495
  },
469
496
  ];
470
497
  const mismatched = [];
@@ -576,7 +603,7 @@ export class Service extends DatabaseService {
576
603
  * would name a channel the responder never heard from.
577
604
  */
578
605
  async deliverNotificationForRule(notificationRuleItem, options) {
579
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32, _33, _34, _35, _36, _37, _38, _39, _40, _41, _42, _43, _44, _45, _46, _47, _48, _49, _50, _51, _52, _53, _54, _55;
606
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32, _33, _34, _35, _36, _37, _38, _39, _40, _41, _42, _43, _44, _45, _46, _47, _48, _49, _50, _51, _52, _53, _54, _55, _56, _57, _58, _59, _60, _61;
580
607
  /*
581
608
  * If the project has a default Twilio config set, use it for all
582
609
  * team-member SMS and Calls in this rule. Otherwise the global config
@@ -1421,8 +1448,67 @@ export class Service extends DatabaseService {
1421
1448
  },
1422
1449
  });
1423
1450
  }
1451
+ // send Slack.
1452
+ if (((_10 = notificationRuleItem.userSlack) === null || _10 === void 0 ? void 0 : _10.slackUserId) &&
1453
+ ((_11 = notificationRuleItem.userSlack) === null || _11 === void 0 ? void 0 : _11.isVerified)) {
1454
+ const attempted = await this.deliverWorkspaceDirectMessageForRule({
1455
+ workspaceType: WorkspaceType.Slack,
1456
+ methodId: notificationRuleItem.userSlack.id,
1457
+ workspaceUserId: notificationRuleItem.userSlack.slackUserId,
1458
+ notificationRuleItem: notificationRuleItem,
1459
+ options: options,
1460
+ logTimelineItem: logTimelineItem,
1461
+ incident: incident,
1462
+ alert: alert,
1463
+ alertEpisode: alertEpisode,
1464
+ incidentEpisode: incidentEpisode,
1465
+ });
1466
+ deliveryAttempted = deliveryAttempted || attempted;
1467
+ }
1468
+ if (notificationRuleItem.userSlack &&
1469
+ !((_12 = notificationRuleItem.userSlack) === null || _12 === void 0 ? void 0 : _12.isVerified)) {
1470
+ logTimelineItem.status = UserNotificationStatus.Error;
1471
+ logTimelineItem.statusMessage = `Slack message not sent because the Slack account is not verified.`;
1472
+ logTimelineItem.userSlackId = notificationRuleItem.userSlack.id;
1473
+ await UserOnCallLogTimelineService.create({
1474
+ data: logTimelineItem,
1475
+ props: {
1476
+ isRoot: true,
1477
+ },
1478
+ });
1479
+ }
1480
+ // send Microsoft Teams.
1481
+ if (((_13 = notificationRuleItem.userMicrosoftTeams) === null || _13 === void 0 ? void 0 : _13.microsoftTeamsUserId) &&
1482
+ ((_14 = notificationRuleItem.userMicrosoftTeams) === null || _14 === void 0 ? void 0 : _14.isVerified)) {
1483
+ const attempted = await this.deliverWorkspaceDirectMessageForRule({
1484
+ workspaceType: WorkspaceType.MicrosoftTeams,
1485
+ methodId: notificationRuleItem.userMicrosoftTeams.id,
1486
+ workspaceUserId: notificationRuleItem.userMicrosoftTeams.microsoftTeamsUserId,
1487
+ notificationRuleItem: notificationRuleItem,
1488
+ options: options,
1489
+ logTimelineItem: logTimelineItem,
1490
+ incident: incident,
1491
+ alert: alert,
1492
+ alertEpisode: alertEpisode,
1493
+ incidentEpisode: incidentEpisode,
1494
+ });
1495
+ deliveryAttempted = deliveryAttempted || attempted;
1496
+ }
1497
+ if (notificationRuleItem.userMicrosoftTeams &&
1498
+ !((_15 = notificationRuleItem.userMicrosoftTeams) === null || _15 === void 0 ? void 0 : _15.isVerified)) {
1499
+ logTimelineItem.status = UserNotificationStatus.Error;
1500
+ logTimelineItem.statusMessage = `Microsoft Teams message not sent because the Microsoft Teams account is not verified.`;
1501
+ logTimelineItem.userMicrosoftTeamsId =
1502
+ notificationRuleItem.userMicrosoftTeams.id;
1503
+ await UserOnCallLogTimelineService.create({
1504
+ data: logTimelineItem,
1505
+ props: {
1506
+ isRoot: true,
1507
+ },
1508
+ });
1509
+ }
1424
1510
  // send webhook.
1425
- if ((_10 = notificationRuleItem.userWebhook) === null || _10 === void 0 ? void 0 : _10.webhookUrl) {
1511
+ if ((_16 = notificationRuleItem.userWebhook) === null || _16 === void 0 ? void 0 : _16.webhookUrl) {
1426
1512
  const webhookUrl = notificationRuleItem.userWebhook.webhookUrl;
1427
1513
  const webhookSecret = notificationRuleItem.userWebhook.secret;
1428
1514
  const userWebhookId = notificationRuleItem.userWebhook.id;
@@ -1472,19 +1558,19 @@ export class Service extends DatabaseService {
1472
1558
  payload: {
1473
1559
  eventType: "on-call.alert.created",
1474
1560
  timestamp: new Date().toISOString(),
1475
- projectId: ((_11 = alert.projectId) === null || _11 === void 0 ? void 0 : _11.toString()) || "",
1561
+ projectId: ((_17 = alert.projectId) === null || _17 === void 0 ? void 0 : _17.toString()) || "",
1476
1562
  userId: notificationRuleItem.userId.toString(),
1477
1563
  alert: {
1478
- id: ((_12 = alert.id) === null || _12 === void 0 ? void 0 : _12.toString()) || "",
1564
+ id: ((_18 = alert.id) === null || _18 === void 0 ? void 0 : _18.toString()) || "",
1479
1565
  title: alert.title || "",
1480
1566
  description: alert.description || "",
1481
1567
  alertNumber: alert.alertNumber || null,
1482
1568
  alertNumberWithPrefix: alert.alertNumberWithPrefix || null,
1483
- severity: ((_13 = alert.alertSeverity) === null || _13 === void 0 ? void 0 : _13.name) || null,
1484
- state: ((_14 = alert.currentAlertState) === null || _14 === void 0 ? void 0 : _14.name) || null,
1569
+ severity: ((_19 = alert.alertSeverity) === null || _19 === void 0 ? void 0 : _19.name) || null,
1570
+ state: ((_20 = alert.currentAlertState) === null || _20 === void 0 ? void 0 : _20.name) || null,
1485
1571
  },
1486
- onCallPolicyId: ((_15 = options.onCallPolicyId) === null || _15 === void 0 ? void 0 : _15.toString()) || null,
1487
- onCallPolicyEscalationRuleId: ((_16 = options.onCallPolicyEscalationRuleId) === null || _16 === void 0 ? void 0 : _16.toString()) || null,
1572
+ onCallPolicyId: ((_21 = options.onCallPolicyId) === null || _21 === void 0 ? void 0 : _21.toString()) || null,
1573
+ onCallPolicyEscalationRuleId: ((_22 = options.onCallPolicyEscalationRuleId) === null || _22 === void 0 ? void 0 : _22.toString()) || null,
1488
1574
  },
1489
1575
  });
1490
1576
  }
@@ -1498,19 +1584,19 @@ export class Service extends DatabaseService {
1498
1584
  payload: {
1499
1585
  eventType: "on-call.incident.created",
1500
1586
  timestamp: new Date().toISOString(),
1501
- projectId: ((_17 = incident.projectId) === null || _17 === void 0 ? void 0 : _17.toString()) || "",
1587
+ projectId: ((_23 = incident.projectId) === null || _23 === void 0 ? void 0 : _23.toString()) || "",
1502
1588
  userId: notificationRuleItem.userId.toString(),
1503
1589
  incident: {
1504
- id: ((_18 = incident.id) === null || _18 === void 0 ? void 0 : _18.toString()) || "",
1590
+ id: ((_24 = incident.id) === null || _24 === void 0 ? void 0 : _24.toString()) || "",
1505
1591
  title: incident.title || "",
1506
1592
  description: incident.description || "",
1507
1593
  incidentNumber: incident.incidentNumber || null,
1508
1594
  incidentNumberWithPrefix: incident.incidentNumberWithPrefix || null,
1509
- severity: ((_19 = incident.incidentSeverity) === null || _19 === void 0 ? void 0 : _19.name) || null,
1510
- state: ((_20 = incident.currentIncidentState) === null || _20 === void 0 ? void 0 : _20.name) || null,
1595
+ severity: ((_25 = incident.incidentSeverity) === null || _25 === void 0 ? void 0 : _25.name) || null,
1596
+ state: ((_26 = incident.currentIncidentState) === null || _26 === void 0 ? void 0 : _26.name) || null,
1511
1597
  },
1512
- onCallPolicyId: ((_21 = options.onCallPolicyId) === null || _21 === void 0 ? void 0 : _21.toString()) || null,
1513
- onCallPolicyEscalationRuleId: ((_22 = options.onCallPolicyEscalationRuleId) === null || _22 === void 0 ? void 0 : _22.toString()) || null,
1598
+ onCallPolicyId: ((_27 = options.onCallPolicyId) === null || _27 === void 0 ? void 0 : _27.toString()) || null,
1599
+ onCallPolicyEscalationRuleId: ((_28 = options.onCallPolicyEscalationRuleId) === null || _28 === void 0 ? void 0 : _28.toString()) || null,
1514
1600
  },
1515
1601
  });
1516
1602
  }
@@ -1523,19 +1609,19 @@ export class Service extends DatabaseService {
1523
1609
  payload: {
1524
1610
  eventType: "on-call.alertEpisode.created",
1525
1611
  timestamp: new Date().toISOString(),
1526
- projectId: ((_23 = alertEpisode.projectId) === null || _23 === void 0 ? void 0 : _23.toString()) || "",
1612
+ projectId: ((_29 = alertEpisode.projectId) === null || _29 === void 0 ? void 0 : _29.toString()) || "",
1527
1613
  userId: notificationRuleItem.userId.toString(),
1528
1614
  alertEpisode: {
1529
- id: ((_24 = alertEpisode.id) === null || _24 === void 0 ? void 0 : _24.toString()) || "",
1615
+ id: ((_30 = alertEpisode.id) === null || _30 === void 0 ? void 0 : _30.toString()) || "",
1530
1616
  title: alertEpisode.title || "",
1531
1617
  description: alertEpisode.description || "",
1532
1618
  episodeNumber: alertEpisode.episodeNumber || null,
1533
1619
  episodeNumberWithPrefix: alertEpisode.episodeNumberWithPrefix || null,
1534
- severity: ((_25 = alertEpisode.alertSeverity) === null || _25 === void 0 ? void 0 : _25.name) || null,
1535
- state: ((_26 = alertEpisode.currentAlertState) === null || _26 === void 0 ? void 0 : _26.name) || null,
1620
+ severity: ((_31 = alertEpisode.alertSeverity) === null || _31 === void 0 ? void 0 : _31.name) || null,
1621
+ state: ((_32 = alertEpisode.currentAlertState) === null || _32 === void 0 ? void 0 : _32.name) || null,
1536
1622
  },
1537
- onCallPolicyId: ((_27 = options.onCallPolicyId) === null || _27 === void 0 ? void 0 : _27.toString()) || null,
1538
- onCallPolicyEscalationRuleId: ((_28 = options.onCallPolicyEscalationRuleId) === null || _28 === void 0 ? void 0 : _28.toString()) || null,
1623
+ onCallPolicyId: ((_33 = options.onCallPolicyId) === null || _33 === void 0 ? void 0 : _33.toString()) || null,
1624
+ onCallPolicyEscalationRuleId: ((_34 = options.onCallPolicyEscalationRuleId) === null || _34 === void 0 ? void 0 : _34.toString()) || null,
1539
1625
  },
1540
1626
  });
1541
1627
  }
@@ -1548,26 +1634,26 @@ export class Service extends DatabaseService {
1548
1634
  payload: {
1549
1635
  eventType: "on-call.incidentEpisode.created",
1550
1636
  timestamp: new Date().toISOString(),
1551
- projectId: ((_29 = incidentEpisode.projectId) === null || _29 === void 0 ? void 0 : _29.toString()) || "",
1637
+ projectId: ((_35 = incidentEpisode.projectId) === null || _35 === void 0 ? void 0 : _35.toString()) || "",
1552
1638
  userId: notificationRuleItem.userId.toString(),
1553
1639
  incidentEpisode: {
1554
- id: ((_30 = incidentEpisode.id) === null || _30 === void 0 ? void 0 : _30.toString()) || "",
1640
+ id: ((_36 = incidentEpisode.id) === null || _36 === void 0 ? void 0 : _36.toString()) || "",
1555
1641
  title: incidentEpisode.title || "",
1556
1642
  description: incidentEpisode.description || "",
1557
1643
  episodeNumber: incidentEpisode.episodeNumber || null,
1558
1644
  episodeNumberWithPrefix: incidentEpisode.episodeNumberWithPrefix || null,
1559
- severity: ((_31 = incidentEpisode.incidentSeverity) === null || _31 === void 0 ? void 0 : _31.name) || null,
1560
- state: ((_32 = incidentEpisode.currentIncidentState) === null || _32 === void 0 ? void 0 : _32.name) || null,
1645
+ severity: ((_37 = incidentEpisode.incidentSeverity) === null || _37 === void 0 ? void 0 : _37.name) || null,
1646
+ state: ((_38 = incidentEpisode.currentIncidentState) === null || _38 === void 0 ? void 0 : _38.name) || null,
1561
1647
  },
1562
- onCallPolicyId: ((_33 = options.onCallPolicyId) === null || _33 === void 0 ? void 0 : _33.toString()) || null,
1563
- onCallPolicyEscalationRuleId: ((_34 = options.onCallPolicyEscalationRuleId) === null || _34 === void 0 ? void 0 : _34.toString()) || null,
1648
+ onCallPolicyId: ((_39 = options.onCallPolicyId) === null || _39 === void 0 ? void 0 : _39.toString()) || null,
1649
+ onCallPolicyEscalationRuleId: ((_40 = options.onCallPolicyEscalationRuleId) === null || _40 === void 0 ? void 0 : _40.toString()) || null,
1564
1650
  },
1565
1651
  });
1566
1652
  }
1567
1653
  }
1568
1654
  // send call.
1569
- if (((_35 = notificationRuleItem.userCall) === null || _35 === void 0 ? void 0 : _35.phone) &&
1570
- ((_36 = notificationRuleItem.userCall) === null || _36 === void 0 ? void 0 : _36.isVerified)) {
1655
+ if (((_41 = notificationRuleItem.userCall) === null || _41 === void 0 ? void 0 : _41.phone) &&
1656
+ ((_42 = notificationRuleItem.userCall) === null || _42 === void 0 ? void 0 : _42.isVerified)) {
1571
1657
  // send call for alert
1572
1658
  if (options.userNotificationEventType ===
1573
1659
  UserNotificationEventType.AlertCreated &&
@@ -1575,7 +1661,7 @@ export class Service extends DatabaseService {
1575
1661
  // create an error log.
1576
1662
  deliveryAttempted = true;
1577
1663
  logTimelineItem.status = UserNotificationStatus.Sending;
1578
- logTimelineItem.statusMessage = `Making a call to ${(_37 = notificationRuleItem.userCall) === null || _37 === void 0 ? void 0 : _37.phone.toString()}.`;
1664
+ logTimelineItem.statusMessage = `Making a call to ${(_43 = notificationRuleItem.userCall) === null || _43 === void 0 ? void 0 : _43.phone.toString()}.`;
1579
1665
  logTimelineItem.userCallId = notificationRuleItem.userCall.id;
1580
1666
  const updatedLog = await UserOnCallLogTimelineService.create({
1581
1667
  data: logTimelineItem,
@@ -1583,7 +1669,7 @@ export class Service extends DatabaseService {
1583
1669
  isRoot: true,
1584
1670
  },
1585
1671
  });
1586
- const callRequest = await this.generateCallTemplateForAlertCreated((_38 = notificationRuleItem.userCall) === null || _38 === void 0 ? void 0 : _38.phone, alert, updatedLog.id);
1672
+ const callRequest = await this.generateCallTemplateForAlertCreated((_44 = notificationRuleItem.userCall) === null || _44 === void 0 ? void 0 : _44.phone, alert, updatedLog.id);
1587
1673
  // send call.
1588
1674
  CallService.makeCall(callRequest, {
1589
1675
  projectId: alert.projectId,
@@ -1615,7 +1701,7 @@ export class Service extends DatabaseService {
1615
1701
  // send call for incident
1616
1702
  deliveryAttempted = true;
1617
1703
  logTimelineItem.status = UserNotificationStatus.Sending;
1618
- logTimelineItem.statusMessage = `Making a call to ${(_39 = notificationRuleItem.userCall) === null || _39 === void 0 ? void 0 : _39.phone.toString()}.`;
1704
+ logTimelineItem.statusMessage = `Making a call to ${(_45 = notificationRuleItem.userCall) === null || _45 === void 0 ? void 0 : _45.phone.toString()}.`;
1619
1705
  logTimelineItem.userCallId = notificationRuleItem.userCall.id;
1620
1706
  const updatedLog = await UserOnCallLogTimelineService.create({
1621
1707
  data: logTimelineItem,
@@ -1623,7 +1709,7 @@ export class Service extends DatabaseService {
1623
1709
  isRoot: true,
1624
1710
  },
1625
1711
  });
1626
- const callRequest = await this.generateCallTemplateForIncidentCreated((_40 = notificationRuleItem.userCall) === null || _40 === void 0 ? void 0 : _40.phone, incident, updatedLog.id);
1712
+ const callRequest = await this.generateCallTemplateForIncidentCreated((_46 = notificationRuleItem.userCall) === null || _46 === void 0 ? void 0 : _46.phone, incident, updatedLog.id);
1627
1713
  // send call.
1628
1714
  CallService.makeCall(callRequest, {
1629
1715
  projectId: incident.projectId,
@@ -1655,7 +1741,7 @@ export class Service extends DatabaseService {
1655
1741
  alertEpisode) {
1656
1742
  deliveryAttempted = true;
1657
1743
  logTimelineItem.status = UserNotificationStatus.Sending;
1658
- logTimelineItem.statusMessage = `Making a call to ${(_41 = notificationRuleItem.userCall) === null || _41 === void 0 ? void 0 : _41.phone.toString()}.`;
1744
+ logTimelineItem.statusMessage = `Making a call to ${(_47 = notificationRuleItem.userCall) === null || _47 === void 0 ? void 0 : _47.phone.toString()}.`;
1659
1745
  logTimelineItem.userCallId = notificationRuleItem.userCall.id;
1660
1746
  const updatedLog = await UserOnCallLogTimelineService.create({
1661
1747
  data: logTimelineItem,
@@ -1663,7 +1749,7 @@ export class Service extends DatabaseService {
1663
1749
  isRoot: true,
1664
1750
  },
1665
1751
  });
1666
- const callRequest = await this.generateCallTemplateForAlertEpisodeCreated((_42 = notificationRuleItem.userCall) === null || _42 === void 0 ? void 0 : _42.phone, alertEpisode, updatedLog.id);
1752
+ const callRequest = await this.generateCallTemplateForAlertEpisodeCreated((_48 = notificationRuleItem.userCall) === null || _48 === void 0 ? void 0 : _48.phone, alertEpisode, updatedLog.id);
1667
1753
  CallService.makeCall(callRequest, {
1668
1754
  projectId: alertEpisode.projectId,
1669
1755
  customTwilioConfig: projectTwilioConfig,
@@ -1694,7 +1780,7 @@ export class Service extends DatabaseService {
1694
1780
  incidentEpisode) {
1695
1781
  deliveryAttempted = true;
1696
1782
  logTimelineItem.status = UserNotificationStatus.Sending;
1697
- logTimelineItem.statusMessage = `Making a call to ${(_43 = notificationRuleItem.userCall) === null || _43 === void 0 ? void 0 : _43.phone.toString()}.`;
1783
+ logTimelineItem.statusMessage = `Making a call to ${(_49 = notificationRuleItem.userCall) === null || _49 === void 0 ? void 0 : _49.phone.toString()}.`;
1698
1784
  logTimelineItem.userCallId = notificationRuleItem.userCall.id;
1699
1785
  const updatedLog = await UserOnCallLogTimelineService.create({
1700
1786
  data: logTimelineItem,
@@ -1702,7 +1788,7 @@ export class Service extends DatabaseService {
1702
1788
  isRoot: true,
1703
1789
  },
1704
1790
  });
1705
- const callRequest = await this.generateCallTemplateForIncidentEpisodeCreated((_44 = notificationRuleItem.userCall) === null || _44 === void 0 ? void 0 : _44.phone, incidentEpisode, updatedLog.id);
1791
+ const callRequest = await this.generateCallTemplateForIncidentEpisodeCreated((_50 = notificationRuleItem.userCall) === null || _50 === void 0 ? void 0 : _50.phone, incidentEpisode, updatedLog.id);
1706
1792
  /*
1707
1793
  * CallService accepts incidentEpisodeId but never writes it onto the
1708
1794
  * request body, so it is deliberately not passed here.
@@ -1731,11 +1817,11 @@ export class Service extends DatabaseService {
1731
1817
  });
1732
1818
  }
1733
1819
  }
1734
- if (((_45 = notificationRuleItem.userCall) === null || _45 === void 0 ? void 0 : _45.phone) &&
1735
- !((_46 = notificationRuleItem.userCall) === null || _46 === void 0 ? void 0 : _46.isVerified)) {
1820
+ if (((_51 = notificationRuleItem.userCall) === null || _51 === void 0 ? void 0 : _51.phone) &&
1821
+ !((_52 = notificationRuleItem.userCall) === null || _52 === void 0 ? void 0 : _52.isVerified)) {
1736
1822
  // create a log.
1737
1823
  logTimelineItem.status = UserNotificationStatus.Error;
1738
- logTimelineItem.statusMessage = `Call not sent because phone ${(_47 = notificationRuleItem.userCall) === null || _47 === void 0 ? void 0 : _47.phone.toString()} is not verified.`;
1824
+ logTimelineItem.statusMessage = `Call not sent because phone ${(_53 = notificationRuleItem.userCall) === null || _53 === void 0 ? void 0 : _53.phone.toString()} is not verified.`;
1739
1825
  await UserOnCallLogTimelineService.create({
1740
1826
  data: logTimelineItem,
1741
1827
  props: {
@@ -1744,8 +1830,8 @@ export class Service extends DatabaseService {
1744
1830
  });
1745
1831
  }
1746
1832
  // send push notification.
1747
- if (((_48 = notificationRuleItem.userPush) === null || _48 === void 0 ? void 0 : _48.deviceToken) &&
1748
- ((_49 = notificationRuleItem.userPush) === null || _49 === void 0 ? void 0 : _49.isVerified)) {
1833
+ if (((_54 = notificationRuleItem.userPush) === null || _54 === void 0 ? void 0 : _54.deviceToken) &&
1834
+ ((_55 = notificationRuleItem.userPush) === null || _55 === void 0 ? void 0 : _55.isVerified)) {
1749
1835
  /*
1750
1836
  * This is the on-call paging path - the notification that exists to wake
1751
1837
  * somebody at 3am - so it is the only push in the product allowed to
@@ -1769,7 +1855,7 @@ export class Service extends DatabaseService {
1769
1855
  isRoot: true,
1770
1856
  },
1771
1857
  });
1772
- const pushMessage = PushNotificationUtil.createAlertCreatedNotification(Object.assign(Object.assign(Object.assign({ alertTitle: alert.title, projectName: ((_50 = alert.project) === null || _50 === void 0 ? void 0 : _50.name) || "OneUptime", alertViewLink: (await AlertService.getAlertLinkInDashboard(alert.projectId, alert.id)).toString() }, (alert.alertNumber !== undefined && {
1858
+ const pushMessage = PushNotificationUtil.createAlertCreatedNotification(Object.assign(Object.assign(Object.assign({ alertTitle: alert.title, projectName: ((_56 = alert.project) === null || _56 === void 0 ? void 0 : _56.name) || "OneUptime", alertViewLink: (await AlertService.getAlertLinkInDashboard(alert.projectId, alert.id)).toString() }, (alert.alertNumber !== undefined && {
1773
1859
  alertNumber: alert.alertNumber,
1774
1860
  })), (alert.alertNumberWithPrefix && {
1775
1861
  alertNumberWithPrefix: alert.alertNumberWithPrefix,
@@ -1823,7 +1909,7 @@ export class Service extends DatabaseService {
1823
1909
  isRoot: true,
1824
1910
  },
1825
1911
  });
1826
- const pushMessage = PushNotificationUtil.createIncidentCreatedNotification(Object.assign(Object.assign(Object.assign({ incidentTitle: incident.title, projectName: ((_51 = incident.project) === null || _51 === void 0 ? void 0 : _51.name) || "OneUptime", incidentViewLink: (await IncidentService.getIncidentLinkInDashboard(incident.projectId, incident.id)).toString() }, (incident.incidentNumber !== undefined && {
1912
+ const pushMessage = PushNotificationUtil.createIncidentCreatedNotification(Object.assign(Object.assign(Object.assign({ incidentTitle: incident.title, projectName: ((_57 = incident.project) === null || _57 === void 0 ? void 0 : _57.name) || "OneUptime", incidentViewLink: (await IncidentService.getIncidentLinkInDashboard(incident.projectId, incident.id)).toString() }, (incident.incidentNumber !== undefined && {
1827
1913
  incidentNumber: incident.incidentNumber,
1828
1914
  })), (incident.incidentNumberWithPrefix && {
1829
1915
  incidentNumberWithPrefix: incident.incidentNumberWithPrefix,
@@ -1876,7 +1962,7 @@ export class Service extends DatabaseService {
1876
1962
  isRoot: true,
1877
1963
  },
1878
1964
  });
1879
- const pushMessage = PushNotificationUtil.createAlertEpisodeCreatedNotification(Object.assign(Object.assign(Object.assign({ alertEpisodeTitle: alertEpisode.title, projectName: ((_52 = alertEpisode.project) === null || _52 === void 0 ? void 0 : _52.name) || "OneUptime", alertEpisodeViewLink: (await AlertEpisodeService.getEpisodeLinkInDashboard(alertEpisode.projectId, alertEpisode.id)).toString() }, (alertEpisode.episodeNumber !== undefined && {
1965
+ const pushMessage = PushNotificationUtil.createAlertEpisodeCreatedNotification(Object.assign(Object.assign(Object.assign({ alertEpisodeTitle: alertEpisode.title, projectName: ((_58 = alertEpisode.project) === null || _58 === void 0 ? void 0 : _58.name) || "OneUptime", alertEpisodeViewLink: (await AlertEpisodeService.getEpisodeLinkInDashboard(alertEpisode.projectId, alertEpisode.id)).toString() }, (alertEpisode.episodeNumber !== undefined && {
1880
1966
  episodeNumber: alertEpisode.episodeNumber,
1881
1967
  })), (alertEpisode.episodeNumberWithPrefix && {
1882
1968
  episodeNumberWithPrefix: alertEpisode.episodeNumberWithPrefix,
@@ -1928,7 +2014,7 @@ export class Service extends DatabaseService {
1928
2014
  isRoot: true,
1929
2015
  },
1930
2016
  });
1931
- const pushMessage = PushNotificationUtil.createIncidentEpisodeCreatedNotification(Object.assign(Object.assign(Object.assign({ incidentEpisodeTitle: incidentEpisode.title, projectName: ((_53 = incidentEpisode.project) === null || _53 === void 0 ? void 0 : _53.name) || "OneUptime", incidentEpisodeViewLink: (await IncidentEpisodeService.getEpisodeLinkInDashboard(incidentEpisode.projectId, incidentEpisode.id)).toString() }, (incidentEpisode.episodeNumber !== undefined && {
2017
+ const pushMessage = PushNotificationUtil.createIncidentEpisodeCreatedNotification(Object.assign(Object.assign(Object.assign({ incidentEpisodeTitle: incidentEpisode.title, projectName: ((_59 = incidentEpisode.project) === null || _59 === void 0 ? void 0 : _59.name) || "OneUptime", incidentEpisodeViewLink: (await IncidentEpisodeService.getEpisodeLinkInDashboard(incidentEpisode.projectId, incidentEpisode.id)).toString() }, (incidentEpisode.episodeNumber !== undefined && {
1932
2018
  episodeNumber: incidentEpisode.episodeNumber,
1933
2019
  })), (incidentEpisode.episodeNumberWithPrefix && {
1934
2020
  episodeNumberWithPrefix: incidentEpisode.episodeNumberWithPrefix,
@@ -1966,8 +2052,8 @@ export class Service extends DatabaseService {
1966
2052
  });
1967
2053
  }
1968
2054
  }
1969
- if (((_54 = notificationRuleItem.userPush) === null || _54 === void 0 ? void 0 : _54.deviceToken) &&
1970
- !((_55 = notificationRuleItem.userPush) === null || _55 === void 0 ? void 0 : _55.isVerified)) {
2055
+ if (((_60 = notificationRuleItem.userPush) === null || _60 === void 0 ? void 0 : _60.deviceToken) &&
2056
+ !((_61 = notificationRuleItem.userPush) === null || _61 === void 0 ? void 0 : _61.isVerified)) {
1971
2057
  // create a log.
1972
2058
  logTimelineItem.status = UserNotificationStatus.Error;
1973
2059
  logTimelineItem.statusMessage = `Push notification not sent because device is not verified.`;
@@ -2006,6 +2092,130 @@ export class Service extends DatabaseService {
2006
2092
  }
2007
2093
  return deliveryAttempted;
2008
2094
  }
2095
+ /*
2096
+ * The Slack and Microsoft Teams halves of deliverNotificationForRule. Both
2097
+ * channels deliver the same way — the same generated message blocks handed
2098
+ * to the same direct-message sender, with only the workspace type and the
2099
+ * timeline method column differing — so one helper carries both instead of
2100
+ * two more copies of the per-event ladder above.
2101
+ *
2102
+ * Returns whether a delivery was attempted. `false` means this event type
2103
+ * has no workspace template, and the caller's fell-through guard turns that
2104
+ * into a loud Error row rather than a silent nothing.
2105
+ */
2106
+ async deliverWorkspaceDirectMessageForRule(data) {
2107
+ const channelDisplayName = getWorkspaceTypeDisplayName(data.workspaceType);
2108
+ const options = data.options;
2109
+ /*
2110
+ * Resolve the event into the entity being paged about, the block
2111
+ * generator for it, and the ids the send should be correlated with. The
2112
+ * generator is deferred because the message embeds the timeline row id,
2113
+ * which does not exist until the row below is created.
2114
+ */
2115
+ let entityProjectId = undefined;
2116
+ let incidentId = undefined;
2117
+ let alertId = undefined;
2118
+ let alertEpisodeId = undefined;
2119
+ let incidentEpisodeId = undefined;
2120
+ let generateBlocks = null;
2121
+ let messageSummary = "";
2122
+ if (options.userNotificationEventType ===
2123
+ UserNotificationEventType.IncidentCreated &&
2124
+ data.incident) {
2125
+ const incident = data.incident;
2126
+ entityProjectId = incident.projectId;
2127
+ incidentId = incident.id;
2128
+ messageSummary = `On-call notification: incident created.`;
2129
+ generateBlocks = (timelineId) => {
2130
+ return this.generateWorkspaceMessageBlocksForIncidentCreated(incident, timelineId);
2131
+ };
2132
+ }
2133
+ if (options.userNotificationEventType ===
2134
+ UserNotificationEventType.AlertCreated &&
2135
+ data.alert) {
2136
+ const alert = data.alert;
2137
+ entityProjectId = alert.projectId;
2138
+ alertId = alert.id;
2139
+ messageSummary = `On-call notification: alert created.`;
2140
+ generateBlocks = (timelineId) => {
2141
+ return this.generateWorkspaceMessageBlocksForAlertCreated(alert, timelineId);
2142
+ };
2143
+ }
2144
+ if (options.userNotificationEventType ===
2145
+ UserNotificationEventType.AlertEpisodeCreated &&
2146
+ data.alertEpisode) {
2147
+ const alertEpisode = data.alertEpisode;
2148
+ entityProjectId = alertEpisode.projectId;
2149
+ alertEpisodeId = alertEpisode.id;
2150
+ messageSummary = `On-call notification: alert episode created.`;
2151
+ generateBlocks = (timelineId) => {
2152
+ return this.generateWorkspaceMessageBlocksForAlertEpisodeCreated(alertEpisode, timelineId);
2153
+ };
2154
+ }
2155
+ if (options.userNotificationEventType ===
2156
+ UserNotificationEventType.IncidentEpisodeCreated &&
2157
+ data.incidentEpisode) {
2158
+ const incidentEpisode = data.incidentEpisode;
2159
+ entityProjectId = incidentEpisode.projectId;
2160
+ incidentEpisodeId = incidentEpisode.id;
2161
+ messageSummary = `On-call notification: incident episode created.`;
2162
+ generateBlocks = (timelineId) => {
2163
+ return this.generateWorkspaceMessageBlocksForIncidentEpisodeCreated(incidentEpisode, timelineId);
2164
+ };
2165
+ }
2166
+ if (!generateBlocks) {
2167
+ return false;
2168
+ }
2169
+ data.logTimelineItem.status = UserNotificationStatus.Sending;
2170
+ data.logTimelineItem.statusMessage = `Sending ${channelDisplayName} message.`;
2171
+ if (data.workspaceType === WorkspaceType.Slack) {
2172
+ data.logTimelineItem.userSlackId = data.methodId;
2173
+ }
2174
+ if (data.workspaceType === WorkspaceType.MicrosoftTeams) {
2175
+ data.logTimelineItem.userMicrosoftTeamsId = data.methodId;
2176
+ }
2177
+ const updatedLog = await UserOnCallLogTimelineService.create({
2178
+ data: data.logTimelineItem,
2179
+ props: {
2180
+ isRoot: true,
2181
+ },
2182
+ });
2183
+ const messageBlocks = await generateBlocks(updatedLog.id);
2184
+ /*
2185
+ * Fire-and-forget like every other channel: the sender flips the timeline
2186
+ * row to Sent / Error itself, and the .catch is the safety net for a
2187
+ * rejection raised before it gets that far.
2188
+ */
2189
+ WorkspaceUserNotificationService.sendDirectMessageToUser({
2190
+ projectId: entityProjectId || options.projectId,
2191
+ workspaceType: data.workspaceType,
2192
+ workspaceUserId: data.workspaceUserId,
2193
+ messageBlocks: messageBlocks,
2194
+ messageSummary: messageSummary,
2195
+ userId: data.notificationRuleItem.userId,
2196
+ userOnCallLogTimelineId: updatedLog.id,
2197
+ incidentId: incidentId,
2198
+ alertId: alertId,
2199
+ alertEpisodeId: alertEpisodeId,
2200
+ incidentEpisodeId: incidentEpisodeId,
2201
+ onCallPolicyId: options.onCallPolicyId,
2202
+ onCallPolicyEscalationRuleId: options.onCallPolicyEscalationRuleId,
2203
+ teamId: options.userBelongsToTeamId,
2204
+ onCallScheduleId: options.onCallScheduleId,
2205
+ }).catch(async (err) => {
2206
+ await UserOnCallLogTimelineService.updateOneById({
2207
+ id: updatedLog.id,
2208
+ data: {
2209
+ status: UserNotificationStatus.Error,
2210
+ statusMessage: err.message || `Error sending ${channelDisplayName} message.`,
2211
+ },
2212
+ props: {
2213
+ isRoot: true,
2214
+ },
2215
+ });
2216
+ });
2217
+ return true;
2218
+ }
2009
2219
  /*
2010
2220
  * The channels this rule could actually reach the user on, by display name.
2011
2221
  *
@@ -2016,7 +2226,7 @@ export class Service extends DatabaseService {
2016
2226
  * isVerified column), so presence of a URL is the whole gate there.
2017
2227
  */
2018
2228
  getContactableChannelNames(notificationRuleItem) {
2019
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
2229
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s;
2020
2230
  const channels = [];
2021
2231
  if (((_a = notificationRuleItem.userEmail) === null || _a === void 0 ? void 0 : _a.email) &&
2022
2232
  ((_b = notificationRuleItem.userEmail) === null || _b === void 0 ? void 0 : _b.isVerified)) {
@@ -2034,15 +2244,23 @@ export class Service extends DatabaseService {
2034
2244
  ((_h = notificationRuleItem.userTelegram) === null || _h === void 0 ? void 0 : _h.isVerified)) {
2035
2245
  channels.push("Telegram");
2036
2246
  }
2037
- if ((_j = notificationRuleItem.userWebhook) === null || _j === void 0 ? void 0 : _j.webhookUrl) {
2247
+ if (((_j = notificationRuleItem.userSlack) === null || _j === void 0 ? void 0 : _j.slackUserId) &&
2248
+ ((_k = notificationRuleItem.userSlack) === null || _k === void 0 ? void 0 : _k.isVerified)) {
2249
+ channels.push("Slack");
2250
+ }
2251
+ if (((_l = notificationRuleItem.userMicrosoftTeams) === null || _l === void 0 ? void 0 : _l.microsoftTeamsUserId) &&
2252
+ ((_m = notificationRuleItem.userMicrosoftTeams) === null || _m === void 0 ? void 0 : _m.isVerified)) {
2253
+ channels.push("Microsoft Teams");
2254
+ }
2255
+ if ((_o = notificationRuleItem.userWebhook) === null || _o === void 0 ? void 0 : _o.webhookUrl) {
2038
2256
  channels.push("Webhook");
2039
2257
  }
2040
- if (((_k = notificationRuleItem.userCall) === null || _k === void 0 ? void 0 : _k.phone) &&
2041
- ((_l = notificationRuleItem.userCall) === null || _l === void 0 ? void 0 : _l.isVerified)) {
2258
+ if (((_p = notificationRuleItem.userCall) === null || _p === void 0 ? void 0 : _p.phone) &&
2259
+ ((_q = notificationRuleItem.userCall) === null || _q === void 0 ? void 0 : _q.isVerified)) {
2042
2260
  channels.push("Call");
2043
2261
  }
2044
- if (((_m = notificationRuleItem.userPush) === null || _m === void 0 ? void 0 : _m.deviceToken) &&
2045
- ((_o = notificationRuleItem.userPush) === null || _o === void 0 ? void 0 : _o.isVerified)) {
2262
+ if (((_r = notificationRuleItem.userPush) === null || _r === void 0 ? void 0 : _r.deviceToken) &&
2263
+ ((_s = notificationRuleItem.userPush) === null || _s === void 0 ? void 0 : _s.isVerified)) {
2046
2264
  channels.push("Push");
2047
2265
  }
2048
2266
  return channels;
@@ -2162,10 +2380,11 @@ export class Service extends DatabaseService {
2162
2380
  /*
2163
2381
  * Pick what to page the user on, and build an unsaved rule for each choice.
2164
2382
  *
2165
- * Zero-cost channels win: push and email reach the most people for no money
2166
- * and no billing surprise, and there is no reason to pick between them, so a
2167
- * user who has both gets both. Only a user with neither is worth spending on,
2168
- * and then just once, in escalating-intrusiveness order.
2383
+ * Zero-cost channels win: push, email, Slack and Microsoft Teams reach the
2384
+ * most people for no money and no billing surprise, and there is no reason
2385
+ * to pick between them, so a user who has several gets all of them. Only a
2386
+ * user with none of these is worth spending on, and then just once, in
2387
+ * escalating-intrusiveness order.
2169
2388
  *
2170
2389
  * Paid channels are additionally gated on the project's own enable flags.
2171
2390
  * SmsService and CallService enforce those at send time, but WhatsApp and
@@ -2217,6 +2436,50 @@ export class Service extends DatabaseService {
2217
2436
  rule.userEmailId = userEmail.id;
2218
2437
  chosen.push({ channelName: "Email", rule: rule });
2219
2438
  }
2439
+ const userSlack = await UserSlackService.findOneBy({
2440
+ query: {
2441
+ projectId: options.projectId,
2442
+ userId: options.userId,
2443
+ isVerified: true,
2444
+ },
2445
+ select: {
2446
+ _id: true,
2447
+ slackUserId: true,
2448
+ slackUserName: true,
2449
+ isVerified: true,
2450
+ },
2451
+ props: {
2452
+ isRoot: true,
2453
+ },
2454
+ });
2455
+ if (userSlack) {
2456
+ const rule = this.buildUnsavedFallbackRule(options);
2457
+ rule.userSlack = userSlack;
2458
+ rule.userSlackId = userSlack.id;
2459
+ chosen.push({ channelName: "Slack", rule: rule });
2460
+ }
2461
+ const userMicrosoftTeams = await UserMicrosoftTeamsService.findOneBy({
2462
+ query: {
2463
+ projectId: options.projectId,
2464
+ userId: options.userId,
2465
+ isVerified: true,
2466
+ },
2467
+ select: {
2468
+ _id: true,
2469
+ microsoftTeamsUserId: true,
2470
+ microsoftTeamsUserName: true,
2471
+ isVerified: true,
2472
+ },
2473
+ props: {
2474
+ isRoot: true,
2475
+ },
2476
+ });
2477
+ if (userMicrosoftTeams) {
2478
+ const rule = this.buildUnsavedFallbackRule(options);
2479
+ rule.userMicrosoftTeams = userMicrosoftTeams;
2480
+ rule.userMicrosoftTeamsId = userMicrosoftTeams.id;
2481
+ chosen.push({ channelName: "Microsoft Teams", rule: rule });
2482
+ }
2220
2483
  if (chosen.length > 0) {
2221
2484
  return chosen;
2222
2485
  }
@@ -2691,6 +2954,107 @@ export class Service extends DatabaseService {
2691
2954
  lines.push("", `✅ <a href="${this.escapeTelegramHtml(ackUrl.toString())}">Tap to acknowledge</a>`);
2692
2955
  return lines.join("\n");
2693
2956
  }
2957
+ /*
2958
+ * ---------------------------------------------------------------------- *
2959
+ * Workspace (Slack / Microsoft Teams) direct-message generators.
2960
+ *
2961
+ * One generator family serves BOTH workspace channels: the blocks are
2962
+ * written in standard markdown, which SlackUtil slackifies and
2963
+ * MicrosoftTeamsUtil renders into an adaptive card. Keep them to the block
2964
+ * types both platforms implement (markdown / header / divider / buttons) —
2965
+ * anything else throws NotImplementedException on Teams.
2966
+ * ---------------------------------------------------------------------- *
2967
+ */
2968
+ buildWorkspaceMessageBlocks(data) {
2969
+ const lines = [
2970
+ `🚨 **${data.headline}**`,
2971
+ "",
2972
+ `📋 **${data.identifier}**`,
2973
+ "",
2974
+ "👤 You're getting this because you're on call.",
2975
+ ];
2976
+ if (data.dashboardUrl) {
2977
+ lines.push("", `🔎 [${data.dashboardLinkText}](${data.dashboardUrl.toString()})`);
2978
+ }
2979
+ lines.push("", `✅ [Acknowledge](${data.ackUrl.toString()})`);
2980
+ const markdownBlock = {
2981
+ _type: "WorkspacePayloadMarkdown",
2982
+ text: lines.join("\n"),
2983
+ };
2984
+ return [markdownBlock];
2985
+ }
2986
+ async generateWorkspaceMessageBlocksForAlertCreated(alert, userOnCallLogTimelineId) {
2987
+ const ackUrl = await this.buildOnCallAcknowledgeShortUrl(userOnCallLogTimelineId);
2988
+ const alertIdentifier = alert.alertNumber !== undefined
2989
+ ? `${alert.alertNumberWithPrefix || "#" + alert.alertNumber} — ${alert.title || "Alert"}`
2990
+ : alert.title || "Alert";
2991
+ let dashboardUrl = null;
2992
+ if (alert.projectId && alert.id) {
2993
+ dashboardUrl = await AlertService.getAlertLinkInDashboard(alert.projectId, alert.id);
2994
+ }
2995
+ return this.buildWorkspaceMessageBlocks({
2996
+ headline: "New alert assigned to you",
2997
+ identifier: alertIdentifier,
2998
+ dashboardUrl: dashboardUrl,
2999
+ dashboardLinkText: "View alert in OneUptime",
3000
+ ackUrl: ackUrl,
3001
+ });
3002
+ }
3003
+ async generateWorkspaceMessageBlocksForIncidentCreated(incident, userOnCallLogTimelineId) {
3004
+ const ackUrl = await this.buildOnCallAcknowledgeShortUrl(userOnCallLogTimelineId);
3005
+ const incidentIdentifier = incident.incidentNumber !== undefined
3006
+ ? `${incident.incidentNumberWithPrefix || "#" + incident.incidentNumber} — ${incident.title || "Incident"}`
3007
+ : incident.title || "Incident";
3008
+ let dashboardUrl = null;
3009
+ if (incident.projectId && incident.id) {
3010
+ dashboardUrl = await IncidentService.getIncidentLinkInDashboard(incident.projectId, incident.id);
3011
+ }
3012
+ return this.buildWorkspaceMessageBlocks({
3013
+ headline: "New incident assigned to you",
3014
+ identifier: incidentIdentifier,
3015
+ dashboardUrl: dashboardUrl,
3016
+ dashboardLinkText: "View incident in OneUptime",
3017
+ ackUrl: ackUrl,
3018
+ });
3019
+ }
3020
+ async generateWorkspaceMessageBlocksForAlertEpisodeCreated(alertEpisode, userOnCallLogTimelineId) {
3021
+ const ackUrl = await this.buildOnCallAcknowledgeShortUrl(userOnCallLogTimelineId);
3022
+ const episodeIdentifier = alertEpisode.episodeNumberWithPrefix
3023
+ ? `${alertEpisode.episodeNumberWithPrefix} — ${alertEpisode.title || "Alert Episode"}`
3024
+ : alertEpisode.episodeNumber !== undefined
3025
+ ? `#${alertEpisode.episodeNumber} — ${alertEpisode.title || "Alert Episode"}`
3026
+ : alertEpisode.title || "Alert Episode";
3027
+ let dashboardUrl = null;
3028
+ if (alertEpisode.projectId && alertEpisode.id) {
3029
+ dashboardUrl = await AlertEpisodeService.getEpisodeLinkInDashboard(alertEpisode.projectId, alertEpisode.id);
3030
+ }
3031
+ return this.buildWorkspaceMessageBlocks({
3032
+ headline: "New alert episode assigned to you",
3033
+ identifier: episodeIdentifier,
3034
+ dashboardUrl: dashboardUrl,
3035
+ dashboardLinkText: "View alert episode in OneUptime",
3036
+ ackUrl: ackUrl,
3037
+ });
3038
+ }
3039
+ async generateWorkspaceMessageBlocksForIncidentEpisodeCreated(incidentEpisode, userOnCallLogTimelineId) {
3040
+ const ackUrl = await this.buildOnCallAcknowledgeShortUrl(userOnCallLogTimelineId);
3041
+ const episodeIdentifier = incidentEpisode.episodeNumberWithPrefix
3042
+ ? `${incidentEpisode.episodeNumberWithPrefix} — ${incidentEpisode.title || "Incident Episode"}`
3043
+ : incidentEpisode.episodeNumber !== undefined
3044
+ ? `#${incidentEpisode.episodeNumber} — ${incidentEpisode.title || "Incident Episode"}`
3045
+ : incidentEpisode.title || "Incident Episode";
3046
+ let dashboardUrl = null;
3047
+ if (incidentEpisode.projectId && incidentEpisode.id) {
3048
+ dashboardUrl = await IncidentEpisodeService.getEpisodeLinkInDashboard(incidentEpisode.projectId, incidentEpisode.id);
3049
+ }
3050
+ return this.buildWorkspaceMessageBlocks({
3051
+ headline: "New incident episode assigned to you",
3052
+ identifier: episodeIdentifier,
3053
+ dashboardUrl: dashboardUrl,
3054
+ dashboardLinkText: "View incident episode in OneUptime",
3055
+ ackUrl: ackUrl,
3056
+ });
3057
+ }
2694
3058
  async generateWhatsAppTemplateForAlertCreated(to, alert, userOnCallLogTimelineId) {
2695
3059
  var _a;
2696
3060
  const host = await DatabaseConfig.getHost();
@@ -3300,7 +3664,7 @@ export class Service extends DatabaseService {
3300
3664
  throw new BadDataException("An opt-out notification rule cannot have a notification method. Remove the notification method, or turn off opt-out.");
3301
3665
  }
3302
3666
  if (!data.isOptOut && !data.hasNotificationMethod) {
3303
- throw new BadDataException("Call, SMS, WhatsApp, Telegram, Webhook, Email, or Push notification is required");
3667
+ throw new BadDataException("Call, SMS, WhatsApp, Telegram, Slack, Microsoft Teams, Webhook, Email, or Push notification is required");
3304
3668
  }
3305
3669
  }
3306
3670
  /**
@@ -3530,6 +3894,8 @@ export class Service extends DatabaseService {
3530
3894
  userCallId: true,
3531
3895
  userWhatsAppId: true,
3532
3896
  userTelegramId: true,
3897
+ userSlackId: true,
3898
+ userMicrosoftTeamsId: true,
3533
3899
  userPushId: true,
3534
3900
  userWebhookId: true,
3535
3901
  },
@@ -3733,6 +4099,8 @@ export class Service extends DatabaseService {
3733
4099
  userCallId: true,
3734
4100
  userWhatsAppId: true,
3735
4101
  userTelegramId: true,
4102
+ userSlackId: true,
4103
+ userMicrosoftTeamsId: true,
3736
4104
  userPushId: true,
3737
4105
  userWebhookId: true,
3738
4106
  },
@@ -3857,6 +4225,12 @@ export class Service extends DatabaseService {
3857
4225
  if (descriptor.userTelegramId) {
3858
4226
  rule.userTelegramId = descriptor.userTelegramId;
3859
4227
  }
4228
+ if (descriptor.userSlackId) {
4229
+ rule.userSlackId = descriptor.userSlackId;
4230
+ }
4231
+ if (descriptor.userMicrosoftTeamsId) {
4232
+ rule.userMicrosoftTeamsId = descriptor.userMicrosoftTeamsId;
4233
+ }
3860
4234
  if (descriptor.userWebhookId) {
3861
4235
  rule.userWebhookId = descriptor.userWebhookId;
3862
4236
  }
@@ -3881,6 +4255,12 @@ export class Service extends DatabaseService {
3881
4255
  if (descriptor.userTelegramId) {
3882
4256
  query["userTelegramId"] = descriptor.userTelegramId;
3883
4257
  }
4258
+ if (descriptor.userSlackId) {
4259
+ query["userSlackId"] = descriptor.userSlackId;
4260
+ }
4261
+ if (descriptor.userMicrosoftTeamsId) {
4262
+ query["userMicrosoftTeamsId"] = descriptor.userMicrosoftTeamsId;
4263
+ }
3884
4264
  if (descriptor.userWebhookId) {
3885
4265
  query["userWebhookId"] = descriptor.userWebhookId;
3886
4266
  }
@@ -4173,6 +4553,22 @@ export class Service extends DatabaseService {
4173
4553
  });
4174
4554
  isVerified = Boolean(row === null || row === void 0 ? void 0 : row.isVerified);
4175
4555
  }
4556
+ else if (data.methodType === ReadinessMethodType.Slack) {
4557
+ row = await UserSlackService.findOneBy({
4558
+ query: query,
4559
+ select: { _id: true, userId: true, isVerified: true },
4560
+ props: props,
4561
+ });
4562
+ isVerified = Boolean(row === null || row === void 0 ? void 0 : row.isVerified);
4563
+ }
4564
+ else if (data.methodType === ReadinessMethodType.MicrosoftTeams) {
4565
+ row = await UserMicrosoftTeamsService.findOneBy({
4566
+ query: query,
4567
+ select: { _id: true, userId: true, isVerified: true },
4568
+ props: props,
4569
+ });
4570
+ isVerified = Boolean(row === null || row === void 0 ? void 0 : row.isVerified);
4571
+ }
4176
4572
  else if (data.methodType === ReadinessMethodType.Webhook) {
4177
4573
  row = await UserWebhookService.findOneBy({
4178
4574
  query: query,
@@ -4219,6 +4615,12 @@ export class Service extends DatabaseService {
4219
4615
  if (methodType === ReadinessMethodType.Telegram) {
4220
4616
  return rule.userTelegramId;
4221
4617
  }
4618
+ if (methodType === ReadinessMethodType.Slack) {
4619
+ return rule.userSlackId;
4620
+ }
4621
+ if (methodType === ReadinessMethodType.MicrosoftTeams) {
4622
+ return rule.userMicrosoftTeamsId;
4623
+ }
4222
4624
  if (methodType === ReadinessMethodType.Webhook) {
4223
4625
  return rule.userWebhookId;
4224
4626
  }
@@ -4472,6 +4874,8 @@ export class Service extends DatabaseService {
4472
4874
  userPushId: true,
4473
4875
  userWhatsAppId: true,
4474
4876
  userTelegramId: true,
4877
+ userSlackId: true,
4878
+ userMicrosoftTeamsId: true,
4475
4879
  userWebhookId: true,
4476
4880
  },
4477
4881
  sort: {
@@ -4840,6 +5244,34 @@ __decorate([
4840
5244
  ObjectID]),
4841
5245
  __metadata("design:returntype", Promise)
4842
5246
  ], Service.prototype, "generateTelegramBodyForIncidentEpisodeCreated", null);
5247
+ __decorate([
5248
+ CaptureSpan(),
5249
+ __metadata("design:type", Function),
5250
+ __metadata("design:paramtypes", [Alert,
5251
+ ObjectID]),
5252
+ __metadata("design:returntype", Promise)
5253
+ ], Service.prototype, "generateWorkspaceMessageBlocksForAlertCreated", null);
5254
+ __decorate([
5255
+ CaptureSpan(),
5256
+ __metadata("design:type", Function),
5257
+ __metadata("design:paramtypes", [Incident,
5258
+ ObjectID]),
5259
+ __metadata("design:returntype", Promise)
5260
+ ], Service.prototype, "generateWorkspaceMessageBlocksForIncidentCreated", null);
5261
+ __decorate([
5262
+ CaptureSpan(),
5263
+ __metadata("design:type", Function),
5264
+ __metadata("design:paramtypes", [AlertEpisode,
5265
+ ObjectID]),
5266
+ __metadata("design:returntype", Promise)
5267
+ ], Service.prototype, "generateWorkspaceMessageBlocksForAlertEpisodeCreated", null);
5268
+ __decorate([
5269
+ CaptureSpan(),
5270
+ __metadata("design:type", Function),
5271
+ __metadata("design:paramtypes", [IncidentEpisode,
5272
+ ObjectID]),
5273
+ __metadata("design:returntype", Promise)
5274
+ ], Service.prototype, "generateWorkspaceMessageBlocksForIncidentEpisodeCreated", null);
4843
5275
  __decorate([
4844
5276
  CaptureSpan(),
4845
5277
  __metadata("design:type", Function),