@oneuptime/common 9.4.7 → 9.4.9
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/Alert.ts +76 -0
- package/Models/DatabaseModels/AlertEpisode.ts +1201 -0
- package/Models/DatabaseModels/AlertEpisodeFeed.ts +529 -0
- package/Models/DatabaseModels/AlertEpisodeInternalNote.ts +455 -0
- package/Models/DatabaseModels/AlertEpisodeMember.ts +586 -0
- package/Models/DatabaseModels/AlertEpisodeOwnerTeam.ts +421 -0
- package/Models/DatabaseModels/AlertEpisodeOwnerUser.ts +419 -0
- package/Models/DatabaseModels/AlertEpisodeStateTimeline.ts +523 -0
- package/Models/DatabaseModels/AlertFeed.ts +1 -0
- package/Models/DatabaseModels/AlertGroupingRule.ts +1432 -0
- package/Models/DatabaseModels/Index.ts +18 -0
- package/Models/DatabaseModels/OnCallDutyPolicyExecutionLog.ts +70 -0
- package/Models/DatabaseModels/OnCallDutyPolicyExecutionLogTimeline.ts +59 -0
- package/Models/DatabaseModels/StatusPageDomain.ts +2 -0
- package/Models/DatabaseModels/UserOnCallLog.ts +48 -0
- package/Models/DatabaseModels/UserOnCallLogTimeline.ts +49 -0
- package/Models/DatabaseModels/WorkspaceNotificationLog.ts +57 -0
- package/Server/API/SlackAPI.ts +21 -0
- package/Server/API/UserOnCallLogTimelineAPI.ts +65 -25
- package/Server/Infrastructure/Postgres/SchemaMigrations/1768938069147-MigrationName.ts +751 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/1769125561322-MigrationName.ts +41 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/1769170578688-MigrationName.ts +29 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/1769172358833-MigrationName.ts +177 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/1769176450526-MigrationName.ts +71 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/1769190495840-MigrationName.ts +35 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/1769199303656-MigrationName.ts +29 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/1769202898645-MigrationName.ts +29 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/1769428619414-MigrationName.ts +35 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/1769428821686-MigrationName.ts +47 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/1769469813786-MigrationName.ts +71 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/1769517677937-RenameNotificationRuleTypes.ts +67 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/Index.ts +24 -0
- package/Server/Services/AlertEpisodeFeedService.ts +94 -0
- package/Server/Services/AlertEpisodeInternalNoteService.ts +71 -0
- package/Server/Services/AlertEpisodeMemberService.ts +267 -0
- package/Server/Services/AlertEpisodeOwnerTeamService.ts +10 -0
- package/Server/Services/AlertEpisodeOwnerUserService.ts +10 -0
- package/Server/Services/AlertEpisodeService.ts +1096 -0
- package/Server/Services/AlertEpisodeStateTimelineService.ts +557 -0
- package/Server/Services/AlertGroupingEngineService.ts +1120 -0
- package/Server/Services/AlertGroupingRuleService.ts +14 -0
- package/Server/Services/AlertService.ts +12 -0
- package/Server/Services/CallService.ts +2 -0
- package/Server/Services/Index.ts +21 -0
- package/Server/Services/MailService.ts +5 -0
- package/Server/Services/OnCallDutyPolicyEscalationRuleService.ts +18 -1
- package/Server/Services/OnCallDutyPolicyExecutionLogService.ts +64 -2
- package/Server/Services/OnCallDutyPolicyExecutionLogTimelineService.ts +27 -1
- package/Server/Services/OnCallDutyPolicyService.ts +16 -1
- package/Server/Services/PushNotificationService.ts +1 -0
- package/Server/Services/SmsService.ts +2 -0
- package/Server/Services/UserNotificationRuleService.ts +641 -10
- package/Server/Services/UserNotificationSettingService.ts +23 -0
- package/Server/Services/UserOnCallLogService.ts +58 -14
- package/Server/Services/WhatsAppService.ts +5 -0
- package/Server/Services/WorkspaceNotificationRuleService.ts +26 -0
- package/Server/Utils/AnalyticsDatabase/Statement.ts +6 -2
- package/Server/Utils/PushNotificationUtil.ts +75 -16
- package/Server/Utils/WhatsAppTemplateUtil.ts +13 -0
- package/Server/Utils/Workspace/MicrosoftTeams/Actions/ActionTypes.ts +18 -0
- package/Server/Utils/Workspace/MicrosoftTeams/Actions/AlertEpisode.ts +689 -0
- package/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeams.ts +16 -0
- package/Server/Utils/Workspace/Slack/Actions/ActionTypes.ts +11 -0
- package/Server/Utils/Workspace/Slack/Actions/AlertEpisode.ts +915 -0
- package/Server/Utils/Workspace/Slack/Messages/AlertEpisode.ts +120 -0
- package/Server/Utils/Workspace/WorkspaceMessages/AlertEpisode.ts +74 -0
- package/Tests/Server/Services/AlertEpisodeMemberService.test.ts +200 -0
- package/Tests/Server/Services/AlertEpisodeService.test.ts +240 -0
- package/Tests/Server/Services/AlertGroupingEngineService.test.ts +542 -0
- package/Tests/Server/Services/AlertGroupingRuleService.test.ts +383 -0
- package/Tests/Server/Utils/AnalyticsDatabase/StatementGenerator.test.ts +1 -1
- package/Tests/UI/Components/Input.test.tsx +1 -1
- package/Tests/UI/Components/TextArea.test.tsx +2 -2
- package/Types/BaseDatabase/SortOrder.ts +9 -0
- package/Types/Email/EmailTemplateType.ts +6 -0
- package/Types/NotificationRule/NotificationRuleType.ts +3 -1
- package/Types/NotificationSetting/NotificationSettingEventType.ts +7 -0
- package/Types/Permission.ts +309 -0
- package/Types/UserNotification/UserNotificationEventType.ts +1 -0
- package/Types/WhatsApp/WhatsAppTemplates.ts +24 -0
- package/Types/Workspace/NotificationRules/EventType.ts +1 -0
- package/Types/Workspace/NotificationRules/NotificationRuleCondition.ts +32 -3
- package/UI/Components/Accordion/Accordion.tsx +20 -2
- package/UI/Components/Alerts/Alert.tsx +1 -0
- package/UI/Components/Button/Button.tsx +29 -0
- package/UI/Components/CardSelect/CardSelect.tsx +5 -1
- package/UI/Components/Checkbox/Checkbox.tsx +7 -3
- package/UI/Components/ColorCircle/ColorCircle.tsx +2 -0
- package/UI/Components/ColorViewer/ColorViewer.tsx +19 -3
- package/UI/Components/CopyableButton/CopyableButton.tsx +22 -5
- package/UI/Components/Detail/Detail.tsx +1 -1
- package/UI/Components/Dropdown/Dropdown.tsx +14 -1
- package/UI/Components/Forms/Fields/FormField.tsx +28 -0
- package/UI/Components/FullPageModal/FullPageModal.tsx +35 -4
- package/UI/Components/Input/Input.tsx +14 -2
- package/UI/Components/Link/Link.tsx +1 -0
- package/UI/Components/Loader/Loader.tsx +8 -2
- package/UI/Components/Markdown.tsx/MarkdownViewer.tsx +76 -1
- package/UI/Components/Modal/Modal.tsx +47 -3
- package/UI/Components/ModelTable/BaseModelTable.tsx +42 -1
- package/UI/Components/MoreMenu/MoreMenu.tsx +84 -2
- package/UI/Components/OrderedStatesList/OrderedStatesList.tsx +30 -8
- package/UI/Components/Pagination/Pagination.tsx +113 -8
- package/UI/Components/ProgressBar/ProgressBar.tsx +12 -2
- package/UI/Components/Radio/Radio.tsx +21 -3
- package/UI/Components/SideMenu/CountModelSideMenuItem.tsx +54 -27
- package/UI/Components/StatusBubble/StatusBubble.tsx +7 -2
- package/UI/Components/Table/TableHeader.tsx +20 -3
- package/UI/Components/Tabs/Tab.tsx +16 -1
- package/UI/Components/Tabs/Tabs.tsx +12 -1
- package/UI/Components/TextArea/TextArea.tsx +12 -2
- package/UI/Components/Toggle/Toggle.tsx +14 -3
- package/UI/Components/Tooltip/Tooltip.tsx +11 -1
- package/UI/Components/TopAlert/TopAlert.tsx +2 -0
- package/build/dist/Models/DatabaseModels/Alert.js +77 -0
- package/build/dist/Models/DatabaseModels/Alert.js.map +1 -1
- package/build/dist/Models/DatabaseModels/AlertEpisode.js +1225 -0
- package/build/dist/Models/DatabaseModels/AlertEpisode.js.map +1 -0
- package/build/dist/Models/DatabaseModels/AlertEpisodeFeed.js +553 -0
- package/build/dist/Models/DatabaseModels/AlertEpisodeFeed.js.map +1 -0
- package/build/dist/Models/DatabaseModels/AlertEpisodeInternalNote.js +467 -0
- package/build/dist/Models/DatabaseModels/AlertEpisodeInternalNote.js.map +1 -0
- package/build/dist/Models/DatabaseModels/AlertEpisodeMember.js +607 -0
- package/build/dist/Models/DatabaseModels/AlertEpisodeMember.js.map +1 -0
- package/build/dist/Models/DatabaseModels/AlertEpisodeOwnerTeam.js +437 -0
- package/build/dist/Models/DatabaseModels/AlertEpisodeOwnerTeam.js.map +1 -0
- package/build/dist/Models/DatabaseModels/AlertEpisodeOwnerUser.js +436 -0
- package/build/dist/Models/DatabaseModels/AlertEpisodeOwnerUser.js.map +1 -0
- package/build/dist/Models/DatabaseModels/AlertEpisodeStateTimeline.js +546 -0
- package/build/dist/Models/DatabaseModels/AlertEpisodeStateTimeline.js.map +1 -0
- package/build/dist/Models/DatabaseModels/AlertFeed.js +1 -0
- package/build/dist/Models/DatabaseModels/AlertFeed.js.map +1 -1
- package/build/dist/Models/DatabaseModels/AlertGroupingRule.js +1437 -0
- package/build/dist/Models/DatabaseModels/AlertGroupingRule.js.map +1 -0
- package/build/dist/Models/DatabaseModels/Index.js +16 -0
- package/build/dist/Models/DatabaseModels/Index.js.map +1 -1
- package/build/dist/Models/DatabaseModels/OnCallDutyPolicyExecutionLog.js +69 -0
- package/build/dist/Models/DatabaseModels/OnCallDutyPolicyExecutionLog.js.map +1 -1
- package/build/dist/Models/DatabaseModels/OnCallDutyPolicyExecutionLogTimeline.js +58 -0
- package/build/dist/Models/DatabaseModels/OnCallDutyPolicyExecutionLogTimeline.js.map +1 -1
- package/build/dist/Models/DatabaseModels/StatusPageDomain.js +2 -0
- package/build/dist/Models/DatabaseModels/StatusPageDomain.js.map +1 -1
- package/build/dist/Models/DatabaseModels/UserOnCallLog.js +47 -0
- package/build/dist/Models/DatabaseModels/UserOnCallLog.js.map +1 -1
- package/build/dist/Models/DatabaseModels/UserOnCallLogTimeline.js +48 -0
- package/build/dist/Models/DatabaseModels/UserOnCallLogTimeline.js.map +1 -1
- package/build/dist/Models/DatabaseModels/WorkspaceNotificationLog.js +58 -0
- package/build/dist/Models/DatabaseModels/WorkspaceNotificationLog.js.map +1 -1
- package/build/dist/Server/API/SlackAPI.js +18 -0
- package/build/dist/Server/API/SlackAPI.js.map +1 -1
- package/build/dist/Server/API/UserOnCallLogTimelineAPI.js +55 -15
- package/build/dist/Server/API/UserOnCallLogTimelineAPI.js.map +1 -1
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1768938069147-MigrationName.js +266 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1768938069147-MigrationName.js.map +1 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1769125561322-MigrationName.js +20 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1769125561322-MigrationName.js.map +1 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1769170578688-MigrationName.js +16 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1769170578688-MigrationName.js.map +1 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1769172358833-MigrationName.js +68 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1769172358833-MigrationName.js.map +1 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1769176450526-MigrationName.js +30 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1769176450526-MigrationName.js.map +1 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1769190495840-MigrationName.js +18 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1769190495840-MigrationName.js.map +1 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1769199303656-MigrationName.js +16 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1769199303656-MigrationName.js.map +1 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1769202898645-MigrationName.js +16 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1769202898645-MigrationName.js.map +1 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1769428619414-MigrationName.js +18 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1769428619414-MigrationName.js.map +1 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1769428821686-MigrationName.js +22 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1769428821686-MigrationName.js.map +1 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1769469813786-MigrationName.js +30 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1769469813786-MigrationName.js.map +1 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1769517677937-RenameNotificationRuleTypes.js +67 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1769517677937-RenameNotificationRuleTypes.js.map +1 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/Index.js +24 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/Index.js.map +1 -1
- package/build/dist/Server/Services/AlertEpisodeFeedService.js +83 -0
- package/build/dist/Server/Services/AlertEpisodeFeedService.js.map +1 -0
- package/build/dist/Server/Services/AlertEpisodeInternalNoteService.js +70 -0
- package/build/dist/Server/Services/AlertEpisodeInternalNoteService.js.map +1 -0
- package/build/dist/Server/Services/AlertEpisodeMemberService.js +256 -0
- package/build/dist/Server/Services/AlertEpisodeMemberService.js.map +1 -0
- package/build/dist/Server/Services/AlertEpisodeOwnerTeamService.js +9 -0
- package/build/dist/Server/Services/AlertEpisodeOwnerTeamService.js.map +1 -0
- package/build/dist/Server/Services/AlertEpisodeOwnerUserService.js +9 -0
- package/build/dist/Server/Services/AlertEpisodeOwnerUserService.js.map +1 -0
- package/build/dist/Server/Services/AlertEpisodeService.js +973 -0
- package/build/dist/Server/Services/AlertEpisodeService.js.map +1 -0
- package/build/dist/Server/Services/AlertEpisodeStateTimelineService.js +494 -0
- package/build/dist/Server/Services/AlertEpisodeStateTimelineService.js.map +1 -0
- package/build/dist/Server/Services/AlertGroupingEngineService.js +893 -0
- package/build/dist/Server/Services/AlertGroupingEngineService.js.map +1 -0
- package/build/dist/Server/Services/AlertGroupingRuleService.js +13 -0
- package/build/dist/Server/Services/AlertGroupingRuleService.js.map +1 -0
- package/build/dist/Server/Services/AlertService.js +11 -0
- package/build/dist/Server/Services/AlertService.js.map +1 -1
- package/build/dist/Server/Services/CallService.js +11 -10
- package/build/dist/Server/Services/CallService.js.map +1 -1
- package/build/dist/Server/Services/Index.js +18 -0
- package/build/dist/Server/Services/Index.js.map +1 -1
- package/build/dist/Server/Services/MailService.js +3 -0
- package/build/dist/Server/Services/MailService.js.map +1 -1
- package/build/dist/Server/Services/OnCallDutyPolicyEscalationRuleService.js +10 -1
- package/build/dist/Server/Services/OnCallDutyPolicyEscalationRuleService.js.map +1 -1
- package/build/dist/Server/Services/OnCallDutyPolicyExecutionLogService.js +49 -2
- package/build/dist/Server/Services/OnCallDutyPolicyExecutionLogService.js.map +1 -1
- package/build/dist/Server/Services/OnCallDutyPolicyExecutionLogTimelineService.js +21 -1
- package/build/dist/Server/Services/OnCallDutyPolicyExecutionLogTimelineService.js.map +1 -1
- package/build/dist/Server/Services/OnCallDutyPolicyService.js +9 -1
- package/build/dist/Server/Services/OnCallDutyPolicyService.js.map +1 -1
- package/build/dist/Server/Services/PushNotificationService.js.map +1 -1
- package/build/dist/Server/Services/SmsService.js +11 -10
- package/build/dist/Server/Services/SmsService.js.map +1 -1
- package/build/dist/Server/Services/UserNotificationRuleService.js +521 -43
- package/build/dist/Server/Services/UserNotificationRuleService.js.map +1 -1
- package/build/dist/Server/Services/UserNotificationSettingService.js +9 -0
- package/build/dist/Server/Services/UserNotificationSettingService.js.map +1 -1
- package/build/dist/Server/Services/UserOnCallLogService.js +48 -12
- package/build/dist/Server/Services/UserOnCallLogService.js.map +1 -1
- package/build/dist/Server/Services/WhatsAppService.js +3 -0
- package/build/dist/Server/Services/WhatsAppService.js.map +1 -1
- package/build/dist/Server/Services/WorkspaceNotificationRuleService.js +25 -0
- package/build/dist/Server/Services/WorkspaceNotificationRuleService.js.map +1 -1
- package/build/dist/Server/Utils/AnalyticsDatabase/Statement.js +4 -2
- package/build/dist/Server/Utils/AnalyticsDatabase/Statement.js.map +1 -1
- package/build/dist/Server/Utils/PushNotificationUtil.js +51 -16
- package/build/dist/Server/Utils/PushNotificationUtil.js.map +1 -1
- package/build/dist/Server/Utils/WhatsAppTemplateUtil.js +8 -0
- package/build/dist/Server/Utils/WhatsAppTemplateUtil.js.map +1 -1
- package/build/dist/Server/Utils/Workspace/MicrosoftTeams/Actions/ActionTypes.js +17 -0
- package/build/dist/Server/Utils/Workspace/MicrosoftTeams/Actions/ActionTypes.js.map +1 -1
- package/build/dist/Server/Utils/Workspace/MicrosoftTeams/Actions/AlertEpisode.js +545 -0
- package/build/dist/Server/Utils/Workspace/MicrosoftTeams/Actions/AlertEpisode.js.map +1 -0
- package/build/dist/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeams.js +13 -0
- package/build/dist/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeams.js.map +1 -1
- package/build/dist/Server/Utils/Workspace/Slack/Actions/ActionTypes.js +10 -0
- package/build/dist/Server/Utils/Workspace/Slack/Actions/ActionTypes.js.map +1 -1
- package/build/dist/Server/Utils/Workspace/Slack/Actions/AlertEpisode.js +651 -0
- package/build/dist/Server/Utils/Workspace/Slack/Actions/AlertEpisode.js.map +1 -0
- package/build/dist/Server/Utils/Workspace/Slack/Messages/AlertEpisode.js +100 -0
- package/build/dist/Server/Utils/Workspace/Slack/Messages/AlertEpisode.js.map +1 -0
- package/build/dist/Server/Utils/Workspace/WorkspaceMessages/AlertEpisode.js +70 -0
- package/build/dist/Server/Utils/Workspace/WorkspaceMessages/AlertEpisode.js.map +1 -0
- package/build/dist/Tests/Server/Services/AlertEpisodeMemberService.test.js +165 -0
- package/build/dist/Tests/Server/Services/AlertEpisodeMemberService.test.js.map +1 -0
- package/build/dist/Tests/Server/Services/AlertEpisodeService.test.js +193 -0
- package/build/dist/Tests/Server/Services/AlertEpisodeService.test.js.map +1 -0
- package/build/dist/Tests/Server/Services/AlertGroupingEngineService.test.js +412 -0
- package/build/dist/Tests/Server/Services/AlertGroupingEngineService.test.js.map +1 -0
- package/build/dist/Tests/Server/Services/AlertGroupingRuleService.test.js +308 -0
- package/build/dist/Tests/Server/Services/AlertGroupingRuleService.test.js.map +1 -0
- package/build/dist/Tests/Server/Utils/AnalyticsDatabase/StatementGenerator.test.js +1 -1
- package/build/dist/Tests/Server/Utils/AnalyticsDatabase/StatementGenerator.test.js.map +1 -1
- package/build/dist/Tests/UI/Components/Input.test.js +1 -1
- package/build/dist/Tests/UI/Components/Input.test.js.map +1 -1
- package/build/dist/Tests/UI/Components/TextArea.test.js +2 -2
- package/build/dist/Tests/UI/Components/TextArea.test.js.map +1 -1
- package/build/dist/Types/BaseDatabase/SortOrder.js +5 -0
- package/build/dist/Types/BaseDatabase/SortOrder.js.map +1 -1
- package/build/dist/Types/Email/EmailTemplateType.js +5 -0
- package/build/dist/Types/Email/EmailTemplateType.js.map +1 -1
- package/build/dist/Types/NotificationRule/NotificationRuleType.js +3 -1
- package/build/dist/Types/NotificationRule/NotificationRuleType.js.map +1 -1
- package/build/dist/Types/NotificationSetting/NotificationSettingEventType.js +5 -0
- package/build/dist/Types/NotificationSetting/NotificationSettingEventType.js.map +1 -1
- package/build/dist/Types/Permission.js +264 -0
- package/build/dist/Types/Permission.js.map +1 -1
- package/build/dist/Types/UserNotification/UserNotificationEventType.js +1 -0
- package/build/dist/Types/UserNotification/UserNotificationEventType.js.map +1 -1
- package/build/dist/Types/WhatsApp/WhatsAppTemplates.js +15 -0
- package/build/dist/Types/WhatsApp/WhatsAppTemplates.js.map +1 -1
- package/build/dist/Types/Workspace/NotificationRules/EventType.js +1 -0
- package/build/dist/Types/Workspace/NotificationRules/EventType.js.map +1 -1
- package/build/dist/Types/Workspace/NotificationRules/NotificationRuleCondition.js +28 -3
- package/build/dist/Types/Workspace/NotificationRules/NotificationRuleCondition.js.map +1 -1
- package/build/dist/UI/Components/Accordion/Accordion.js +10 -3
- package/build/dist/UI/Components/Accordion/Accordion.js.map +1 -1
- package/build/dist/UI/Components/Alerts/Alert.js +1 -1
- package/build/dist/UI/Components/Alerts/Alert.js.map +1 -1
- package/build/dist/UI/Components/Button/Button.js +8 -2
- package/build/dist/UI/Components/Button/Button.js.map +1 -1
- package/build/dist/UI/Components/CardSelect/CardSelect.js +1 -1
- package/build/dist/UI/Components/CardSelect/CardSelect.js.map +1 -1
- package/build/dist/UI/Components/Checkbox/Checkbox.js +2 -2
- package/build/dist/UI/Components/Checkbox/Checkbox.js.map +1 -1
- package/build/dist/UI/Components/ColorCircle/ColorCircle.js +1 -1
- package/build/dist/UI/Components/ColorCircle/ColorCircle.js.map +1 -1
- package/build/dist/UI/Components/ColorViewer/ColorViewer.js +12 -3
- package/build/dist/UI/Components/ColorViewer/ColorViewer.js.map +1 -1
- package/build/dist/UI/Components/CopyableButton/CopyableButton.js +12 -5
- package/build/dist/UI/Components/CopyableButton/CopyableButton.js.map +1 -1
- package/build/dist/UI/Components/Detail/Detail.js +1 -1
- package/build/dist/UI/Components/Detail/Detail.js.map +1 -1
- package/build/dist/UI/Components/Dropdown/Dropdown.js +5 -3
- package/build/dist/UI/Components/Dropdown/Dropdown.js.map +1 -1
- package/build/dist/UI/Components/Forms/Fields/FormField.js +19 -1
- package/build/dist/UI/Components/Forms/Fields/FormField.js.map +1 -1
- package/build/dist/UI/Components/FullPageModal/FullPageModal.js +24 -5
- package/build/dist/UI/Components/FullPageModal/FullPageModal.js.map +1 -1
- package/build/dist/UI/Components/Input/Input.js +3 -3
- package/build/dist/UI/Components/Input/Input.js.map +1 -1
- package/build/dist/UI/Components/Link/Link.js +1 -1
- package/build/dist/UI/Components/Link/Link.js.map +1 -1
- package/build/dist/UI/Components/Loader/Loader.js +6 -4
- package/build/dist/UI/Components/Loader/Loader.js.map +1 -1
- package/build/dist/UI/Components/Markdown.tsx/MarkdownViewer.js +56 -3
- package/build/dist/UI/Components/Markdown.tsx/MarkdownViewer.js.map +1 -1
- package/build/dist/UI/Components/Modal/Modal.js +28 -3
- package/build/dist/UI/Components/Modal/Modal.js.map +1 -1
- package/build/dist/UI/Components/ModelTable/BaseModelTable.js +23 -1
- package/build/dist/UI/Components/ModelTable/BaseModelTable.js.map +1 -1
- package/build/dist/UI/Components/MoreMenu/MoreMenu.js +67 -6
- package/build/dist/UI/Components/MoreMenu/MoreMenu.js.map +1 -1
- package/build/dist/UI/Components/OrderedStatesList/OrderedStatesList.js +14 -3
- package/build/dist/UI/Components/OrderedStatesList/OrderedStatesList.js.map +1 -1
- package/build/dist/UI/Components/Pagination/Pagination.js +69 -13
- package/build/dist/UI/Components/Pagination/Pagination.js.map +1 -1
- package/build/dist/UI/Components/ProgressBar/ProgressBar.js +2 -2
- package/build/dist/UI/Components/ProgressBar/ProgressBar.js.map +1 -1
- package/build/dist/UI/Components/Radio/Radio.js +8 -5
- package/build/dist/UI/Components/Radio/Radio.js.map +1 -1
- package/build/dist/UI/Components/SideMenu/CountModelSideMenuItem.js +23 -4
- package/build/dist/UI/Components/SideMenu/CountModelSideMenuItem.js.map +1 -1
- package/build/dist/UI/Components/StatusBubble/StatusBubble.js +2 -2
- package/build/dist/UI/Components/StatusBubble/StatusBubble.js.map +1 -1
- package/build/dist/UI/Components/Table/TableHeader.js +12 -4
- package/build/dist/UI/Components/Table/TableHeader.js.map +1 -1
- package/build/dist/UI/Components/Tabs/Tab.js +8 -1
- package/build/dist/UI/Components/Tabs/Tab.js.map +1 -1
- package/build/dist/UI/Components/Tabs/Tabs.js +4 -3
- package/build/dist/UI/Components/Tabs/Tabs.js.map +1 -1
- package/build/dist/UI/Components/TextArea/TextArea.js +3 -3
- package/build/dist/UI/Components/TextArea/TextArea.js.map +1 -1
- package/build/dist/UI/Components/Toggle/Toggle.js +7 -4
- package/build/dist/UI/Components/Toggle/Toggle.js.map +1 -1
- package/build/dist/UI/Components/Tooltip/Tooltip.js +4 -1
- package/build/dist/UI/Components/Tooltip/Tooltip.js.map +1 -1
- package/build/dist/UI/Components/TopAlert/TopAlert.js +1 -1
- package/build/dist/UI/Components/TopAlert/TopAlert.js.map +1 -1
- package/package.json +2 -1
|
@@ -43,6 +43,9 @@ import UserOnCallLogTimeline from "../../Models/DatabaseModels/UserOnCallLogTime
|
|
|
43
43
|
import Alert from "../../Models/DatabaseModels/Alert";
|
|
44
44
|
import AlertService from "./AlertService";
|
|
45
45
|
import AlertSeverityService from "./AlertSeverityService";
|
|
46
|
+
import AlertEpisode from "../../Models/DatabaseModels/AlertEpisode";
|
|
47
|
+
import AlertEpisodeService from "./AlertEpisodeService";
|
|
48
|
+
import AlertEpisodeMemberService from "./AlertEpisodeMemberService";
|
|
46
49
|
import WorkspaceNotificationRuleService from "./WorkspaceNotificationRuleService";
|
|
47
50
|
import PushNotificationService from "./PushNotificationService";
|
|
48
51
|
import NotificationRuleEventType from "../../Types/Workspace/NotificationRules/EventType";
|
|
@@ -55,7 +58,7 @@ export class Service extends DatabaseService {
|
|
|
55
58
|
}
|
|
56
59
|
async executeNotificationRuleItem(userNotificationRuleId, options) {
|
|
57
60
|
// get user notification log and see if this rule has already been executed. If so then skip.
|
|
58
|
-
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;
|
|
61
|
+
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;
|
|
59
62
|
const userOnCallLog = await UserOnCallLogService.findOneById({
|
|
60
63
|
id: options.userNotificationLogId,
|
|
61
64
|
props: {
|
|
@@ -150,6 +153,10 @@ export class Service extends DatabaseService {
|
|
|
150
153
|
if (options.triggeredByAlertId) {
|
|
151
154
|
logTimelineItem.triggeredByAlertId = options.triggeredByAlertId;
|
|
152
155
|
}
|
|
156
|
+
if (options.triggeredByAlertEpisodeId) {
|
|
157
|
+
logTimelineItem.triggeredByAlertEpisodeId =
|
|
158
|
+
options.triggeredByAlertEpisodeId;
|
|
159
|
+
}
|
|
153
160
|
if (options.onCallDutyPolicyExecutionLogTimelineId) {
|
|
154
161
|
logTimelineItem.onCallDutyPolicyExecutionLogTimelineId =
|
|
155
162
|
options.onCallDutyPolicyExecutionLogTimelineId;
|
|
@@ -157,6 +164,7 @@ export class Service extends DatabaseService {
|
|
|
157
164
|
// add status and status message and save.
|
|
158
165
|
let incident = null;
|
|
159
166
|
let alert = null;
|
|
167
|
+
let alertEpisode = null;
|
|
160
168
|
if (options.userNotificationEventType ===
|
|
161
169
|
UserNotificationEventType.IncidentCreated &&
|
|
162
170
|
options.triggeredByIncidentId) {
|
|
@@ -210,8 +218,35 @@ export class Service extends DatabaseService {
|
|
|
210
218
|
},
|
|
211
219
|
});
|
|
212
220
|
}
|
|
213
|
-
if (
|
|
214
|
-
|
|
221
|
+
if (options.userNotificationEventType ===
|
|
222
|
+
UserNotificationEventType.AlertEpisodeCreated &&
|
|
223
|
+
options.triggeredByAlertEpisodeId) {
|
|
224
|
+
alertEpisode = await AlertEpisodeService.findOneById({
|
|
225
|
+
id: options.triggeredByAlertEpisodeId,
|
|
226
|
+
props: {
|
|
227
|
+
isRoot: true,
|
|
228
|
+
},
|
|
229
|
+
select: {
|
|
230
|
+
_id: true,
|
|
231
|
+
title: true,
|
|
232
|
+
description: true,
|
|
233
|
+
projectId: true,
|
|
234
|
+
project: {
|
|
235
|
+
name: true,
|
|
236
|
+
},
|
|
237
|
+
currentAlertState: {
|
|
238
|
+
name: true,
|
|
239
|
+
},
|
|
240
|
+
alertSeverity: {
|
|
241
|
+
name: true,
|
|
242
|
+
},
|
|
243
|
+
episodeNumber: true,
|
|
244
|
+
rootCause: true,
|
|
245
|
+
},
|
|
246
|
+
});
|
|
247
|
+
}
|
|
248
|
+
if (!incident && !alert && !alertEpisode) {
|
|
249
|
+
throw new BadDataException("Incident, Alert, or Alert Episode not found.");
|
|
215
250
|
}
|
|
216
251
|
if (((_a = notificationRuleItem.userEmail) === null || _a === void 0 ? void 0 : _a.email) &&
|
|
217
252
|
((_b = notificationRuleItem.userEmail) === null || _b === void 0 ? void 0 : _b.isVerified)) {
|
|
@@ -293,13 +328,50 @@ export class Service extends DatabaseService {
|
|
|
293
328
|
});
|
|
294
329
|
});
|
|
295
330
|
}
|
|
331
|
+
// send email for alert episode
|
|
332
|
+
if (options.userNotificationEventType ===
|
|
333
|
+
UserNotificationEventType.AlertEpisodeCreated &&
|
|
334
|
+
alertEpisode) {
|
|
335
|
+
logTimelineItem.status = UserNotificationStatus.Sending;
|
|
336
|
+
logTimelineItem.statusMessage = `Sending email to ${(_g = notificationRuleItem.userEmail) === null || _g === void 0 ? void 0 : _g.email.toString()}`;
|
|
337
|
+
logTimelineItem.userEmailId = notificationRuleItem.userEmail.id;
|
|
338
|
+
const updatedLog = await UserOnCallLogTimelineService.create({
|
|
339
|
+
data: logTimelineItem,
|
|
340
|
+
props: {
|
|
341
|
+
isRoot: true,
|
|
342
|
+
},
|
|
343
|
+
});
|
|
344
|
+
const emailMessage = await this.generateEmailTemplateForAlertEpisodeCreated((_h = notificationRuleItem.userEmail) === null || _h === void 0 ? void 0 : _h.email, alertEpisode, updatedLog.id);
|
|
345
|
+
MailService.sendMail(emailMessage, {
|
|
346
|
+
userOnCallLogTimelineId: updatedLog.id,
|
|
347
|
+
projectId: options.projectId,
|
|
348
|
+
alertEpisodeId: alertEpisode.id,
|
|
349
|
+
userId: notificationRuleItem.userId,
|
|
350
|
+
onCallPolicyId: options.onCallPolicyId,
|
|
351
|
+
onCallPolicyEscalationRuleId: options.onCallPolicyEscalationRuleId,
|
|
352
|
+
teamId: options.userBelongsToTeamId,
|
|
353
|
+
onCallDutyPolicyExecutionLogTimelineId: options.onCallDutyPolicyExecutionLogTimelineId,
|
|
354
|
+
onCallScheduleId: options.onCallScheduleId,
|
|
355
|
+
}).catch(async (err) => {
|
|
356
|
+
await UserOnCallLogTimelineService.updateOneById({
|
|
357
|
+
id: updatedLog.id,
|
|
358
|
+
data: {
|
|
359
|
+
status: UserNotificationStatus.Error,
|
|
360
|
+
statusMessage: err.message || "Error sending email.",
|
|
361
|
+
},
|
|
362
|
+
props: {
|
|
363
|
+
isRoot: true,
|
|
364
|
+
},
|
|
365
|
+
});
|
|
366
|
+
});
|
|
367
|
+
}
|
|
296
368
|
}
|
|
297
369
|
// if you have an email but is not verified, then create a log.
|
|
298
|
-
if (((
|
|
299
|
-
!((
|
|
370
|
+
if (((_j = notificationRuleItem.userEmail) === null || _j === void 0 ? void 0 : _j.email) &&
|
|
371
|
+
!((_k = notificationRuleItem.userEmail) === null || _k === void 0 ? void 0 : _k.isVerified)) {
|
|
300
372
|
// create an error log.
|
|
301
373
|
logTimelineItem.status = UserNotificationStatus.Error;
|
|
302
|
-
logTimelineItem.statusMessage = `Email notification not sent because email ${(
|
|
374
|
+
logTimelineItem.statusMessage = `Email notification not sent because email ${(_l = notificationRuleItem.userEmail) === null || _l === void 0 ? void 0 : _l.email.toString()} is not verified.`;
|
|
303
375
|
await UserOnCallLogTimelineService.create({
|
|
304
376
|
data: logTimelineItem,
|
|
305
377
|
props: {
|
|
@@ -308,15 +380,15 @@ export class Service extends DatabaseService {
|
|
|
308
380
|
});
|
|
309
381
|
}
|
|
310
382
|
// send sms.
|
|
311
|
-
if (((
|
|
312
|
-
((
|
|
383
|
+
if (((_m = notificationRuleItem.userSms) === null || _m === void 0 ? void 0 : _m.phone) &&
|
|
384
|
+
((_o = notificationRuleItem.userSms) === null || _o === void 0 ? void 0 : _o.isVerified)) {
|
|
313
385
|
//send sms for alert
|
|
314
386
|
if (options.userNotificationEventType ===
|
|
315
387
|
UserNotificationEventType.AlertCreated &&
|
|
316
388
|
alert) {
|
|
317
389
|
// create an error log.
|
|
318
390
|
logTimelineItem.status = UserNotificationStatus.Sending;
|
|
319
|
-
logTimelineItem.statusMessage = `Sending SMS to ${(
|
|
391
|
+
logTimelineItem.statusMessage = `Sending SMS to ${(_p = notificationRuleItem.userSms) === null || _p === void 0 ? void 0 : _p.phone.toString()}.`;
|
|
320
392
|
logTimelineItem.userSmsId = notificationRuleItem.userSms.id;
|
|
321
393
|
const updatedLog = await UserOnCallLogTimelineService.create({
|
|
322
394
|
data: logTimelineItem,
|
|
@@ -355,7 +427,7 @@ export class Service extends DatabaseService {
|
|
|
355
427
|
incident) {
|
|
356
428
|
// create an error log.
|
|
357
429
|
logTimelineItem.status = UserNotificationStatus.Sending;
|
|
358
|
-
logTimelineItem.statusMessage = `Sending SMS to ${(
|
|
430
|
+
logTimelineItem.statusMessage = `Sending SMS to ${(_q = notificationRuleItem.userSms) === null || _q === void 0 ? void 0 : _q.phone.toString()}.`;
|
|
359
431
|
logTimelineItem.userSmsId = notificationRuleItem.userSms.id;
|
|
360
432
|
const updatedLog = await UserOnCallLogTimelineService.create({
|
|
361
433
|
data: logTimelineItem,
|
|
@@ -388,12 +460,49 @@ export class Service extends DatabaseService {
|
|
|
388
460
|
});
|
|
389
461
|
});
|
|
390
462
|
}
|
|
463
|
+
// send sms for alert episode
|
|
464
|
+
if (options.userNotificationEventType ===
|
|
465
|
+
UserNotificationEventType.AlertEpisodeCreated &&
|
|
466
|
+
alertEpisode) {
|
|
467
|
+
logTimelineItem.status = UserNotificationStatus.Sending;
|
|
468
|
+
logTimelineItem.statusMessage = `Sending SMS to ${(_r = notificationRuleItem.userSms) === null || _r === void 0 ? void 0 : _r.phone.toString()}.`;
|
|
469
|
+
logTimelineItem.userSmsId = notificationRuleItem.userSms.id;
|
|
470
|
+
const updatedLog = await UserOnCallLogTimelineService.create({
|
|
471
|
+
data: logTimelineItem,
|
|
472
|
+
props: {
|
|
473
|
+
isRoot: true,
|
|
474
|
+
},
|
|
475
|
+
});
|
|
476
|
+
const smsMessage = await this.generateSmsTemplateForAlertEpisodeCreated(notificationRuleItem.userSms.phone, alertEpisode, updatedLog.id);
|
|
477
|
+
SmsService.sendSms(smsMessage, {
|
|
478
|
+
projectId: alertEpisode.projectId,
|
|
479
|
+
userOnCallLogTimelineId: updatedLog.id,
|
|
480
|
+
alertEpisodeId: alertEpisode.id,
|
|
481
|
+
userId: notificationRuleItem.userId,
|
|
482
|
+
onCallPolicyId: options.onCallPolicyId,
|
|
483
|
+
onCallPolicyEscalationRuleId: options.onCallPolicyEscalationRuleId,
|
|
484
|
+
teamId: options.userBelongsToTeamId,
|
|
485
|
+
onCallDutyPolicyExecutionLogTimelineId: options.onCallDutyPolicyExecutionLogTimelineId,
|
|
486
|
+
onCallScheduleId: options.onCallScheduleId,
|
|
487
|
+
}).catch(async (err) => {
|
|
488
|
+
await UserOnCallLogTimelineService.updateOneById({
|
|
489
|
+
id: updatedLog.id,
|
|
490
|
+
data: {
|
|
491
|
+
status: UserNotificationStatus.Error,
|
|
492
|
+
statusMessage: err.message || "Error sending SMS.",
|
|
493
|
+
},
|
|
494
|
+
props: {
|
|
495
|
+
isRoot: true,
|
|
496
|
+
},
|
|
497
|
+
});
|
|
498
|
+
});
|
|
499
|
+
}
|
|
391
500
|
}
|
|
392
|
-
if (((
|
|
393
|
-
!((
|
|
501
|
+
if (((_s = notificationRuleItem.userSms) === null || _s === void 0 ? void 0 : _s.phone) &&
|
|
502
|
+
!((_t = notificationRuleItem.userSms) === null || _t === void 0 ? void 0 : _t.isVerified)) {
|
|
394
503
|
// create a log.
|
|
395
504
|
logTimelineItem.status = UserNotificationStatus.Error;
|
|
396
|
-
logTimelineItem.statusMessage = `SMS not sent because phone ${(
|
|
505
|
+
logTimelineItem.statusMessage = `SMS not sent because phone ${(_u = notificationRuleItem.userSms) === null || _u === void 0 ? void 0 : _u.phone.toString()} is not verified.`;
|
|
397
506
|
await UserOnCallLogTimelineService.create({
|
|
398
507
|
data: logTimelineItem,
|
|
399
508
|
props: {
|
|
@@ -401,13 +510,13 @@ export class Service extends DatabaseService {
|
|
|
401
510
|
},
|
|
402
511
|
});
|
|
403
512
|
}
|
|
404
|
-
if (((
|
|
405
|
-
((
|
|
513
|
+
if (((_v = notificationRuleItem.userWhatsApp) === null || _v === void 0 ? void 0 : _v.phone) &&
|
|
514
|
+
((_w = notificationRuleItem.userWhatsApp) === null || _w === void 0 ? void 0 : _w.isVerified)) {
|
|
406
515
|
if (options.userNotificationEventType ===
|
|
407
516
|
UserNotificationEventType.AlertCreated &&
|
|
408
517
|
alert) {
|
|
409
518
|
logTimelineItem.status = UserNotificationStatus.Sending;
|
|
410
|
-
logTimelineItem.statusMessage = `Sending WhatsApp message to ${(
|
|
519
|
+
logTimelineItem.statusMessage = `Sending WhatsApp message to ${(_x = notificationRuleItem.userWhatsApp) === null || _x === void 0 ? void 0 : _x.phone.toString()}.`;
|
|
411
520
|
logTimelineItem.userWhatsAppId = notificationRuleItem.userWhatsApp.id;
|
|
412
521
|
const updatedLog = await UserOnCallLogTimelineService.create({
|
|
413
522
|
data: logTimelineItem,
|
|
@@ -443,7 +552,7 @@ export class Service extends DatabaseService {
|
|
|
443
552
|
UserNotificationEventType.IncidentCreated &&
|
|
444
553
|
incident) {
|
|
445
554
|
logTimelineItem.status = UserNotificationStatus.Sending;
|
|
446
|
-
logTimelineItem.statusMessage = `Sending WhatsApp message to ${(
|
|
555
|
+
logTimelineItem.statusMessage = `Sending WhatsApp message to ${(_y = notificationRuleItem.userWhatsApp) === null || _y === void 0 ? void 0 : _y.phone.toString()}.`;
|
|
447
556
|
logTimelineItem.userWhatsAppId = notificationRuleItem.userWhatsApp.id;
|
|
448
557
|
const updatedLog = await UserOnCallLogTimelineService.create({
|
|
449
558
|
data: logTimelineItem,
|
|
@@ -475,11 +584,48 @@ export class Service extends DatabaseService {
|
|
|
475
584
|
});
|
|
476
585
|
});
|
|
477
586
|
}
|
|
587
|
+
// send WhatsApp for alert episode
|
|
588
|
+
if (options.userNotificationEventType ===
|
|
589
|
+
UserNotificationEventType.AlertEpisodeCreated &&
|
|
590
|
+
alertEpisode) {
|
|
591
|
+
logTimelineItem.status = UserNotificationStatus.Sending;
|
|
592
|
+
logTimelineItem.statusMessage = `Sending WhatsApp message to ${(_z = notificationRuleItem.userWhatsApp) === null || _z === void 0 ? void 0 : _z.phone.toString()}.`;
|
|
593
|
+
logTimelineItem.userWhatsAppId = notificationRuleItem.userWhatsApp.id;
|
|
594
|
+
const updatedLog = await UserOnCallLogTimelineService.create({
|
|
595
|
+
data: logTimelineItem,
|
|
596
|
+
props: {
|
|
597
|
+
isRoot: true,
|
|
598
|
+
},
|
|
599
|
+
});
|
|
600
|
+
const whatsAppMessage = await this.generateWhatsAppTemplateForAlertEpisodeCreated(notificationRuleItem.userWhatsApp.phone, alertEpisode, updatedLog.id);
|
|
601
|
+
WhatsAppService.sendWhatsAppMessage(whatsAppMessage, {
|
|
602
|
+
projectId: alertEpisode.projectId,
|
|
603
|
+
alertEpisodeId: alertEpisode.id,
|
|
604
|
+
userOnCallLogTimelineId: updatedLog.id,
|
|
605
|
+
userId: notificationRuleItem.userId,
|
|
606
|
+
onCallPolicyId: options.onCallPolicyId,
|
|
607
|
+
onCallPolicyEscalationRuleId: options.onCallPolicyEscalationRuleId,
|
|
608
|
+
teamId: options.userBelongsToTeamId,
|
|
609
|
+
onCallDutyPolicyExecutionLogTimelineId: options.onCallDutyPolicyExecutionLogTimelineId,
|
|
610
|
+
onCallScheduleId: options.onCallScheduleId,
|
|
611
|
+
}).catch(async (err) => {
|
|
612
|
+
await UserOnCallLogTimelineService.updateOneById({
|
|
613
|
+
id: updatedLog.id,
|
|
614
|
+
data: {
|
|
615
|
+
status: UserNotificationStatus.Error,
|
|
616
|
+
statusMessage: err.message || "Error sending WhatsApp message.",
|
|
617
|
+
},
|
|
618
|
+
props: {
|
|
619
|
+
isRoot: true,
|
|
620
|
+
},
|
|
621
|
+
});
|
|
622
|
+
});
|
|
623
|
+
}
|
|
478
624
|
}
|
|
479
|
-
if (((
|
|
480
|
-
!((
|
|
625
|
+
if (((_0 = notificationRuleItem.userWhatsApp) === null || _0 === void 0 ? void 0 : _0.phone) &&
|
|
626
|
+
!((_1 = notificationRuleItem.userWhatsApp) === null || _1 === void 0 ? void 0 : _1.isVerified)) {
|
|
481
627
|
logTimelineItem.status = UserNotificationStatus.Error;
|
|
482
|
-
logTimelineItem.statusMessage = `WhatsApp message not sent because phone ${(
|
|
628
|
+
logTimelineItem.statusMessage = `WhatsApp message not sent because phone ${(_2 = notificationRuleItem.userWhatsApp) === null || _2 === void 0 ? void 0 : _2.phone.toString()} is not verified.`;
|
|
483
629
|
logTimelineItem.userWhatsAppId = notificationRuleItem.userWhatsApp.id;
|
|
484
630
|
await UserOnCallLogTimelineService.create({
|
|
485
631
|
data: logTimelineItem,
|
|
@@ -489,15 +635,15 @@ export class Service extends DatabaseService {
|
|
|
489
635
|
});
|
|
490
636
|
}
|
|
491
637
|
// send call.
|
|
492
|
-
if (((
|
|
493
|
-
((
|
|
638
|
+
if (((_3 = notificationRuleItem.userCall) === null || _3 === void 0 ? void 0 : _3.phone) &&
|
|
639
|
+
((_4 = notificationRuleItem.userCall) === null || _4 === void 0 ? void 0 : _4.isVerified)) {
|
|
494
640
|
// send call for alert
|
|
495
641
|
if (options.userNotificationEventType ===
|
|
496
642
|
UserNotificationEventType.AlertCreated &&
|
|
497
643
|
alert) {
|
|
498
644
|
// create an error log.
|
|
499
645
|
logTimelineItem.status = UserNotificationStatus.Sending;
|
|
500
|
-
logTimelineItem.statusMessage = `Making a call to ${(
|
|
646
|
+
logTimelineItem.statusMessage = `Making a call to ${(_5 = notificationRuleItem.userCall) === null || _5 === void 0 ? void 0 : _5.phone.toString()}.`;
|
|
501
647
|
logTimelineItem.userCallId = notificationRuleItem.userCall.id;
|
|
502
648
|
const updatedLog = await UserOnCallLogTimelineService.create({
|
|
503
649
|
data: logTimelineItem,
|
|
@@ -505,7 +651,7 @@ export class Service extends DatabaseService {
|
|
|
505
651
|
isRoot: true,
|
|
506
652
|
},
|
|
507
653
|
});
|
|
508
|
-
const callRequest = await this.generateCallTemplateForAlertCreated((
|
|
654
|
+
const callRequest = await this.generateCallTemplateForAlertCreated((_6 = notificationRuleItem.userCall) === null || _6 === void 0 ? void 0 : _6.phone, alert, updatedLog.id);
|
|
509
655
|
// send call.
|
|
510
656
|
CallService.makeCall(callRequest, {
|
|
511
657
|
projectId: alert.projectId,
|
|
@@ -535,7 +681,7 @@ export class Service extends DatabaseService {
|
|
|
535
681
|
incident) {
|
|
536
682
|
// send call for incident
|
|
537
683
|
logTimelineItem.status = UserNotificationStatus.Sending;
|
|
538
|
-
logTimelineItem.statusMessage = `Making a call to ${(
|
|
684
|
+
logTimelineItem.statusMessage = `Making a call to ${(_7 = notificationRuleItem.userCall) === null || _7 === void 0 ? void 0 : _7.phone.toString()}.`;
|
|
539
685
|
logTimelineItem.userCallId = notificationRuleItem.userCall.id;
|
|
540
686
|
const updatedLog = await UserOnCallLogTimelineService.create({
|
|
541
687
|
data: logTimelineItem,
|
|
@@ -543,7 +689,7 @@ export class Service extends DatabaseService {
|
|
|
543
689
|
isRoot: true,
|
|
544
690
|
},
|
|
545
691
|
});
|
|
546
|
-
const callRequest = await this.generateCallTemplateForIncidentCreated((
|
|
692
|
+
const callRequest = await this.generateCallTemplateForIncidentCreated((_8 = notificationRuleItem.userCall) === null || _8 === void 0 ? void 0 : _8.phone, incident, updatedLog.id);
|
|
547
693
|
// send call.
|
|
548
694
|
CallService.makeCall(callRequest, {
|
|
549
695
|
projectId: incident.projectId,
|
|
@@ -568,12 +714,49 @@ export class Service extends DatabaseService {
|
|
|
568
714
|
});
|
|
569
715
|
});
|
|
570
716
|
}
|
|
717
|
+
// send call for alert episode
|
|
718
|
+
if (options.userNotificationEventType ===
|
|
719
|
+
UserNotificationEventType.AlertEpisodeCreated &&
|
|
720
|
+
alertEpisode) {
|
|
721
|
+
logTimelineItem.status = UserNotificationStatus.Sending;
|
|
722
|
+
logTimelineItem.statusMessage = `Making a call to ${(_9 = notificationRuleItem.userCall) === null || _9 === void 0 ? void 0 : _9.phone.toString()}.`;
|
|
723
|
+
logTimelineItem.userCallId = notificationRuleItem.userCall.id;
|
|
724
|
+
const updatedLog = await UserOnCallLogTimelineService.create({
|
|
725
|
+
data: logTimelineItem,
|
|
726
|
+
props: {
|
|
727
|
+
isRoot: true,
|
|
728
|
+
},
|
|
729
|
+
});
|
|
730
|
+
const callRequest = await this.generateCallTemplateForAlertEpisodeCreated((_10 = notificationRuleItem.userCall) === null || _10 === void 0 ? void 0 : _10.phone, alertEpisode, updatedLog.id);
|
|
731
|
+
CallService.makeCall(callRequest, {
|
|
732
|
+
projectId: alertEpisode.projectId,
|
|
733
|
+
userOnCallLogTimelineId: updatedLog.id,
|
|
734
|
+
alertEpisodeId: alertEpisode.id,
|
|
735
|
+
userId: notificationRuleItem.userId,
|
|
736
|
+
onCallPolicyId: options.onCallPolicyId,
|
|
737
|
+
onCallPolicyEscalationRuleId: options.onCallPolicyEscalationRuleId,
|
|
738
|
+
teamId: options.userBelongsToTeamId,
|
|
739
|
+
onCallDutyPolicyExecutionLogTimelineId: options.onCallDutyPolicyExecutionLogTimelineId,
|
|
740
|
+
onCallScheduleId: options.onCallScheduleId,
|
|
741
|
+
}).catch(async (err) => {
|
|
742
|
+
await UserOnCallLogTimelineService.updateOneById({
|
|
743
|
+
id: updatedLog.id,
|
|
744
|
+
data: {
|
|
745
|
+
status: UserNotificationStatus.Error,
|
|
746
|
+
statusMessage: err.message || "Error making call.",
|
|
747
|
+
},
|
|
748
|
+
props: {
|
|
749
|
+
isRoot: true,
|
|
750
|
+
},
|
|
751
|
+
});
|
|
752
|
+
});
|
|
753
|
+
}
|
|
571
754
|
}
|
|
572
|
-
if (((
|
|
573
|
-
!((
|
|
755
|
+
if (((_11 = notificationRuleItem.userCall) === null || _11 === void 0 ? void 0 : _11.phone) &&
|
|
756
|
+
!((_12 = notificationRuleItem.userCall) === null || _12 === void 0 ? void 0 : _12.isVerified)) {
|
|
574
757
|
// create a log.
|
|
575
758
|
logTimelineItem.status = UserNotificationStatus.Error;
|
|
576
|
-
logTimelineItem.statusMessage = `Call not sent because phone ${(
|
|
759
|
+
logTimelineItem.statusMessage = `Call not sent because phone ${(_13 = notificationRuleItem.userCall) === null || _13 === void 0 ? void 0 : _13.phone.toString()} is not verified.`;
|
|
577
760
|
await UserOnCallLogTimelineService.create({
|
|
578
761
|
data: logTimelineItem,
|
|
579
762
|
props: {
|
|
@@ -582,8 +765,8 @@ export class Service extends DatabaseService {
|
|
|
582
765
|
});
|
|
583
766
|
}
|
|
584
767
|
// send push notification.
|
|
585
|
-
if (((
|
|
586
|
-
((
|
|
768
|
+
if (((_14 = notificationRuleItem.userPush) === null || _14 === void 0 ? void 0 : _14.deviceToken) &&
|
|
769
|
+
((_15 = notificationRuleItem.userPush) === null || _15 === void 0 ? void 0 : _15.isVerified)) {
|
|
587
770
|
// send push notification for alert
|
|
588
771
|
if (options.userNotificationEventType ===
|
|
589
772
|
UserNotificationEventType.AlertCreated &&
|
|
@@ -600,8 +783,9 @@ export class Service extends DatabaseService {
|
|
|
600
783
|
});
|
|
601
784
|
const pushMessage = PushNotificationUtil.createAlertCreatedNotification({
|
|
602
785
|
alertTitle: alert.title,
|
|
603
|
-
projectName: ((
|
|
786
|
+
projectName: ((_16 = alert.project) === null || _16 === void 0 ? void 0 : _16.name) || "OneUptime",
|
|
604
787
|
alertViewLink: (await AlertService.getAlertLinkInDashboard(alert.projectId, alert.id)).toString(),
|
|
788
|
+
alertNumber: alert.alertNumber,
|
|
605
789
|
});
|
|
606
790
|
// send push notification.
|
|
607
791
|
PushNotificationService.sendPushNotification({
|
|
@@ -651,8 +835,9 @@ export class Service extends DatabaseService {
|
|
|
651
835
|
});
|
|
652
836
|
const pushMessage = PushNotificationUtil.createIncidentCreatedNotification({
|
|
653
837
|
incidentTitle: incident.title,
|
|
654
|
-
projectName: ((
|
|
838
|
+
projectName: ((_17 = incident.project) === null || _17 === void 0 ? void 0 : _17.name) || "OneUptime",
|
|
655
839
|
incidentViewLink: (await IncidentService.getIncidentLinkInDashboard(incident.projectId, incident.id)).toString(),
|
|
840
|
+
incidentNumber: incident.incidentNumber,
|
|
656
841
|
});
|
|
657
842
|
// send push notification.
|
|
658
843
|
PushNotificationService.sendPushNotification({
|
|
@@ -686,9 +871,59 @@ export class Service extends DatabaseService {
|
|
|
686
871
|
});
|
|
687
872
|
});
|
|
688
873
|
}
|
|
874
|
+
// send push notification for alert episode
|
|
875
|
+
if (options.userNotificationEventType ===
|
|
876
|
+
UserNotificationEventType.AlertEpisodeCreated &&
|
|
877
|
+
alertEpisode) {
|
|
878
|
+
logTimelineItem.status = UserNotificationStatus.Sending;
|
|
879
|
+
logTimelineItem.statusMessage = `Sending push notification to device.`;
|
|
880
|
+
logTimelineItem.userPushId = notificationRuleItem.userPush.id;
|
|
881
|
+
const updatedLog = await UserOnCallLogTimelineService.create({
|
|
882
|
+
data: logTimelineItem,
|
|
883
|
+
props: {
|
|
884
|
+
isRoot: true,
|
|
885
|
+
},
|
|
886
|
+
});
|
|
887
|
+
const pushMessage = PushNotificationUtil.createAlertEpisodeCreatedNotification({
|
|
888
|
+
alertEpisodeTitle: alertEpisode.title,
|
|
889
|
+
projectName: ((_18 = alertEpisode.project) === null || _18 === void 0 ? void 0 : _18.name) || "OneUptime",
|
|
890
|
+
alertEpisodeViewLink: (await AlertEpisodeService.getEpisodeLinkInDashboard(alertEpisode.projectId, alertEpisode.id)).toString(),
|
|
891
|
+
episodeNumber: alertEpisode.episodeNumber,
|
|
892
|
+
});
|
|
893
|
+
PushNotificationService.sendPushNotification({
|
|
894
|
+
devices: [
|
|
895
|
+
Object.assign({ token: notificationRuleItem.userPush.deviceToken }, (notificationRuleItem.userPush.deviceName && {
|
|
896
|
+
name: notificationRuleItem.userPush.deviceName,
|
|
897
|
+
})),
|
|
898
|
+
],
|
|
899
|
+
message: pushMessage,
|
|
900
|
+
deviceType: notificationRuleItem.userPush.deviceType,
|
|
901
|
+
}, {
|
|
902
|
+
projectId: options.projectId,
|
|
903
|
+
userOnCallLogTimelineId: updatedLog.id,
|
|
904
|
+
alertEpisodeId: alertEpisode.id,
|
|
905
|
+
userId: notificationRuleItem.userId,
|
|
906
|
+
onCallPolicyId: options.onCallPolicyId,
|
|
907
|
+
onCallPolicyEscalationRuleId: options.onCallPolicyEscalationRuleId,
|
|
908
|
+
teamId: options.userBelongsToTeamId,
|
|
909
|
+
onCallDutyPolicyExecutionLogTimelineId: options.onCallDutyPolicyExecutionLogTimelineId,
|
|
910
|
+
onCallScheduleId: options.onCallScheduleId,
|
|
911
|
+
}).catch(async (err) => {
|
|
912
|
+
await UserOnCallLogTimelineService.updateOneById({
|
|
913
|
+
id: updatedLog.id,
|
|
914
|
+
data: {
|
|
915
|
+
status: UserNotificationStatus.Error,
|
|
916
|
+
statusMessage: err.message || "Error sending push notification.",
|
|
917
|
+
},
|
|
918
|
+
props: {
|
|
919
|
+
isRoot: true,
|
|
920
|
+
},
|
|
921
|
+
});
|
|
922
|
+
});
|
|
923
|
+
}
|
|
689
924
|
}
|
|
690
|
-
if (((
|
|
691
|
-
!((
|
|
925
|
+
if (((_19 = notificationRuleItem.userPush) === null || _19 === void 0 ? void 0 : _19.deviceToken) &&
|
|
926
|
+
!((_20 = notificationRuleItem.userPush) === null || _20 === void 0 ? void 0 : _20.isVerified)) {
|
|
692
927
|
// create a log.
|
|
693
928
|
logTimelineItem.status = UserNotificationStatus.Error;
|
|
694
929
|
logTimelineItem.statusMessage = `Push notification not sent because device is not verified.`;
|
|
@@ -703,6 +938,9 @@ export class Service extends DatabaseService {
|
|
|
703
938
|
async generateCallTemplateForAlertCreated(to, alert, userOnCallLogTimelineId) {
|
|
704
939
|
const host = await DatabaseConfig.getHost();
|
|
705
940
|
const httpProtocol = await DatabaseConfig.getHttpProtocol();
|
|
941
|
+
const alertIdentifier = alert.alertNumber !== undefined
|
|
942
|
+
? `Alert number ${alert.alertNumber}, ${alert.title || "Alert"}`
|
|
943
|
+
: alert.title || "Alert";
|
|
706
944
|
const callRequest = {
|
|
707
945
|
to: to,
|
|
708
946
|
data: [
|
|
@@ -713,7 +951,7 @@ export class Service extends DatabaseService {
|
|
|
713
951
|
sayMessage: "A new alert has been created",
|
|
714
952
|
},
|
|
715
953
|
{
|
|
716
|
-
sayMessage:
|
|
954
|
+
sayMessage: alertIdentifier,
|
|
717
955
|
},
|
|
718
956
|
{
|
|
719
957
|
introMessage: "To acknowledge this alert press 1",
|
|
@@ -739,6 +977,9 @@ export class Service extends DatabaseService {
|
|
|
739
977
|
async generateCallTemplateForIncidentCreated(to, incident, userOnCallLogTimelineId) {
|
|
740
978
|
const host = await DatabaseConfig.getHost();
|
|
741
979
|
const httpProtocol = await DatabaseConfig.getHttpProtocol();
|
|
980
|
+
const incidentIdentifier = incident.incidentNumber !== undefined
|
|
981
|
+
? `Incident number ${incident.incidentNumber}, ${incident.title || "Incident"}`
|
|
982
|
+
: incident.title || "Incident";
|
|
742
983
|
const callRequest = {
|
|
743
984
|
to: to,
|
|
744
985
|
data: [
|
|
@@ -749,7 +990,7 @@ export class Service extends DatabaseService {
|
|
|
749
990
|
sayMessage: "A new incident has been created",
|
|
750
991
|
},
|
|
751
992
|
{
|
|
752
|
-
sayMessage:
|
|
993
|
+
sayMessage: incidentIdentifier,
|
|
753
994
|
},
|
|
754
995
|
{
|
|
755
996
|
introMessage: "To acknowledge this incident press 1",
|
|
@@ -772,6 +1013,45 @@ export class Service extends DatabaseService {
|
|
|
772
1013
|
};
|
|
773
1014
|
return callRequest;
|
|
774
1015
|
}
|
|
1016
|
+
async generateCallTemplateForAlertEpisodeCreated(to, alertEpisode, userOnCallLogTimelineId) {
|
|
1017
|
+
const host = await DatabaseConfig.getHost();
|
|
1018
|
+
const httpProtocol = await DatabaseConfig.getHttpProtocol();
|
|
1019
|
+
const episodeIdentifier = alertEpisode.episodeNumber !== undefined
|
|
1020
|
+
? `Alert episode number ${alertEpisode.episodeNumber}, ${alertEpisode.title || "Alert Episode"}`
|
|
1021
|
+
: alertEpisode.title || "Alert Episode";
|
|
1022
|
+
const callRequest = {
|
|
1023
|
+
to: to,
|
|
1024
|
+
data: [
|
|
1025
|
+
{
|
|
1026
|
+
sayMessage: "This is a call from OneUptime",
|
|
1027
|
+
},
|
|
1028
|
+
{
|
|
1029
|
+
sayMessage: "A new alert episode has been created",
|
|
1030
|
+
},
|
|
1031
|
+
{
|
|
1032
|
+
sayMessage: episodeIdentifier,
|
|
1033
|
+
},
|
|
1034
|
+
{
|
|
1035
|
+
introMessage: "To acknowledge this alert episode press 1",
|
|
1036
|
+
numDigits: 1,
|
|
1037
|
+
timeoutInSeconds: 10,
|
|
1038
|
+
noInputMessage: "You have not entered any input. Good bye",
|
|
1039
|
+
onInputCallRequest: {
|
|
1040
|
+
"1": {
|
|
1041
|
+
sayMessage: "You have acknowledged this alert episode. Good bye",
|
|
1042
|
+
},
|
|
1043
|
+
default: {
|
|
1044
|
+
sayMessage: "Invalid input. Good bye",
|
|
1045
|
+
},
|
|
1046
|
+
},
|
|
1047
|
+
responseUrl: new URL(httpProtocol, host, new Route(AppApiRoute.toString())
|
|
1048
|
+
.addRoute(new UserOnCallLogTimeline().crudApiPath)
|
|
1049
|
+
.addRoute("/call/gather-input/" + userOnCallLogTimelineId.toString())),
|
|
1050
|
+
},
|
|
1051
|
+
],
|
|
1052
|
+
};
|
|
1053
|
+
return callRequest;
|
|
1054
|
+
}
|
|
775
1055
|
async generateSmsTemplateForAlertCreated(to, alert, userOnCallLogTimelineId) {
|
|
776
1056
|
const host = await DatabaseConfig.getHost();
|
|
777
1057
|
const httpProtocol = await DatabaseConfig.getHttpProtocol();
|
|
@@ -804,6 +1084,22 @@ export class Service extends DatabaseService {
|
|
|
804
1084
|
};
|
|
805
1085
|
return sms;
|
|
806
1086
|
}
|
|
1087
|
+
async generateSmsTemplateForAlertEpisodeCreated(to, alertEpisode, userOnCallLogTimelineId) {
|
|
1088
|
+
const host = await DatabaseConfig.getHost();
|
|
1089
|
+
const httpProtocol = await DatabaseConfig.getHttpProtocol();
|
|
1090
|
+
const shortUrl = await ShortLinkService.saveShortLinkFor(new URL(httpProtocol, host, new Route(AppApiRoute.toString())
|
|
1091
|
+
.addRoute(new UserOnCallLogTimeline().crudApiPath)
|
|
1092
|
+
.addRoute("/acknowledge-page/" + userOnCallLogTimelineId.toString())));
|
|
1093
|
+
const url = await ShortLinkService.getShortenedUrl(shortUrl);
|
|
1094
|
+
const episodeIdentifier = alertEpisode.episodeNumber !== undefined
|
|
1095
|
+
? `#${alertEpisode.episodeNumber} (${alertEpisode.title || "Alert Episode"})`
|
|
1096
|
+
: alertEpisode.title || "Alert Episode";
|
|
1097
|
+
const sms = {
|
|
1098
|
+
to,
|
|
1099
|
+
message: `This is a message from OneUptime. A new alert episode has been created: ${episodeIdentifier}. To acknowledge this alert episode, please click on the following link ${url.toString()}`,
|
|
1100
|
+
};
|
|
1101
|
+
return sms;
|
|
1102
|
+
}
|
|
807
1103
|
async generateWhatsAppTemplateForAlertCreated(to, alert, userOnCallLogTimelineId) {
|
|
808
1104
|
var _a;
|
|
809
1105
|
const host = await DatabaseConfig.getHost();
|
|
@@ -862,11 +1158,45 @@ export class Service extends DatabaseService {
|
|
|
862
1158
|
templateLanguageCode: WhatsAppTemplateLanguage[templateKey],
|
|
863
1159
|
};
|
|
864
1160
|
}
|
|
1161
|
+
async generateWhatsAppTemplateForAlertEpisodeCreated(to, alertEpisode, userOnCallLogTimelineId) {
|
|
1162
|
+
var _a;
|
|
1163
|
+
const host = await DatabaseConfig.getHost();
|
|
1164
|
+
const httpProtocol = await DatabaseConfig.getHttpProtocol();
|
|
1165
|
+
const acknowledgeShortLink = await ShortLinkService.saveShortLinkFor(new URL(httpProtocol, host, new Route(AppApiRoute.toString())
|
|
1166
|
+
.addRoute(new UserOnCallLogTimeline().crudApiPath)
|
|
1167
|
+
.addRoute("/acknowledge-page/" + userOnCallLogTimelineId.toString())));
|
|
1168
|
+
const acknowledgeUrl = await ShortLinkService.getShortenedUrl(acknowledgeShortLink);
|
|
1169
|
+
const episodeLinkOnDashboard = alertEpisode.projectId && alertEpisode.id
|
|
1170
|
+
? (await AlertEpisodeService.getEpisodeLinkInDashboard(alertEpisode.projectId, alertEpisode.id)).toString()
|
|
1171
|
+
: acknowledgeUrl.toString();
|
|
1172
|
+
const templateKey = WhatsAppTemplateIds.AlertEpisodeCreated;
|
|
1173
|
+
const templateVariables = {
|
|
1174
|
+
project_name: ((_a = alertEpisode.project) === null || _a === void 0 ? void 0 : _a.name) || "OneUptime",
|
|
1175
|
+
episode_title: alertEpisode.title || "",
|
|
1176
|
+
acknowledge_url: acknowledgeUrl.toString(),
|
|
1177
|
+
episode_number: alertEpisode.episodeNumber !== undefined
|
|
1178
|
+
? alertEpisode.episodeNumber.toString()
|
|
1179
|
+
: "",
|
|
1180
|
+
episode_link: episodeLinkOnDashboard,
|
|
1181
|
+
};
|
|
1182
|
+
const body = renderWhatsAppTemplate(templateKey, templateVariables);
|
|
1183
|
+
return {
|
|
1184
|
+
to,
|
|
1185
|
+
body,
|
|
1186
|
+
templateKey,
|
|
1187
|
+
templateVariables,
|
|
1188
|
+
templateLanguageCode: WhatsAppTemplateLanguage[templateKey],
|
|
1189
|
+
};
|
|
1190
|
+
}
|
|
865
1191
|
async generateEmailTemplateForAlertCreated(to, alert, userOnCallLogTimelineId) {
|
|
866
1192
|
const host = await DatabaseConfig.getHost();
|
|
867
1193
|
const httpProtocol = await DatabaseConfig.getHttpProtocol();
|
|
1194
|
+
const alertNumber = alert.alertNumber
|
|
1195
|
+
? `#${alert.alertNumber}`
|
|
1196
|
+
: "";
|
|
868
1197
|
const vars = {
|
|
869
1198
|
alertTitle: alert.title,
|
|
1199
|
+
alertNumber: alertNumber,
|
|
870
1200
|
projectName: alert.project.name,
|
|
871
1201
|
currentState: alert.currentAlertState.name,
|
|
872
1202
|
alertDescription: await Markdown.convertToHTML(alert.description || "", MarkdownContentType.Email),
|
|
@@ -880,15 +1210,19 @@ export class Service extends DatabaseService {
|
|
|
880
1210
|
toEmail: to,
|
|
881
1211
|
templateType: EmailTemplateType.AcknowledgeAlert,
|
|
882
1212
|
vars: vars,
|
|
883
|
-
subject:
|
|
1213
|
+
subject: `ACTION REQUIRED: Alert ${alertNumber} created - ${alert.title}`,
|
|
884
1214
|
};
|
|
885
1215
|
return emailMessage;
|
|
886
1216
|
}
|
|
887
1217
|
async generateEmailTemplateForIncidentCreated(to, incident, userOnCallLogTimelineId) {
|
|
888
1218
|
const host = await DatabaseConfig.getHost();
|
|
889
1219
|
const httpProtocol = await DatabaseConfig.getHttpProtocol();
|
|
1220
|
+
const incidentNumber = incident.incidentNumber
|
|
1221
|
+
? `#${incident.incidentNumber}`
|
|
1222
|
+
: "";
|
|
890
1223
|
const vars = {
|
|
891
1224
|
incidentTitle: incident.title,
|
|
1225
|
+
incidentNumber: incidentNumber,
|
|
892
1226
|
projectName: incident.project.name,
|
|
893
1227
|
currentState: incident.currentIncidentState.name,
|
|
894
1228
|
incidentDescription: await Markdown.convertToHTML(incident.description || "", MarkdownContentType.Email),
|
|
@@ -903,7 +1237,114 @@ export class Service extends DatabaseService {
|
|
|
903
1237
|
toEmail: to,
|
|
904
1238
|
templateType: EmailTemplateType.AcknowledgeIncident,
|
|
905
1239
|
vars: vars,
|
|
906
|
-
subject:
|
|
1240
|
+
subject: `ACTION REQUIRED: Incident ${incidentNumber} created - ${incident.title}`,
|
|
1241
|
+
};
|
|
1242
|
+
return emailMessage;
|
|
1243
|
+
}
|
|
1244
|
+
async generateEmailTemplateForAlertEpisodeCreated(to, alertEpisode, userOnCallLogTimelineId) {
|
|
1245
|
+
var _a, _b, _c;
|
|
1246
|
+
const host = await DatabaseConfig.getHost();
|
|
1247
|
+
const httpProtocol = await DatabaseConfig.getHttpProtocol();
|
|
1248
|
+
// Fetch alerts that are members of this episode
|
|
1249
|
+
const episodeMembers = await AlertEpisodeMemberService.findBy({
|
|
1250
|
+
query: {
|
|
1251
|
+
alertEpisodeId: alertEpisode.id,
|
|
1252
|
+
},
|
|
1253
|
+
select: {
|
|
1254
|
+
alertId: true,
|
|
1255
|
+
alert: {
|
|
1256
|
+
_id: true,
|
|
1257
|
+
title: true,
|
|
1258
|
+
alertNumber: true,
|
|
1259
|
+
monitor: {
|
|
1260
|
+
_id: true,
|
|
1261
|
+
name: true,
|
|
1262
|
+
},
|
|
1263
|
+
},
|
|
1264
|
+
},
|
|
1265
|
+
props: {
|
|
1266
|
+
isRoot: true,
|
|
1267
|
+
},
|
|
1268
|
+
limit: LIMIT_PER_PROJECT,
|
|
1269
|
+
skip: 0,
|
|
1270
|
+
});
|
|
1271
|
+
// Get unique monitors (resources affected)
|
|
1272
|
+
const monitorNames = new Set();
|
|
1273
|
+
for (const member of episodeMembers) {
|
|
1274
|
+
if ((_b = (_a = member.alert) === null || _a === void 0 ? void 0 : _a.monitor) === null || _b === void 0 ? void 0 : _b.name) {
|
|
1275
|
+
monitorNames.add(member.alert.monitor.name);
|
|
1276
|
+
}
|
|
1277
|
+
}
|
|
1278
|
+
const resourcesAffected = monitorNames.size > 0
|
|
1279
|
+
? Array.from(monitorNames).join(", ")
|
|
1280
|
+
: "No resources identified";
|
|
1281
|
+
// Build alerts list HTML with proper email styling
|
|
1282
|
+
let alertsListHtml = "";
|
|
1283
|
+
if (episodeMembers.length > 0) {
|
|
1284
|
+
const alertRows = [];
|
|
1285
|
+
for (const member of episodeMembers) {
|
|
1286
|
+
if (member.alert) {
|
|
1287
|
+
const alertTitle = member.alert.title || "Untitled Alert";
|
|
1288
|
+
const alertNumber = member.alert.alertNumber
|
|
1289
|
+
? `#${member.alert.alertNumber}`
|
|
1290
|
+
: "";
|
|
1291
|
+
const alertLink = (await AlertService.getAlertLinkInDashboard(alertEpisode.projectId, new ObjectID(member.alert._id))).toString();
|
|
1292
|
+
const monitorName = ((_c = member.alert.monitor) === null || _c === void 0 ? void 0 : _c.name) || "";
|
|
1293
|
+
alertRows.push(`
|
|
1294
|
+
<tr>
|
|
1295
|
+
<td style="padding: 12px 16px; border-bottom: 1px solid #e2e8f0;">
|
|
1296
|
+
<table cellpadding="0" cellspacing="0" width="100%">
|
|
1297
|
+
<tr>
|
|
1298
|
+
<td style="vertical-align: middle;">
|
|
1299
|
+
<span style="display: inline-block; background-color: #dbeafe; color: #1e40af; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 4px; margin-right: 8px;">${alertNumber}</span>
|
|
1300
|
+
<a href="${alertLink}" style="color: #2563eb; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; font-size: 14px; font-weight: 500; text-decoration: none;">${alertTitle}</a>
|
|
1301
|
+
${monitorName ? `<span style="display: block; color: #64748b; font-size: 12px; margin-top: 4px;">Monitor: ${monitorName}</span>` : ""}
|
|
1302
|
+
</td>
|
|
1303
|
+
<td style="text-align: right; vertical-align: middle;">
|
|
1304
|
+
<a href="${alertLink}" style="color: #2563eb; font-size: 12px; text-decoration: none;">View →</a>
|
|
1305
|
+
</td>
|
|
1306
|
+
</tr>
|
|
1307
|
+
</table>
|
|
1308
|
+
</td>
|
|
1309
|
+
</tr>
|
|
1310
|
+
`);
|
|
1311
|
+
}
|
|
1312
|
+
}
|
|
1313
|
+
if (alertRows.length > 0) {
|
|
1314
|
+
alertsListHtml = `
|
|
1315
|
+
<table cellpadding="0" cellspacing="0" width="100%" style="background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%); border-radius: 8px; border: 1px solid #e2e8f0; margin: 8px 0 16px 0;">
|
|
1316
|
+
<tbody>
|
|
1317
|
+
${alertRows.join("")}
|
|
1318
|
+
</tbody>
|
|
1319
|
+
</table>
|
|
1320
|
+
`;
|
|
1321
|
+
}
|
|
1322
|
+
}
|
|
1323
|
+
const episodeNumber = alertEpisode.episodeNumber
|
|
1324
|
+
? `#${alertEpisode.episodeNumber}`
|
|
1325
|
+
: "";
|
|
1326
|
+
const vars = {
|
|
1327
|
+
alertEpisodeTitle: alertEpisode.title,
|
|
1328
|
+
episodeNumber: episodeNumber,
|
|
1329
|
+
projectName: alertEpisode.project.name,
|
|
1330
|
+
currentState: alertEpisode.currentAlertState.name,
|
|
1331
|
+
alertEpisodeDescription: await Markdown.convertToHTML(alertEpisode.description || "", MarkdownContentType.Email),
|
|
1332
|
+
alertEpisodeSeverity: alertEpisode.alertSeverity.name,
|
|
1333
|
+
resourcesAffected: resourcesAffected,
|
|
1334
|
+
rootCause: alertEpisode.rootCause ||
|
|
1335
|
+
"No root cause identified for this alert episode",
|
|
1336
|
+
alertsList: alertsListHtml,
|
|
1337
|
+
alertsCount: episodeMembers.length.toString(),
|
|
1338
|
+
alertEpisodeViewLink: (await AlertEpisodeService.getEpisodeLinkInDashboard(alertEpisode.projectId, alertEpisode.id)).toString(),
|
|
1339
|
+
acknowledgeAlertEpisodeLink: new URL(httpProtocol, host, new Route(AppApiRoute.toString())
|
|
1340
|
+
.addRoute(new UserOnCallLogTimeline().crudApiPath)
|
|
1341
|
+
.addRoute("/acknowledge-page/" + userOnCallLogTimelineId.toString())).toString(),
|
|
1342
|
+
};
|
|
1343
|
+
const emailMessage = {
|
|
1344
|
+
toEmail: to,
|
|
1345
|
+
templateType: EmailTemplateType.AcknowledgeAlertEpisode,
|
|
1346
|
+
vars: vars,
|
|
1347
|
+
subject: `ACTION REQUIRED: Alert Episode ${episodeNumber} created - ${alertEpisode.title}`,
|
|
907
1348
|
};
|
|
908
1349
|
return emailMessage;
|
|
909
1350
|
}
|
|
@@ -918,6 +1359,10 @@ export class Service extends DatabaseService {
|
|
|
918
1359
|
if (options.triggeredByAlertId) {
|
|
919
1360
|
userOnCallLog.triggeredByAlertId = options.triggeredByAlertId;
|
|
920
1361
|
}
|
|
1362
|
+
if (options.triggeredByAlertEpisodeId) {
|
|
1363
|
+
userOnCallLog.triggeredByAlertEpisodeId =
|
|
1364
|
+
options.triggeredByAlertEpisodeId;
|
|
1365
|
+
}
|
|
921
1366
|
userOnCallLog.userNotificationEventType = options.userNotificationEventType;
|
|
922
1367
|
if (options.onCallPolicyExecutionLogId) {
|
|
923
1368
|
userOnCallLog.onCallDutyPolicyExecutionLogId =
|
|
@@ -1043,7 +1488,7 @@ export class Service extends DatabaseService {
|
|
|
1043
1488
|
userId,
|
|
1044
1489
|
userEmailId: userEmail.id,
|
|
1045
1490
|
incidentSeverityId: incidentSeverity.id,
|
|
1046
|
-
ruleType: NotificationRuleType.
|
|
1491
|
+
ruleType: NotificationRuleType.ON_CALL_EXECUTED_INCIDENT,
|
|
1047
1492
|
},
|
|
1048
1493
|
props: {
|
|
1049
1494
|
isRoot: true,
|
|
@@ -1058,7 +1503,8 @@ export class Service extends DatabaseService {
|
|
|
1058
1503
|
notificationRule.userEmailId = userEmail.id;
|
|
1059
1504
|
notificationRule.incidentSeverityId = incidentSeverity.id;
|
|
1060
1505
|
notificationRule.notifyAfterMinutes = 0;
|
|
1061
|
-
notificationRule.ruleType =
|
|
1506
|
+
notificationRule.ruleType =
|
|
1507
|
+
NotificationRuleType.ON_CALL_EXECUTED_INCIDENT;
|
|
1062
1508
|
await this.create({
|
|
1063
1509
|
data: notificationRule,
|
|
1064
1510
|
props: {
|
|
@@ -1091,7 +1537,7 @@ export class Service extends DatabaseService {
|
|
|
1091
1537
|
userId,
|
|
1092
1538
|
userEmailId: userEmail.id,
|
|
1093
1539
|
alertSeverityId: alertSeverity.id,
|
|
1094
|
-
ruleType: NotificationRuleType.
|
|
1540
|
+
ruleType: NotificationRuleType.ON_CALL_EXECUTED_ALERT,
|
|
1095
1541
|
},
|
|
1096
1542
|
props: {
|
|
1097
1543
|
isRoot: true,
|
|
@@ -1106,7 +1552,7 @@ export class Service extends DatabaseService {
|
|
|
1106
1552
|
notificationRule.userEmailId = userEmail.id;
|
|
1107
1553
|
notificationRule.alertSeverityId = alertSeverity.id;
|
|
1108
1554
|
notificationRule.notifyAfterMinutes = 0;
|
|
1109
|
-
notificationRule.ruleType = NotificationRuleType.
|
|
1555
|
+
notificationRule.ruleType = NotificationRuleType.ON_CALL_EXECUTED_ALERT;
|
|
1110
1556
|
await this.create({
|
|
1111
1557
|
data: notificationRule,
|
|
1112
1558
|
props: {
|
|
@@ -1229,6 +1675,14 @@ __decorate([
|
|
|
1229
1675
|
ObjectID]),
|
|
1230
1676
|
__metadata("design:returntype", Promise)
|
|
1231
1677
|
], Service.prototype, "generateCallTemplateForIncidentCreated", null);
|
|
1678
|
+
__decorate([
|
|
1679
|
+
CaptureSpan(),
|
|
1680
|
+
__metadata("design:type", Function),
|
|
1681
|
+
__metadata("design:paramtypes", [Phone,
|
|
1682
|
+
AlertEpisode,
|
|
1683
|
+
ObjectID]),
|
|
1684
|
+
__metadata("design:returntype", Promise)
|
|
1685
|
+
], Service.prototype, "generateCallTemplateForAlertEpisodeCreated", null);
|
|
1232
1686
|
__decorate([
|
|
1233
1687
|
CaptureSpan(),
|
|
1234
1688
|
__metadata("design:type", Function),
|
|
@@ -1245,6 +1699,14 @@ __decorate([
|
|
|
1245
1699
|
ObjectID]),
|
|
1246
1700
|
__metadata("design:returntype", Promise)
|
|
1247
1701
|
], Service.prototype, "generateSmsTemplateForIncidentCreated", null);
|
|
1702
|
+
__decorate([
|
|
1703
|
+
CaptureSpan(),
|
|
1704
|
+
__metadata("design:type", Function),
|
|
1705
|
+
__metadata("design:paramtypes", [Phone,
|
|
1706
|
+
AlertEpisode,
|
|
1707
|
+
ObjectID]),
|
|
1708
|
+
__metadata("design:returntype", Promise)
|
|
1709
|
+
], Service.prototype, "generateSmsTemplateForAlertEpisodeCreated", null);
|
|
1248
1710
|
__decorate([
|
|
1249
1711
|
CaptureSpan(),
|
|
1250
1712
|
__metadata("design:type", Function),
|
|
@@ -1261,6 +1723,14 @@ __decorate([
|
|
|
1261
1723
|
ObjectID]),
|
|
1262
1724
|
__metadata("design:returntype", Promise)
|
|
1263
1725
|
], Service.prototype, "generateWhatsAppTemplateForIncidentCreated", null);
|
|
1726
|
+
__decorate([
|
|
1727
|
+
CaptureSpan(),
|
|
1728
|
+
__metadata("design:type", Function),
|
|
1729
|
+
__metadata("design:paramtypes", [Phone,
|
|
1730
|
+
AlertEpisode,
|
|
1731
|
+
ObjectID]),
|
|
1732
|
+
__metadata("design:returntype", Promise)
|
|
1733
|
+
], Service.prototype, "generateWhatsAppTemplateForAlertEpisodeCreated", null);
|
|
1264
1734
|
__decorate([
|
|
1265
1735
|
CaptureSpan(),
|
|
1266
1736
|
__metadata("design:type", Function),
|
|
@@ -1277,6 +1747,14 @@ __decorate([
|
|
|
1277
1747
|
ObjectID]),
|
|
1278
1748
|
__metadata("design:returntype", Promise)
|
|
1279
1749
|
], Service.prototype, "generateEmailTemplateForIncidentCreated", null);
|
|
1750
|
+
__decorate([
|
|
1751
|
+
CaptureSpan(),
|
|
1752
|
+
__metadata("design:type", Function),
|
|
1753
|
+
__metadata("design:paramtypes", [Email,
|
|
1754
|
+
AlertEpisode,
|
|
1755
|
+
ObjectID]),
|
|
1756
|
+
__metadata("design:returntype", Promise)
|
|
1757
|
+
], Service.prototype, "generateEmailTemplateForAlertEpisodeCreated", null);
|
|
1280
1758
|
__decorate([
|
|
1281
1759
|
CaptureSpan(),
|
|
1282
1760
|
__metadata("design:type", Function),
|