@oneuptime/common 9.4.12 → 9.4.13
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/Incident.ts +77 -0
- package/Models/DatabaseModels/IncidentEpisode.ts +1223 -0
- package/Models/DatabaseModels/IncidentEpisodeFeed.ts +533 -0
- package/Models/DatabaseModels/IncidentEpisodeInternalNote.ts +456 -0
- package/Models/DatabaseModels/IncidentEpisodeMember.ts +587 -0
- package/Models/DatabaseModels/IncidentEpisodeOwnerTeam.ts +421 -0
- package/Models/DatabaseModels/IncidentEpisodeOwnerUser.ts +419 -0
- package/Models/DatabaseModels/IncidentEpisodeStateTimeline.ts +524 -0
- package/Models/DatabaseModels/IncidentGroupingRule.ts +1430 -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/UserOnCallLog.ts +48 -0
- package/Models/DatabaseModels/UserOnCallLogTimeline.ts +49 -0
- package/Models/DatabaseModels/WorkspaceNotificationLog.ts +57 -0
- package/Server/API/IncidentEpisodeAPI.ts +150 -0
- package/Server/API/SlackAPI.ts +23 -0
- package/Server/API/UserOnCallLogTimelineAPI.ts +24 -4
- package/Server/Infrastructure/Postgres/SchemaMigrations/1769626069479-MigrationName.ts +729 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/1769629928240-MigrationName.ts +261 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/1769676117342-RenameEvaluateOverTimeInCriteriaFilter.ts +28 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/Index.ts +6 -0
- package/Server/Services/BillingService.ts +1 -3
- package/Server/Services/CallService.ts +1 -0
- package/Server/Services/IncidentEpisodeFeedService.ts +94 -0
- package/Server/Services/IncidentEpisodeInternalNoteService.ts +71 -0
- package/Server/Services/IncidentEpisodeMemberService.ts +321 -0
- package/Server/Services/IncidentEpisodeOwnerTeamService.ts +10 -0
- package/Server/Services/IncidentEpisodeOwnerUserService.ts +10 -0
- package/Server/Services/IncidentEpisodeService.ts +1045 -0
- package/Server/Services/IncidentEpisodeStateTimelineService.ts +566 -0
- package/Server/Services/IncidentGroupingEngineService.ts +1047 -0
- package/Server/Services/IncidentGroupingRuleService.ts +14 -0
- package/Server/Services/IncidentService.ts +11 -0
- package/Server/Services/Index.ts +18 -0
- package/Server/Services/MailService.ts +1 -0
- package/Server/Services/MonitorService.ts +9 -0
- package/Server/Services/OnCallDutyPolicyEscalationRuleService.ts +18 -0
- package/Server/Services/OnCallDutyPolicyExecutionLogService.ts +64 -2
- package/Server/Services/OnCallDutyPolicyExecutionLogTimelineService.ts +26 -1
- package/Server/Services/OnCallDutyPolicyService.ts +15 -0
- package/Server/Services/SmsService.ts +1 -0
- package/Server/Services/UserNotificationRuleService.ts +48 -2
- package/Server/Services/UserNotificationSettingService.ts +23 -0
- package/Server/Services/UserOnCallLogService.ts +41 -4
- package/Server/Services/WhatsAppService.ts +1 -0
- package/Server/Services/WorkspaceNotificationLogService.ts +16 -0
- package/Server/Services/WorkspaceNotificationRuleService.ts +116 -0
- package/Server/Utils/AI/IncidentEpisodeAIContextBuilder.ts +490 -0
- package/Server/Utils/Monitor/Criteria/APIRequestCriteria.ts +1 -1
- package/Server/Utils/Monitor/Criteria/CompareCriteria.ts +1 -1
- package/Server/Utils/Monitor/Criteria/IncomingRequestCriteria.ts +1 -1
- package/Server/Utils/Monitor/Criteria/SSLMonitorCriteria.ts +1 -1
- package/Server/Utils/Monitor/Criteria/ServerMonitorCriteria.ts +2 -2
- package/Server/Utils/Monitor/Criteria/SnmpMonitorCriteria.ts +182 -0
- package/Server/Utils/Monitor/MonitorCriteriaEvaluator.ts +13 -0
- package/Server/Utils/Monitor/MonitorCriteriaExpectationBuilder.ts +1 -1
- package/Server/Utils/Monitor/MonitorTemplateUtil.ts +37 -0
- package/Server/Utils/PushNotificationUtil.ts +31 -0
- package/Server/Utils/WhatsAppTemplateUtil.ts +14 -0
- package/Server/Utils/Workspace/MicrosoftTeams/Actions/ActionTypes.ts +18 -0
- package/Server/Utils/Workspace/MicrosoftTeams/Actions/IncidentEpisode.ts +702 -0
- package/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeams.ts +20 -0
- package/Server/Utils/Workspace/Slack/Actions/ActionTypes.ts +11 -0
- package/Server/Utils/Workspace/Slack/Actions/IncidentEpisode.ts +918 -0
- package/Server/Utils/Workspace/Slack/Messages/IncidentEpisode.ts +120 -0
- package/Server/Utils/Workspace/WorkspaceMessages/IncidentEpisode.ts +74 -0
- package/Types/Email/EmailTemplateType.ts +6 -0
- package/Types/Monitor/CriteriaFilter.ts +24 -4
- package/Types/Monitor/MonitorCriteriaInstance.ts +67 -0
- package/Types/Monitor/MonitorStep.ts +37 -0
- package/Types/Monitor/MonitorStepSnmpMonitor.ts +102 -0
- package/Types/Monitor/MonitorType.ts +15 -2
- package/Types/Monitor/SnmpMonitor/SnmpAuthProtocol.ts +8 -0
- package/Types/Monitor/SnmpMonitor/SnmpDataType.ts +21 -0
- package/Types/Monitor/SnmpMonitor/SnmpMonitorResponse.ts +16 -0
- package/Types/Monitor/SnmpMonitor/SnmpOid.ts +60 -0
- package/Types/Monitor/SnmpMonitor/SnmpPrivProtocol.ts +7 -0
- package/Types/Monitor/SnmpMonitor/SnmpSecurityLevel.ts +7 -0
- package/Types/Monitor/SnmpMonitor/SnmpV3Auth.ts +12 -0
- package/Types/Monitor/SnmpMonitor/SnmpVersion.ts +7 -0
- package/Types/NotificationSetting/NotificationSettingEventType.ts +7 -0
- package/Types/Permission.ts +311 -0
- package/Types/Probe/ProbeMonitorResponse.ts +2 -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 +38 -1
- package/Utils/Monitor/MonitorMetricType.ts +2 -1
- package/build/dist/Models/DatabaseModels/Incident.js +78 -0
- package/build/dist/Models/DatabaseModels/Incident.js.map +1 -1
- package/build/dist/Models/DatabaseModels/IncidentEpisode.js +1250 -0
- package/build/dist/Models/DatabaseModels/IncidentEpisode.js.map +1 -0
- package/build/dist/Models/DatabaseModels/IncidentEpisodeFeed.js +555 -0
- package/build/dist/Models/DatabaseModels/IncidentEpisodeFeed.js.map +1 -0
- package/build/dist/Models/DatabaseModels/IncidentEpisodeInternalNote.js +467 -0
- package/build/dist/Models/DatabaseModels/IncidentEpisodeInternalNote.js.map +1 -0
- package/build/dist/Models/DatabaseModels/IncidentEpisodeMember.js +607 -0
- package/build/dist/Models/DatabaseModels/IncidentEpisodeMember.js.map +1 -0
- package/build/dist/Models/DatabaseModels/IncidentEpisodeOwnerTeam.js +437 -0
- package/build/dist/Models/DatabaseModels/IncidentEpisodeOwnerTeam.js.map +1 -0
- package/build/dist/Models/DatabaseModels/IncidentEpisodeOwnerUser.js +436 -0
- package/build/dist/Models/DatabaseModels/IncidentEpisodeOwnerUser.js.map +1 -0
- package/build/dist/Models/DatabaseModels/IncidentEpisodeStateTimeline.js +546 -0
- package/build/dist/Models/DatabaseModels/IncidentEpisodeStateTimeline.js.map +1 -0
- package/build/dist/Models/DatabaseModels/IncidentGroupingRule.js +1437 -0
- package/build/dist/Models/DatabaseModels/IncidentGroupingRule.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/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/IncidentEpisodeAPI.js +97 -0
- package/build/dist/Server/API/IncidentEpisodeAPI.js.map +1 -0
- 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 +30 -10
- package/build/dist/Server/API/UserOnCallLogTimelineAPI.js.map +1 -1
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1769626069479-MigrationName.js +256 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1769626069479-MigrationName.js.map +1 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1769629928240-MigrationName.js +96 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1769629928240-MigrationName.js.map +1 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1769676117342-RenameEvaluateOverTimeInCriteriaFilter.js +25 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1769676117342-RenameEvaluateOverTimeInCriteriaFilter.js.map +1 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/Index.js +6 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/Index.js.map +1 -1
- package/build/dist/Server/Services/BillingService.js +1 -2
- package/build/dist/Server/Services/BillingService.js.map +1 -1
- package/build/dist/Server/Services/CallService.js.map +1 -1
- package/build/dist/Server/Services/IncidentEpisodeFeedService.js +83 -0
- package/build/dist/Server/Services/IncidentEpisodeFeedService.js.map +1 -0
- package/build/dist/Server/Services/IncidentEpisodeInternalNoteService.js +70 -0
- package/build/dist/Server/Services/IncidentEpisodeInternalNoteService.js.map +1 -0
- package/build/dist/Server/Services/IncidentEpisodeMemberService.js +298 -0
- package/build/dist/Server/Services/IncidentEpisodeMemberService.js.map +1 -0
- package/build/dist/Server/Services/IncidentEpisodeOwnerTeamService.js +9 -0
- package/build/dist/Server/Services/IncidentEpisodeOwnerTeamService.js.map +1 -0
- package/build/dist/Server/Services/IncidentEpisodeOwnerUserService.js +9 -0
- package/build/dist/Server/Services/IncidentEpisodeOwnerUserService.js.map +1 -0
- package/build/dist/Server/Services/IncidentEpisodeService.js +933 -0
- package/build/dist/Server/Services/IncidentEpisodeService.js.map +1 -0
- package/build/dist/Server/Services/IncidentEpisodeStateTimelineService.js +498 -0
- package/build/dist/Server/Services/IncidentEpisodeStateTimelineService.js.map +1 -0
- package/build/dist/Server/Services/IncidentGroupingEngineService.js +799 -0
- package/build/dist/Server/Services/IncidentGroupingEngineService.js.map +1 -0
- package/build/dist/Server/Services/IncidentGroupingRuleService.js +13 -0
- package/build/dist/Server/Services/IncidentGroupingRuleService.js.map +1 -0
- package/build/dist/Server/Services/IncidentService.js +10 -0
- package/build/dist/Server/Services/IncidentService.js.map +1 -1
- package/build/dist/Server/Services/Index.js +16 -0
- package/build/dist/Server/Services/Index.js.map +1 -1
- package/build/dist/Server/Services/MailService.js.map +1 -1
- package/build/dist/Server/Services/MonitorService.js +9 -1
- package/build/dist/Server/Services/MonitorService.js.map +1 -1
- package/build/dist/Server/Services/OnCallDutyPolicyEscalationRuleService.js +10 -0
- package/build/dist/Server/Services/OnCallDutyPolicyEscalationRuleService.js.map +1 -1
- package/build/dist/Server/Services/OnCallDutyPolicyExecutionLogService.js +48 -2
- package/build/dist/Server/Services/OnCallDutyPolicyExecutionLogService.js.map +1 -1
- package/build/dist/Server/Services/OnCallDutyPolicyExecutionLogTimelineService.js +20 -1
- package/build/dist/Server/Services/OnCallDutyPolicyExecutionLogTimelineService.js.map +1 -1
- package/build/dist/Server/Services/OnCallDutyPolicyService.js +8 -0
- package/build/dist/Server/Services/OnCallDutyPolicyService.js.map +1 -1
- package/build/dist/Server/Services/SmsService.js.map +1 -1
- package/build/dist/Server/Services/UserNotificationRuleService.js +39 -2
- 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 +35 -3
- package/build/dist/Server/Services/UserOnCallLogService.js.map +1 -1
- package/build/dist/Server/Services/WhatsAppService.js.map +1 -1
- package/build/dist/Server/Services/WorkspaceNotificationLogService.js +12 -0
- package/build/dist/Server/Services/WorkspaceNotificationLogService.js.map +1 -1
- package/build/dist/Server/Services/WorkspaceNotificationRuleService.js +95 -1
- package/build/dist/Server/Services/WorkspaceNotificationRuleService.js.map +1 -1
- package/build/dist/Server/Utils/AI/IncidentEpisodeAIContextBuilder.js +402 -0
- package/build/dist/Server/Utils/AI/IncidentEpisodeAIContextBuilder.js.map +1 -0
- package/build/dist/Server/Utils/Monitor/Criteria/APIRequestCriteria.js +1 -1
- package/build/dist/Server/Utils/Monitor/Criteria/CompareCriteria.js +1 -1
- package/build/dist/Server/Utils/Monitor/Criteria/IncomingRequestCriteria.js +1 -1
- package/build/dist/Server/Utils/Monitor/Criteria/SSLMonitorCriteria.js +1 -1
- package/build/dist/Server/Utils/Monitor/Criteria/ServerMonitorCriteria.js +2 -2
- package/build/dist/Server/Utils/Monitor/Criteria/SnmpMonitorCriteria.js +135 -0
- package/build/dist/Server/Utils/Monitor/Criteria/SnmpMonitorCriteria.js.map +1 -0
- package/build/dist/Server/Utils/Monitor/MonitorCriteriaEvaluator.js +10 -0
- package/build/dist/Server/Utils/Monitor/MonitorCriteriaEvaluator.js.map +1 -1
- package/build/dist/Server/Utils/Monitor/MonitorCriteriaExpectationBuilder.js +1 -1
- package/build/dist/Server/Utils/Monitor/MonitorTemplateUtil.js +26 -0
- package/build/dist/Server/Utils/Monitor/MonitorTemplateUtil.js.map +1 -1
- package/build/dist/Server/Utils/PushNotificationUtil.js +20 -0
- 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/IncidentEpisode.js +547 -0
- package/build/dist/Server/Utils/Workspace/MicrosoftTeams/Actions/IncidentEpisode.js.map +1 -0
- package/build/dist/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeams.js +15 -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/IncidentEpisode.js +651 -0
- package/build/dist/Server/Utils/Workspace/Slack/Actions/IncidentEpisode.js.map +1 -0
- package/build/dist/Server/Utils/Workspace/Slack/Messages/IncidentEpisode.js +100 -0
- package/build/dist/Server/Utils/Workspace/Slack/Messages/IncidentEpisode.js.map +1 -0
- package/build/dist/Server/Utils/Workspace/WorkspaceMessages/IncidentEpisode.js +70 -0
- package/build/dist/Server/Utils/Workspace/WorkspaceMessages/IncidentEpisode.js.map +1 -0
- package/build/dist/Types/Email/EmailTemplateType.js +5 -0
- package/build/dist/Types/Email/EmailTemplateType.js.map +1 -1
- package/build/dist/Types/Monitor/CriteriaFilter.js +16 -3
- package/build/dist/Types/Monitor/CriteriaFilter.js.map +1 -1
- package/build/dist/Types/Monitor/MonitorCriteriaInstance.js +62 -0
- package/build/dist/Types/Monitor/MonitorCriteriaInstance.js.map +1 -1
- package/build/dist/Types/Monitor/MonitorStep.js +26 -0
- package/build/dist/Types/Monitor/MonitorStep.js.map +1 -1
- package/build/dist/Types/Monitor/MonitorStepSnmpMonitor.js +77 -0
- package/build/dist/Types/Monitor/MonitorStepSnmpMonitor.js.map +1 -0
- package/build/dist/Types/Monitor/MonitorType.js +13 -2
- package/build/dist/Types/Monitor/MonitorType.js.map +1 -1
- package/build/dist/Types/Monitor/SnmpMonitor/SnmpAuthProtocol.js +9 -0
- package/build/dist/Types/Monitor/SnmpMonitor/SnmpAuthProtocol.js.map +1 -0
- package/build/dist/Types/Monitor/SnmpMonitor/SnmpDataType.js +22 -0
- package/build/dist/Types/Monitor/SnmpMonitor/SnmpDataType.js.map +1 -0
- package/build/dist/Types/Monitor/SnmpMonitor/SnmpMonitorResponse.js +2 -0
- package/build/dist/Types/Monitor/SnmpMonitor/SnmpMonitorResponse.js.map +1 -0
- package/build/dist/Types/Monitor/SnmpMonitor/SnmpOid.js +55 -0
- package/build/dist/Types/Monitor/SnmpMonitor/SnmpOid.js.map +1 -0
- package/build/dist/Types/Monitor/SnmpMonitor/SnmpPrivProtocol.js +8 -0
- package/build/dist/Types/Monitor/SnmpMonitor/SnmpPrivProtocol.js.map +1 -0
- package/build/dist/Types/Monitor/SnmpMonitor/SnmpSecurityLevel.js +8 -0
- package/build/dist/Types/Monitor/SnmpMonitor/SnmpSecurityLevel.js.map +1 -0
- package/build/dist/Types/Monitor/SnmpMonitor/SnmpV3Auth.js +2 -0
- package/build/dist/Types/Monitor/SnmpMonitor/SnmpV3Auth.js.map +1 -0
- package/build/dist/Types/Monitor/SnmpMonitor/SnmpVersion.js +8 -0
- package/build/dist/Types/Monitor/SnmpMonitor/SnmpVersion.js.map +1 -0
- 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 +33 -1
- package/build/dist/Types/Workspace/NotificationRules/NotificationRuleCondition.js.map +1 -1
- package/build/dist/Utils/Monitor/MonitorMetricType.js +2 -1
- package/build/dist/Utils/Monitor/MonitorMetricType.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,651 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
+
};
|
|
10
|
+
import BadDataException from "../../../../../Types/Exception/BadDataException";
|
|
11
|
+
import ObjectID from "../../../../../Types/ObjectID";
|
|
12
|
+
import IncidentEpisodeService from "../../../../Services/IncidentEpisodeService";
|
|
13
|
+
import SlackUtil from "../Slack";
|
|
14
|
+
import SlackActionType, { PrivateNoteEmojis } from "./ActionTypes";
|
|
15
|
+
import Response from "../../../Response";
|
|
16
|
+
import IncidentEpisodeInternalNoteService from "../../../../Services/IncidentEpisodeInternalNoteService";
|
|
17
|
+
import OnCallDutyPolicyService from "../../../../Services/OnCallDutyPolicyService";
|
|
18
|
+
import { LIMIT_PER_PROJECT } from "../../../../../Types/Database/LimitMax";
|
|
19
|
+
import UserNotificationEventType from "../../../../../Types/UserNotification/UserNotificationEventType";
|
|
20
|
+
import IncidentStateService from "../../../../Services/IncidentStateService";
|
|
21
|
+
import logger from "../../../Logger";
|
|
22
|
+
import AccessTokenService from "../../../../Services/AccessTokenService";
|
|
23
|
+
import CaptureSpan from "../../../Telemetry/CaptureSpan";
|
|
24
|
+
import WorkspaceNotificationLogService from "../../../../Services/WorkspaceNotificationLogService";
|
|
25
|
+
import WorkspaceUserAuthTokenService from "../../../../Services/WorkspaceUserAuthTokenService";
|
|
26
|
+
import WorkspaceType from "../../../../../Types/Workspace/WorkspaceType";
|
|
27
|
+
import WorkspaceProjectAuthTokenService from "../../../../Services/WorkspaceProjectAuthTokenService";
|
|
28
|
+
export default class SlackIncidentEpisodeActions {
|
|
29
|
+
static isIncidentEpisodeAction(data) {
|
|
30
|
+
const { actionType } = data;
|
|
31
|
+
switch (actionType) {
|
|
32
|
+
case SlackActionType.AcknowledgeIncidentEpisode:
|
|
33
|
+
case SlackActionType.ResolveIncidentEpisode:
|
|
34
|
+
case SlackActionType.ViewAddIncidentEpisodeNote:
|
|
35
|
+
case SlackActionType.SubmitIncidentEpisodeNote:
|
|
36
|
+
case SlackActionType.ViewChangeIncidentEpisodeState:
|
|
37
|
+
case SlackActionType.SubmitChangeIncidentEpisodeState:
|
|
38
|
+
case SlackActionType.ViewExecuteIncidentEpisodeOnCallPolicy:
|
|
39
|
+
case SlackActionType.SubmitExecuteIncidentEpisodeOnCallPolicy:
|
|
40
|
+
case SlackActionType.ViewIncidentEpisode:
|
|
41
|
+
return true;
|
|
42
|
+
default:
|
|
43
|
+
return false;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
static async acknowledgeIncidentEpisode(data) {
|
|
47
|
+
const { slackRequest, req, res } = data;
|
|
48
|
+
const { botUserId, userId, projectAuthToken, slackUsername } = slackRequest;
|
|
49
|
+
const { actionValue } = data.action;
|
|
50
|
+
if (!actionValue) {
|
|
51
|
+
return Response.sendErrorResponse(req, res, new BadDataException("Invalid Incident Episode ID"));
|
|
52
|
+
}
|
|
53
|
+
if (!userId) {
|
|
54
|
+
return Response.sendErrorResponse(req, res, new BadDataException("Invalid User ID"));
|
|
55
|
+
}
|
|
56
|
+
if (!projectAuthToken) {
|
|
57
|
+
return Response.sendErrorResponse(req, res, new BadDataException("Invalid Project Auth Token"));
|
|
58
|
+
}
|
|
59
|
+
if (!botUserId) {
|
|
60
|
+
return Response.sendErrorResponse(req, res, new BadDataException("Invalid Bot User ID"));
|
|
61
|
+
}
|
|
62
|
+
if (data.action.actionType === SlackActionType.AcknowledgeIncidentEpisode) {
|
|
63
|
+
const episodeId = new ObjectID(actionValue);
|
|
64
|
+
// We send this early let slack know we're ok. We'll do the rest in the background.
|
|
65
|
+
Response.sendJsonObjectResponse(req, res, {
|
|
66
|
+
response_action: "clear",
|
|
67
|
+
});
|
|
68
|
+
const isAlreadyAcknowledged = await IncidentEpisodeService.isEpisodeAcknowledged({
|
|
69
|
+
episodeId: episodeId,
|
|
70
|
+
});
|
|
71
|
+
if (isAlreadyAcknowledged) {
|
|
72
|
+
// send a message to the channel visible to user, that the episode has already been acknowledged.
|
|
73
|
+
const markdwonPayload = {
|
|
74
|
+
_type: "WorkspacePayloadMarkdown",
|
|
75
|
+
text: `@${slackUsername}, unfortunately you cannot acknowledge the **[Incident Episode](${await IncidentEpisodeService.getEpisodeLinkInDashboard(slackRequest.projectId, episodeId)})**. It has already been acknowledged.`,
|
|
76
|
+
};
|
|
77
|
+
await SlackUtil.sendDirectMessageToUser({
|
|
78
|
+
messageBlocks: [markdwonPayload],
|
|
79
|
+
authToken: projectAuthToken,
|
|
80
|
+
workspaceUserId: slackRequest.slackUserId,
|
|
81
|
+
});
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
await IncidentEpisodeService.acknowledgeEpisode(episodeId, userId);
|
|
85
|
+
// Log the button interaction
|
|
86
|
+
if (slackRequest.projectId) {
|
|
87
|
+
try {
|
|
88
|
+
const logData = {
|
|
89
|
+
projectId: slackRequest.projectId,
|
|
90
|
+
workspaceType: WorkspaceType.Slack,
|
|
91
|
+
userId: userId,
|
|
92
|
+
buttonAction: "acknowledge_incident_episode",
|
|
93
|
+
};
|
|
94
|
+
if (slackRequest.slackChannelId) {
|
|
95
|
+
logData.channelId = slackRequest.slackChannelId;
|
|
96
|
+
}
|
|
97
|
+
logData.incidentEpisodeId = episodeId;
|
|
98
|
+
await WorkspaceNotificationLogService.logButtonPressed(logData, {
|
|
99
|
+
isRoot: true,
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
catch (err) {
|
|
103
|
+
logger.error("Error logging button interaction:");
|
|
104
|
+
logger.error(err);
|
|
105
|
+
// Don't throw the error, just log it so the main flow continues
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
// invalid action type.
|
|
111
|
+
return Response.sendErrorResponse(req, res, new BadDataException("Invalid Action Type"));
|
|
112
|
+
}
|
|
113
|
+
static async resolveIncidentEpisode(data) {
|
|
114
|
+
const { slackRequest, req, res } = data;
|
|
115
|
+
const { botUserId, userId, projectAuthToken, slackUsername } = slackRequest;
|
|
116
|
+
const { actionValue } = data.action;
|
|
117
|
+
if (!actionValue) {
|
|
118
|
+
return Response.sendErrorResponse(req, res, new BadDataException("Invalid Incident Episode ID"));
|
|
119
|
+
}
|
|
120
|
+
if (!userId) {
|
|
121
|
+
return Response.sendErrorResponse(req, res, new BadDataException("Invalid User ID"));
|
|
122
|
+
}
|
|
123
|
+
if (!projectAuthToken) {
|
|
124
|
+
return Response.sendErrorResponse(req, res, new BadDataException("Invalid Project Auth Token"));
|
|
125
|
+
}
|
|
126
|
+
if (!botUserId) {
|
|
127
|
+
return Response.sendErrorResponse(req, res, new BadDataException("Invalid Bot User ID"));
|
|
128
|
+
}
|
|
129
|
+
if (data.action.actionType === SlackActionType.ResolveIncidentEpisode) {
|
|
130
|
+
const episodeId = new ObjectID(actionValue);
|
|
131
|
+
// We send this early let slack know we're ok. We'll do the rest in the background.
|
|
132
|
+
Response.sendJsonObjectResponse(req, res, {
|
|
133
|
+
response_action: "clear",
|
|
134
|
+
});
|
|
135
|
+
const isAlreadyResolved = await IncidentEpisodeService.isEpisodeResolved(episodeId);
|
|
136
|
+
if (isAlreadyResolved) {
|
|
137
|
+
// send a message to the channel visible to user, that the episode has already been Resolved.
|
|
138
|
+
const markdwonPayload = {
|
|
139
|
+
_type: "WorkspacePayloadMarkdown",
|
|
140
|
+
text: `@${slackUsername}, unfortunately you cannot resolve the **[Incident Episode](${await IncidentEpisodeService.getEpisodeLinkInDashboard(slackRequest.projectId, episodeId)})**. It has already been resolved.`,
|
|
141
|
+
};
|
|
142
|
+
await SlackUtil.sendDirectMessageToUser({
|
|
143
|
+
messageBlocks: [markdwonPayload],
|
|
144
|
+
authToken: projectAuthToken,
|
|
145
|
+
workspaceUserId: slackRequest.slackUserId,
|
|
146
|
+
});
|
|
147
|
+
return;
|
|
148
|
+
}
|
|
149
|
+
await IncidentEpisodeService.resolveEpisode(episodeId, userId);
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
152
|
+
// invalid action type.
|
|
153
|
+
return Response.sendErrorResponse(req, res, new BadDataException("Invalid Action Type"));
|
|
154
|
+
}
|
|
155
|
+
static async viewExecuteOnCallPolicy(data) {
|
|
156
|
+
const { req, res } = data;
|
|
157
|
+
const { actionValue } = data.action;
|
|
158
|
+
if (!actionValue) {
|
|
159
|
+
return Response.sendErrorResponse(req, res, new BadDataException("Invalid Incident Episode ID"));
|
|
160
|
+
}
|
|
161
|
+
// We send this early let slack know we're ok. We'll do the rest in the background.
|
|
162
|
+
Response.sendJsonObjectResponse(req, res, {
|
|
163
|
+
response_action: "clear",
|
|
164
|
+
});
|
|
165
|
+
const onCallPolicies = await OnCallDutyPolicyService.findBy({
|
|
166
|
+
query: {
|
|
167
|
+
projectId: data.slackRequest.projectId,
|
|
168
|
+
},
|
|
169
|
+
select: {
|
|
170
|
+
name: true,
|
|
171
|
+
},
|
|
172
|
+
props: {
|
|
173
|
+
isRoot: true,
|
|
174
|
+
},
|
|
175
|
+
limit: LIMIT_PER_PROJECT,
|
|
176
|
+
skip: 0,
|
|
177
|
+
});
|
|
178
|
+
const dropdownOption = onCallPolicies
|
|
179
|
+
.map((policy) => {
|
|
180
|
+
var _a;
|
|
181
|
+
return {
|
|
182
|
+
label: policy.name || "",
|
|
183
|
+
value: ((_a = policy._id) === null || _a === void 0 ? void 0 : _a.toString()) || "",
|
|
184
|
+
};
|
|
185
|
+
})
|
|
186
|
+
.filter((option) => {
|
|
187
|
+
return option.label !== "" || option.value !== "";
|
|
188
|
+
});
|
|
189
|
+
const onCallPolicyDropdown = {
|
|
190
|
+
_type: "WorkspaceDropdownBlock",
|
|
191
|
+
label: "On Call Policy",
|
|
192
|
+
blockId: "onCallPolicy",
|
|
193
|
+
placeholder: "Select On Call Policy",
|
|
194
|
+
options: dropdownOption,
|
|
195
|
+
};
|
|
196
|
+
const modalBlock = {
|
|
197
|
+
_type: "WorkspaceModalBlock",
|
|
198
|
+
title: "Execute On Call Policy",
|
|
199
|
+
submitButtonTitle: "Submit",
|
|
200
|
+
cancelButtonTitle: "Cancel",
|
|
201
|
+
actionId: SlackActionType.SubmitExecuteIncidentEpisodeOnCallPolicy,
|
|
202
|
+
actionValue: actionValue,
|
|
203
|
+
blocks: [onCallPolicyDropdown],
|
|
204
|
+
};
|
|
205
|
+
await SlackUtil.showModalToUser({
|
|
206
|
+
authToken: data.slackRequest.projectAuthToken,
|
|
207
|
+
modalBlock: modalBlock,
|
|
208
|
+
triggerId: data.slackRequest.triggerId,
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
static async viewChangeIncidentEpisodeState(data) {
|
|
212
|
+
const { req, res } = data;
|
|
213
|
+
const { actionValue } = data.action;
|
|
214
|
+
if (!actionValue) {
|
|
215
|
+
return Response.sendErrorResponse(req, res, new BadDataException("Invalid Incident Episode ID"));
|
|
216
|
+
}
|
|
217
|
+
// We send this early let slack know we're ok. We'll do the rest in the background.
|
|
218
|
+
Response.sendJsonObjectResponse(req, res, {
|
|
219
|
+
response_action: "clear",
|
|
220
|
+
});
|
|
221
|
+
// Incident Episodes use incident states
|
|
222
|
+
const incidentStates = await IncidentStateService.getAllIncidentStates({
|
|
223
|
+
projectId: data.slackRequest.projectId,
|
|
224
|
+
props: {
|
|
225
|
+
isRoot: true,
|
|
226
|
+
},
|
|
227
|
+
});
|
|
228
|
+
const dropdownOptions = incidentStates
|
|
229
|
+
.map((state) => {
|
|
230
|
+
var _a;
|
|
231
|
+
return {
|
|
232
|
+
label: state.name || "",
|
|
233
|
+
value: ((_a = state._id) === null || _a === void 0 ? void 0 : _a.toString()) || "",
|
|
234
|
+
};
|
|
235
|
+
})
|
|
236
|
+
.filter((option) => {
|
|
237
|
+
return option.label !== "" || option.value !== "";
|
|
238
|
+
});
|
|
239
|
+
const statePickerDropdown = {
|
|
240
|
+
_type: "WorkspaceDropdownBlock",
|
|
241
|
+
label: "Episode State",
|
|
242
|
+
blockId: "episodeState",
|
|
243
|
+
placeholder: "Select Episode State",
|
|
244
|
+
options: dropdownOptions,
|
|
245
|
+
};
|
|
246
|
+
const modalBlock = {
|
|
247
|
+
_type: "WorkspaceModalBlock",
|
|
248
|
+
title: "Change Episode State",
|
|
249
|
+
submitButtonTitle: "Submit",
|
|
250
|
+
cancelButtonTitle: "Cancel",
|
|
251
|
+
actionId: SlackActionType.SubmitChangeIncidentEpisodeState,
|
|
252
|
+
actionValue: actionValue,
|
|
253
|
+
blocks: [statePickerDropdown],
|
|
254
|
+
};
|
|
255
|
+
await SlackUtil.showModalToUser({
|
|
256
|
+
authToken: data.slackRequest.projectAuthToken,
|
|
257
|
+
modalBlock: modalBlock,
|
|
258
|
+
triggerId: data.slackRequest.triggerId,
|
|
259
|
+
});
|
|
260
|
+
}
|
|
261
|
+
static async submitChangeIncidentEpisodeState(data) {
|
|
262
|
+
const { req, res } = data;
|
|
263
|
+
const { actionValue } = data.action;
|
|
264
|
+
if (!actionValue) {
|
|
265
|
+
return Response.sendErrorResponse(req, res, new BadDataException("Invalid Incident Episode ID"));
|
|
266
|
+
}
|
|
267
|
+
// We send this early let slack know we're ok. We'll do the rest in the background.
|
|
268
|
+
Response.sendJsonObjectResponse(req, res, {
|
|
269
|
+
response_action: "clear",
|
|
270
|
+
});
|
|
271
|
+
if (!data.slackRequest.viewValues ||
|
|
272
|
+
!data.slackRequest.viewValues["episodeState"]) {
|
|
273
|
+
return Response.sendErrorResponse(req, res, new BadDataException("Invalid View Values"));
|
|
274
|
+
}
|
|
275
|
+
const episodeId = new ObjectID(actionValue);
|
|
276
|
+
const stateString = data.slackRequest.viewValues["episodeState"].toString();
|
|
277
|
+
const stateId = new ObjectID(stateString);
|
|
278
|
+
await IncidentEpisodeService.updateOneById({
|
|
279
|
+
id: episodeId,
|
|
280
|
+
data: {
|
|
281
|
+
currentIncidentStateId: stateId,
|
|
282
|
+
},
|
|
283
|
+
props: await AccessTokenService.getDatabaseCommonInteractionPropsByUserAndProject({
|
|
284
|
+
userId: data.slackRequest.userId,
|
|
285
|
+
projectId: data.slackRequest.projectId,
|
|
286
|
+
}),
|
|
287
|
+
});
|
|
288
|
+
// Log the button interaction
|
|
289
|
+
if (data.slackRequest.projectId && data.slackRequest.userId) {
|
|
290
|
+
try {
|
|
291
|
+
const logData = {
|
|
292
|
+
projectId: data.slackRequest.projectId,
|
|
293
|
+
workspaceType: WorkspaceType.Slack,
|
|
294
|
+
userId: data.slackRequest.userId,
|
|
295
|
+
buttonAction: "change_incident_episode_state",
|
|
296
|
+
};
|
|
297
|
+
if (data.slackRequest.slackChannelId) {
|
|
298
|
+
logData.channelId = data.slackRequest.slackChannelId;
|
|
299
|
+
}
|
|
300
|
+
logData.incidentEpisodeId = episodeId;
|
|
301
|
+
await WorkspaceNotificationLogService.logButtonPressed(logData, {
|
|
302
|
+
isRoot: true,
|
|
303
|
+
});
|
|
304
|
+
}
|
|
305
|
+
catch (err) {
|
|
306
|
+
logger.error("Error logging button interaction:");
|
|
307
|
+
logger.error(err);
|
|
308
|
+
// Don't throw the error, just log it so the main flow continues
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
static async executeOnCallPolicy(data) {
|
|
313
|
+
const { slackRequest, req, res } = data;
|
|
314
|
+
const { botUserId, userId, projectAuthToken, slackUsername } = slackRequest;
|
|
315
|
+
const { actionValue } = data.action;
|
|
316
|
+
if (!actionValue) {
|
|
317
|
+
return Response.sendErrorResponse(req, res, new BadDataException("Invalid Incident Episode ID"));
|
|
318
|
+
}
|
|
319
|
+
if (!userId) {
|
|
320
|
+
return Response.sendErrorResponse(req, res, new BadDataException("Invalid User ID"));
|
|
321
|
+
}
|
|
322
|
+
if (!projectAuthToken) {
|
|
323
|
+
return Response.sendErrorResponse(req, res, new BadDataException("Invalid Project Auth Token"));
|
|
324
|
+
}
|
|
325
|
+
if (!botUserId) {
|
|
326
|
+
return Response.sendErrorResponse(req, res, new BadDataException("Invalid Bot User ID"));
|
|
327
|
+
}
|
|
328
|
+
if (data.action.actionType ===
|
|
329
|
+
SlackActionType.SubmitExecuteIncidentEpisodeOnCallPolicy) {
|
|
330
|
+
const episodeId = new ObjectID(actionValue);
|
|
331
|
+
// We send this early let slack know we're ok. We'll do the rest in the background.
|
|
332
|
+
Response.sendJsonObjectResponse(req, res, {
|
|
333
|
+
response_action: "clear",
|
|
334
|
+
});
|
|
335
|
+
const isAlreadyResolved = await IncidentEpisodeService.isEpisodeResolved(episodeId);
|
|
336
|
+
if (isAlreadyResolved) {
|
|
337
|
+
// send a message to the channel visible to user, that the episode has already been Resolved.
|
|
338
|
+
const markdwonPayload = {
|
|
339
|
+
_type: "WorkspacePayloadMarkdown",
|
|
340
|
+
text: `@${slackUsername}, unfortunately you cannot execute the on-call policy for **[Incident Episode](${await IncidentEpisodeService.getEpisodeLinkInDashboard(slackRequest.projectId, episodeId)})**. It has already been resolved.`,
|
|
341
|
+
};
|
|
342
|
+
await SlackUtil.sendDirectMessageToUser({
|
|
343
|
+
messageBlocks: [markdwonPayload],
|
|
344
|
+
authToken: projectAuthToken,
|
|
345
|
+
workspaceUserId: slackRequest.slackUserId,
|
|
346
|
+
});
|
|
347
|
+
return;
|
|
348
|
+
}
|
|
349
|
+
if (!data.slackRequest.viewValues ||
|
|
350
|
+
!data.slackRequest.viewValues["onCallPolicy"]) {
|
|
351
|
+
return Response.sendErrorResponse(req, res, new BadDataException("Invalid View Values"));
|
|
352
|
+
}
|
|
353
|
+
const onCallPolicyString = data.slackRequest.viewValues["onCallPolicy"].toString();
|
|
354
|
+
// get the on-call policy id.
|
|
355
|
+
const onCallPolicyId = new ObjectID(onCallPolicyString);
|
|
356
|
+
await OnCallDutyPolicyService.executePolicy(onCallPolicyId, {
|
|
357
|
+
triggeredByIncidentEpisodeId: episodeId,
|
|
358
|
+
userNotificationEventType: UserNotificationEventType.IncidentEpisodeCreated,
|
|
359
|
+
});
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
static async submitIncidentEpisodeNote(data) {
|
|
363
|
+
const { req, res } = data;
|
|
364
|
+
const { actionValue } = data.action;
|
|
365
|
+
if (!actionValue) {
|
|
366
|
+
return Response.sendErrorResponse(req, res, new BadDataException("Invalid Incident Episode ID"));
|
|
367
|
+
}
|
|
368
|
+
if (!data.slackRequest.viewValues) {
|
|
369
|
+
return Response.sendErrorResponse(req, res, new BadDataException("Invalid View Values"));
|
|
370
|
+
}
|
|
371
|
+
if (!data.slackRequest.viewValues["note"]) {
|
|
372
|
+
return Response.sendErrorResponse(req, res, new BadDataException("Invalid Note"));
|
|
373
|
+
}
|
|
374
|
+
const episodeId = new ObjectID(actionValue);
|
|
375
|
+
const note = data.slackRequest.viewValues["note"].toString();
|
|
376
|
+
// send empty response.
|
|
377
|
+
Response.sendJsonObjectResponse(req, res, {
|
|
378
|
+
response_action: "clear",
|
|
379
|
+
});
|
|
380
|
+
await IncidentEpisodeInternalNoteService.addNote({
|
|
381
|
+
incidentEpisodeId: episodeId,
|
|
382
|
+
note: note || "",
|
|
383
|
+
projectId: data.slackRequest.projectId,
|
|
384
|
+
userId: data.slackRequest.userId,
|
|
385
|
+
});
|
|
386
|
+
}
|
|
387
|
+
static async viewAddIncidentEpisodeNote(data) {
|
|
388
|
+
const { req, res } = data;
|
|
389
|
+
const { actionValue } = data.action;
|
|
390
|
+
if (!actionValue) {
|
|
391
|
+
return Response.sendErrorResponse(req, res, new BadDataException("Invalid Incident Episode ID"));
|
|
392
|
+
}
|
|
393
|
+
// We send this early let slack know we're ok. We'll do the rest in the background.
|
|
394
|
+
Response.sendJsonObjectResponse(req, res, {
|
|
395
|
+
response_action: "clear",
|
|
396
|
+
});
|
|
397
|
+
const noteTextArea = {
|
|
398
|
+
_type: "WorkspaceTextAreaBlock",
|
|
399
|
+
label: "Note",
|
|
400
|
+
blockId: "note",
|
|
401
|
+
placeholder: "Note",
|
|
402
|
+
description: "Please type in plain text or markdown.",
|
|
403
|
+
};
|
|
404
|
+
const modalBlock = {
|
|
405
|
+
_type: "WorkspaceModalBlock",
|
|
406
|
+
title: "Add Note",
|
|
407
|
+
submitButtonTitle: "Submit",
|
|
408
|
+
cancelButtonTitle: "Cancel",
|
|
409
|
+
actionId: SlackActionType.SubmitIncidentEpisodeNote,
|
|
410
|
+
actionValue: actionValue,
|
|
411
|
+
blocks: [noteTextArea],
|
|
412
|
+
};
|
|
413
|
+
await SlackUtil.showModalToUser({
|
|
414
|
+
authToken: data.slackRequest.projectAuthToken,
|
|
415
|
+
modalBlock: modalBlock,
|
|
416
|
+
triggerId: data.slackRequest.triggerId,
|
|
417
|
+
});
|
|
418
|
+
}
|
|
419
|
+
static async handleIncidentEpisodeAction(data) {
|
|
420
|
+
const actionType = data.action.actionType;
|
|
421
|
+
if (actionType === SlackActionType.AcknowledgeIncidentEpisode) {
|
|
422
|
+
return await this.acknowledgeIncidentEpisode(data);
|
|
423
|
+
}
|
|
424
|
+
if (actionType === SlackActionType.ResolveIncidentEpisode) {
|
|
425
|
+
return await this.resolveIncidentEpisode(data);
|
|
426
|
+
}
|
|
427
|
+
if (actionType === SlackActionType.ViewAddIncidentEpisodeNote) {
|
|
428
|
+
return await this.viewAddIncidentEpisodeNote(data);
|
|
429
|
+
}
|
|
430
|
+
if (actionType === SlackActionType.SubmitIncidentEpisodeNote) {
|
|
431
|
+
return await this.submitIncidentEpisodeNote(data);
|
|
432
|
+
}
|
|
433
|
+
if (actionType === SlackActionType.ViewExecuteIncidentEpisodeOnCallPolicy) {
|
|
434
|
+
return await this.viewExecuteOnCallPolicy(data);
|
|
435
|
+
}
|
|
436
|
+
if (actionType === SlackActionType.SubmitExecuteIncidentEpisodeOnCallPolicy) {
|
|
437
|
+
return await this.executeOnCallPolicy(data);
|
|
438
|
+
}
|
|
439
|
+
if (actionType === SlackActionType.ViewChangeIncidentEpisodeState) {
|
|
440
|
+
return await this.viewChangeIncidentEpisodeState(data);
|
|
441
|
+
}
|
|
442
|
+
if (actionType === SlackActionType.SubmitChangeIncidentEpisodeState) {
|
|
443
|
+
return await this.submitChangeIncidentEpisodeState(data);
|
|
444
|
+
}
|
|
445
|
+
if (actionType === SlackActionType.ViewIncidentEpisode) {
|
|
446
|
+
// do nothing. This is just a view episode action.
|
|
447
|
+
return Response.sendJsonObjectResponse(data.req, data.res, {
|
|
448
|
+
response_action: "clear",
|
|
449
|
+
});
|
|
450
|
+
}
|
|
451
|
+
// invalid action type.
|
|
452
|
+
return Response.sendErrorResponse(data.req, data.res, new BadDataException("Invalid Action Type"));
|
|
453
|
+
}
|
|
454
|
+
static async handleEmojiReaction(data) {
|
|
455
|
+
logger.debug("Handling emoji reaction for Incident Episode with data:");
|
|
456
|
+
logger.debug(data);
|
|
457
|
+
const { teamId, reaction, userId, channelId, messageTs } = data;
|
|
458
|
+
// Incident Episodes only support private notes
|
|
459
|
+
const isPrivateNoteEmoji = PrivateNoteEmojis.includes(reaction);
|
|
460
|
+
if (!isPrivateNoteEmoji) {
|
|
461
|
+
logger.debug(`Emoji "${reaction}" is not a supported private note emoji for incident episodes. Ignoring.`);
|
|
462
|
+
return;
|
|
463
|
+
}
|
|
464
|
+
// Get the project auth token using the team ID
|
|
465
|
+
const projectAuth = await WorkspaceProjectAuthTokenService.findOneBy({
|
|
466
|
+
query: {
|
|
467
|
+
workspaceProjectId: teamId,
|
|
468
|
+
},
|
|
469
|
+
select: {
|
|
470
|
+
projectId: true,
|
|
471
|
+
authToken: true,
|
|
472
|
+
},
|
|
473
|
+
props: {
|
|
474
|
+
isRoot: true,
|
|
475
|
+
},
|
|
476
|
+
});
|
|
477
|
+
if (!projectAuth || !projectAuth.projectId || !projectAuth.authToken) {
|
|
478
|
+
logger.debug("No project auth found for team ID. Ignoring emoji reaction.");
|
|
479
|
+
return;
|
|
480
|
+
}
|
|
481
|
+
const projectId = projectAuth.projectId;
|
|
482
|
+
const authToken = projectAuth.authToken;
|
|
483
|
+
// Find the incident episode linked to this channel
|
|
484
|
+
const workspaceLog = await WorkspaceNotificationLogService.findOneBy({
|
|
485
|
+
query: {
|
|
486
|
+
channelId: channelId,
|
|
487
|
+
workspaceType: WorkspaceType.Slack,
|
|
488
|
+
projectId: projectId,
|
|
489
|
+
},
|
|
490
|
+
select: {
|
|
491
|
+
incidentEpisodeId: true,
|
|
492
|
+
},
|
|
493
|
+
props: {
|
|
494
|
+
isRoot: true,
|
|
495
|
+
},
|
|
496
|
+
});
|
|
497
|
+
if (!workspaceLog || !workspaceLog.incidentEpisodeId) {
|
|
498
|
+
logger.debug("No incident episode found linked to this channel. Ignoring emoji reaction.");
|
|
499
|
+
return;
|
|
500
|
+
}
|
|
501
|
+
const episodeId = workspaceLog.incidentEpisodeId;
|
|
502
|
+
// Get the user ID in OneUptime based on Slack user ID
|
|
503
|
+
const userAuth = await WorkspaceUserAuthTokenService.findOneBy({
|
|
504
|
+
query: {
|
|
505
|
+
workspaceUserId: userId,
|
|
506
|
+
workspaceType: WorkspaceType.Slack,
|
|
507
|
+
projectId: projectId,
|
|
508
|
+
},
|
|
509
|
+
select: {
|
|
510
|
+
userId: true,
|
|
511
|
+
},
|
|
512
|
+
props: {
|
|
513
|
+
isRoot: true,
|
|
514
|
+
},
|
|
515
|
+
});
|
|
516
|
+
if (!userAuth || !userAuth.userId) {
|
|
517
|
+
logger.debug("No OneUptime user found for Slack user. Ignoring emoji reaction.");
|
|
518
|
+
return;
|
|
519
|
+
}
|
|
520
|
+
const oneUptimeUserId = userAuth.userId;
|
|
521
|
+
// Fetch the message text using the timestamp
|
|
522
|
+
let messageText = null;
|
|
523
|
+
try {
|
|
524
|
+
messageText = await SlackUtil.getMessageByTimestamp({
|
|
525
|
+
authToken: authToken,
|
|
526
|
+
channelId: channelId,
|
|
527
|
+
messageTs: messageTs,
|
|
528
|
+
});
|
|
529
|
+
}
|
|
530
|
+
catch (err) {
|
|
531
|
+
logger.error("Error fetching message text:");
|
|
532
|
+
logger.error(err);
|
|
533
|
+
return;
|
|
534
|
+
}
|
|
535
|
+
if (!messageText) {
|
|
536
|
+
logger.debug("No message text found. Ignoring emoji reaction.");
|
|
537
|
+
return;
|
|
538
|
+
}
|
|
539
|
+
// Create a unique identifier for this Slack message to prevent duplicate notes
|
|
540
|
+
const postedFromSlackMessageId = `${channelId}:${messageTs}`;
|
|
541
|
+
// Check if a note from this Slack message already exists
|
|
542
|
+
const hasExistingNote = await IncidentEpisodeInternalNoteService.hasNoteFromSlackMessage({
|
|
543
|
+
incidentEpisodeId: episodeId,
|
|
544
|
+
postedFromSlackMessageId: postedFromSlackMessageId,
|
|
545
|
+
});
|
|
546
|
+
if (hasExistingNote) {
|
|
547
|
+
logger.debug("Private note from this Slack message already exists. Skipping duplicate.");
|
|
548
|
+
return;
|
|
549
|
+
}
|
|
550
|
+
// Save as private note
|
|
551
|
+
try {
|
|
552
|
+
await IncidentEpisodeInternalNoteService.addNote({
|
|
553
|
+
incidentEpisodeId: episodeId,
|
|
554
|
+
note: messageText,
|
|
555
|
+
projectId: projectId,
|
|
556
|
+
userId: oneUptimeUserId,
|
|
557
|
+
postedFromSlackMessageId: postedFromSlackMessageId,
|
|
558
|
+
});
|
|
559
|
+
logger.debug("Private note added to incident episode successfully.");
|
|
560
|
+
}
|
|
561
|
+
catch (err) {
|
|
562
|
+
logger.error("Error saving note:");
|
|
563
|
+
logger.error(err);
|
|
564
|
+
return;
|
|
565
|
+
}
|
|
566
|
+
// Send confirmation message as a reply to the original message thread
|
|
567
|
+
try {
|
|
568
|
+
const episodeLink = (await IncidentEpisodeService.getEpisodeLinkInDashboard(projectId, episodeId)).toString();
|
|
569
|
+
const confirmationMessage = `Message saved as *private note* to <${episodeLink}|Incident Episode>.`;
|
|
570
|
+
await SlackUtil.sendMessageToThread({
|
|
571
|
+
authToken: authToken,
|
|
572
|
+
channelId: channelId,
|
|
573
|
+
threadTs: messageTs,
|
|
574
|
+
text: confirmationMessage,
|
|
575
|
+
});
|
|
576
|
+
logger.debug("Confirmation message sent successfully.");
|
|
577
|
+
}
|
|
578
|
+
catch (err) {
|
|
579
|
+
logger.error("Error sending confirmation message:");
|
|
580
|
+
logger.error(err);
|
|
581
|
+
// Don't throw - note was saved successfully, confirmation is best effort
|
|
582
|
+
}
|
|
583
|
+
}
|
|
584
|
+
}
|
|
585
|
+
__decorate([
|
|
586
|
+
CaptureSpan(),
|
|
587
|
+
__metadata("design:type", Function),
|
|
588
|
+
__metadata("design:paramtypes", [Object]),
|
|
589
|
+
__metadata("design:returntype", Boolean)
|
|
590
|
+
], SlackIncidentEpisodeActions, "isIncidentEpisodeAction", null);
|
|
591
|
+
__decorate([
|
|
592
|
+
CaptureSpan(),
|
|
593
|
+
__metadata("design:type", Function),
|
|
594
|
+
__metadata("design:paramtypes", [Object]),
|
|
595
|
+
__metadata("design:returntype", Promise)
|
|
596
|
+
], SlackIncidentEpisodeActions, "acknowledgeIncidentEpisode", null);
|
|
597
|
+
__decorate([
|
|
598
|
+
CaptureSpan(),
|
|
599
|
+
__metadata("design:type", Function),
|
|
600
|
+
__metadata("design:paramtypes", [Object]),
|
|
601
|
+
__metadata("design:returntype", Promise)
|
|
602
|
+
], SlackIncidentEpisodeActions, "resolveIncidentEpisode", null);
|
|
603
|
+
__decorate([
|
|
604
|
+
CaptureSpan(),
|
|
605
|
+
__metadata("design:type", Function),
|
|
606
|
+
__metadata("design:paramtypes", [Object]),
|
|
607
|
+
__metadata("design:returntype", Promise)
|
|
608
|
+
], SlackIncidentEpisodeActions, "viewExecuteOnCallPolicy", null);
|
|
609
|
+
__decorate([
|
|
610
|
+
CaptureSpan(),
|
|
611
|
+
__metadata("design:type", Function),
|
|
612
|
+
__metadata("design:paramtypes", [Object]),
|
|
613
|
+
__metadata("design:returntype", Promise)
|
|
614
|
+
], SlackIncidentEpisodeActions, "viewChangeIncidentEpisodeState", null);
|
|
615
|
+
__decorate([
|
|
616
|
+
CaptureSpan(),
|
|
617
|
+
__metadata("design:type", Function),
|
|
618
|
+
__metadata("design:paramtypes", [Object]),
|
|
619
|
+
__metadata("design:returntype", Promise)
|
|
620
|
+
], SlackIncidentEpisodeActions, "submitChangeIncidentEpisodeState", null);
|
|
621
|
+
__decorate([
|
|
622
|
+
CaptureSpan(),
|
|
623
|
+
__metadata("design:type", Function),
|
|
624
|
+
__metadata("design:paramtypes", [Object]),
|
|
625
|
+
__metadata("design:returntype", Promise)
|
|
626
|
+
], SlackIncidentEpisodeActions, "executeOnCallPolicy", null);
|
|
627
|
+
__decorate([
|
|
628
|
+
CaptureSpan(),
|
|
629
|
+
__metadata("design:type", Function),
|
|
630
|
+
__metadata("design:paramtypes", [Object]),
|
|
631
|
+
__metadata("design:returntype", Promise)
|
|
632
|
+
], SlackIncidentEpisodeActions, "submitIncidentEpisodeNote", null);
|
|
633
|
+
__decorate([
|
|
634
|
+
CaptureSpan(),
|
|
635
|
+
__metadata("design:type", Function),
|
|
636
|
+
__metadata("design:paramtypes", [Object]),
|
|
637
|
+
__metadata("design:returntype", Promise)
|
|
638
|
+
], SlackIncidentEpisodeActions, "viewAddIncidentEpisodeNote", null);
|
|
639
|
+
__decorate([
|
|
640
|
+
CaptureSpan(),
|
|
641
|
+
__metadata("design:type", Function),
|
|
642
|
+
__metadata("design:paramtypes", [Object]),
|
|
643
|
+
__metadata("design:returntype", Promise)
|
|
644
|
+
], SlackIncidentEpisodeActions, "handleIncidentEpisodeAction", null);
|
|
645
|
+
__decorate([
|
|
646
|
+
CaptureSpan(),
|
|
647
|
+
__metadata("design:type", Function),
|
|
648
|
+
__metadata("design:paramtypes", [Object]),
|
|
649
|
+
__metadata("design:returntype", Promise)
|
|
650
|
+
], SlackIncidentEpisodeActions, "handleEmojiReaction", null);
|
|
651
|
+
//# sourceMappingURL=IncidentEpisode.js.map
|