@oneuptime/common 7.0.3786 → 7.0.3815
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/Server/API/SlackAPI.ts +68 -0
- package/Server/Services/AccessTokenService.ts +21 -0
- package/Server/Services/AlertFeedService.ts +98 -0
- package/Server/Services/AlertInternalNoteService.ts +49 -8
- package/Server/Services/AlertOwnerTeamService.ts +50 -2
- package/Server/Services/AlertOwnerUserService.ts +52 -2
- package/Server/Services/AlertService.ts +236 -37
- package/Server/Services/AlertStateService.ts +24 -0
- package/Server/Services/AlertStateTimelineService.ts +30 -2
- package/Server/Services/IncidentInternalNoteService.ts +6 -6
- package/Server/Services/IncidentPublicNoteService.ts +7 -4
- package/Server/Services/IncidentStateTimelineService.ts +2 -1
- package/Server/Services/ScheduledMaintenanceFeedService.ts +103 -0
- package/Server/Services/ScheduledMaintenanceInternalNoteService.ts +50 -6
- package/Server/Services/ScheduledMaintenanceOwnerTeamService.ts +37 -0
- package/Server/Services/ScheduledMaintenanceOwnerUserService.ts +34 -0
- package/Server/Services/ScheduledMaintenancePublicNoteService.ts +49 -7
- package/Server/Services/ScheduledMaintenanceService.ts +375 -12
- package/Server/Services/ScheduledMaintenanceStateService.ts +122 -34
- package/Server/Services/ScheduledMaintenanceStateTimelineService.ts +33 -1
- package/Server/Services/WorkspaceNotificationRuleService.ts +12 -0
- package/Server/Utils/Workspace/MicrosoftTeams/Actions/ActionTypes.ts +38 -0
- package/Server/Utils/Workspace/MicrosoftTeams/Messages/Alert.ts +116 -0
- package/Server/Utils/Workspace/MicrosoftTeams/Messages/Incident.ts +36 -115
- package/Server/Utils/Workspace/MicrosoftTeams/Messages/ScheduledMaintenance.ts +108 -0
- package/Server/Utils/Workspace/Slack/Actions/ActionTypes.ts +20 -2
- package/Server/Utils/Workspace/Slack/Actions/Alert.ts +697 -0
- package/Server/Utils/Workspace/Slack/Actions/Auth.ts +9 -2
- package/Server/Utils/Workspace/Slack/Actions/Incident.ts +9 -3
- package/Server/Utils/Workspace/Slack/Actions/ScheduledMaintenance.ts +956 -0
- package/Server/Utils/Workspace/Slack/Messages/Alert.ts +116 -0
- package/Server/Utils/Workspace/Slack/Messages/ScheduledMaintenance.ts +108 -0
- package/Server/Utils/Workspace/Slack/Slack.ts +48 -2
- package/Server/Utils/Workspace/Slack/app-manifest.json +3 -3
- package/Server/Utils/Workspace/WorkspaceBase.ts +14 -0
- package/Server/Utils/Workspace/WorkspaceMessages/Alert.ts +69 -0
- package/Server/Utils/Workspace/WorkspaceMessages/ScheduledMaintenance.ts +73 -0
- package/Types/Date.ts +5 -0
- package/Types/Workspace/WorkspaceMessagePayload.ts +9 -0
- package/build/dist/Server/API/SlackAPI.js +54 -0
- package/build/dist/Server/API/SlackAPI.js.map +1 -1
- package/build/dist/Server/Services/AccessTokenService.js +11 -0
- package/build/dist/Server/Services/AccessTokenService.js.map +1 -1
- package/build/dist/Server/Services/AlertFeedService.js +60 -0
- package/build/dist/Server/Services/AlertFeedService.js.map +1 -1
- package/build/dist/Server/Services/AlertInternalNoteService.js +39 -8
- package/build/dist/Server/Services/AlertInternalNoteService.js.map +1 -1
- package/build/dist/Server/Services/AlertOwnerTeamService.js +40 -2
- package/build/dist/Server/Services/AlertOwnerTeamService.js.map +1 -1
- package/build/dist/Server/Services/AlertOwnerUserService.js +41 -3
- package/build/dist/Server/Services/AlertOwnerUserService.js.map +1 -1
- package/build/dist/Server/Services/AlertService.js +192 -35
- package/build/dist/Server/Services/AlertService.js.map +1 -1
- package/build/dist/Server/Services/AlertStateService.js +13 -0
- package/build/dist/Server/Services/AlertStateService.js.map +1 -1
- package/build/dist/Server/Services/AlertStateTimelineService.js +26 -2
- package/build/dist/Server/Services/AlertStateTimelineService.js.map +1 -1
- package/build/dist/Server/Services/IncidentInternalNoteService.js +6 -6
- package/build/dist/Server/Services/IncidentInternalNoteService.js.map +1 -1
- package/build/dist/Server/Services/IncidentPublicNoteService.js +5 -4
- package/build/dist/Server/Services/IncidentPublicNoteService.js.map +1 -1
- package/build/dist/Server/Services/IncidentStateTimelineService.js +1 -1
- package/build/dist/Server/Services/IncidentStateTimelineService.js.map +1 -1
- package/build/dist/Server/Services/ScheduledMaintenanceFeedService.js +60 -0
- package/build/dist/Server/Services/ScheduledMaintenanceFeedService.js.map +1 -1
- package/build/dist/Server/Services/ScheduledMaintenanceInternalNoteService.js +36 -6
- package/build/dist/Server/Services/ScheduledMaintenanceInternalNoteService.js.map +1 -1
- package/build/dist/Server/Services/ScheduledMaintenanceOwnerTeamService.js +24 -0
- package/build/dist/Server/Services/ScheduledMaintenanceOwnerTeamService.js.map +1 -1
- package/build/dist/Server/Services/ScheduledMaintenanceOwnerUserService.js +22 -0
- package/build/dist/Server/Services/ScheduledMaintenanceOwnerUserService.js.map +1 -1
- package/build/dist/Server/Services/ScheduledMaintenancePublicNoteService.js +36 -7
- package/build/dist/Server/Services/ScheduledMaintenancePublicNoteService.js.map +1 -1
- package/build/dist/Server/Services/ScheduledMaintenanceService.js +275 -13
- package/build/dist/Server/Services/ScheduledMaintenanceService.js.map +1 -1
- package/build/dist/Server/Services/ScheduledMaintenanceStateService.js +52 -4
- package/build/dist/Server/Services/ScheduledMaintenanceStateService.js.map +1 -1
- package/build/dist/Server/Services/ScheduledMaintenanceStateTimelineService.js +28 -1
- package/build/dist/Server/Services/ScheduledMaintenanceStateTimelineService.js.map +1 -1
- package/build/dist/Server/Services/WorkspaceNotificationRuleService.js +10 -0
- package/build/dist/Server/Services/WorkspaceNotificationRuleService.js.map +1 -1
- package/build/dist/Server/Utils/Workspace/MicrosoftTeams/Actions/ActionTypes.js +37 -0
- package/build/dist/Server/Utils/Workspace/MicrosoftTeams/Actions/ActionTypes.js.map +1 -0
- package/build/dist/Server/Utils/Workspace/MicrosoftTeams/Messages/Alert.js +82 -0
- package/build/dist/Server/Utils/Workspace/MicrosoftTeams/Messages/Alert.js.map +1 -0
- package/build/dist/Server/Utils/Workspace/MicrosoftTeams/Messages/Incident.js +33 -99
- package/build/dist/Server/Utils/Workspace/MicrosoftTeams/Messages/Incident.js.map +1 -1
- package/build/dist/Server/Utils/Workspace/MicrosoftTeams/Messages/ScheduledMaintenance.js +74 -0
- package/build/dist/Server/Utils/Workspace/MicrosoftTeams/Messages/ScheduledMaintenance.js.map +1 -0
- package/build/dist/Server/Utils/Workspace/Slack/Actions/ActionTypes.js +20 -2
- package/build/dist/Server/Utils/Workspace/Slack/Actions/ActionTypes.js.map +1 -1
- package/build/dist/Server/Utils/Workspace/Slack/Actions/Alert.js +425 -0
- package/build/dist/Server/Utils/Workspace/Slack/Actions/Alert.js.map +1 -0
- package/build/dist/Server/Utils/Workspace/Slack/Actions/Auth.js +2 -0
- package/build/dist/Server/Utils/Workspace/Slack/Actions/Auth.js.map +1 -1
- package/build/dist/Server/Utils/Workspace/Slack/Actions/Incident.js +5 -2
- package/build/dist/Server/Utils/Workspace/Slack/Actions/Incident.js.map +1 -1
- package/build/dist/Server/Utils/Workspace/Slack/Actions/ScheduledMaintenance.js +599 -0
- package/build/dist/Server/Utils/Workspace/Slack/Actions/ScheduledMaintenance.js.map +1 -0
- package/build/dist/Server/Utils/Workspace/Slack/Messages/Alert.js +82 -0
- package/build/dist/Server/Utils/Workspace/Slack/Messages/Alert.js.map +1 -0
- package/build/dist/Server/Utils/Workspace/Slack/Messages/ScheduledMaintenance.js +74 -0
- package/build/dist/Server/Utils/Workspace/Slack/Messages/ScheduledMaintenance.js.map +1 -0
- package/build/dist/Server/Utils/Workspace/Slack/Slack.js +34 -0
- package/build/dist/Server/Utils/Workspace/Slack/Slack.js.map +1 -1
- package/build/dist/Server/Utils/Workspace/Slack/app-manifest.json +3 -3
- package/build/dist/Server/Utils/Workspace/WorkspaceBase.js +8 -0
- package/build/dist/Server/Utils/Workspace/WorkspaceBase.js.map +1 -1
- package/build/dist/Server/Utils/Workspace/WorkspaceMessages/Alert.js +48 -0
- package/build/dist/Server/Utils/Workspace/WorkspaceMessages/Alert.js.map +1 -0
- package/build/dist/Server/Utils/Workspace/WorkspaceMessages/ScheduledMaintenance.js +47 -0
- package/build/dist/Server/Utils/Workspace/WorkspaceMessages/ScheduledMaintenance.js.map +1 -0
- package/build/dist/Types/Date.js +4 -0
- package/build/dist/Types/Date.js.map +1 -1
- package/package.json +2 -2
|
@@ -408,6 +408,12 @@ export class Service extends DatabaseService<WorkspaceNotificationRule> {
|
|
|
408
408
|
notificationRules: Array<WorkspaceNotificationRule>;
|
|
409
409
|
userIds: Array<ObjectID>;
|
|
410
410
|
}): Promise<void> {
|
|
411
|
+
// if no rules then return.
|
|
412
|
+
if (data.notificationRules.length === 0) {
|
|
413
|
+
logger.debug("No notification rules found. Returning.");
|
|
414
|
+
return;
|
|
415
|
+
}
|
|
416
|
+
|
|
411
417
|
logger.debug(
|
|
412
418
|
"inviteUsersBasedOnRulesAndWorkspaceChannels called with data:",
|
|
413
419
|
);
|
|
@@ -555,6 +561,12 @@ export class Service extends DatabaseService<WorkspaceNotificationRule> {
|
|
|
555
561
|
notificationRules: Array<WorkspaceNotificationRule>;
|
|
556
562
|
teamIds: Array<ObjectID>;
|
|
557
563
|
}): Promise<void> {
|
|
564
|
+
// if no rules then return.
|
|
565
|
+
if (data.notificationRules.length === 0) {
|
|
566
|
+
logger.debug("No notification rules found. Returning.");
|
|
567
|
+
return;
|
|
568
|
+
}
|
|
569
|
+
|
|
558
570
|
const usersInTeam: Array<User> = await TeamMemberService.getUsersInTeams(
|
|
559
571
|
data.teamIds,
|
|
560
572
|
);
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
enum SlackActionType {
|
|
2
|
+
// Incident actions
|
|
3
|
+
AcknowledgeIncident = "AcknowledgeIncident",
|
|
4
|
+
ResolveIncident = "ResolveIncident",
|
|
5
|
+
ViewAddIncidentNote = "ViewAddIncidentNote",
|
|
6
|
+
SubmitIncidentNote = "SubmitIncidentNote",
|
|
7
|
+
ViewChangeIncidentState = "ViewChangeIncidentState",
|
|
8
|
+
SubmitChangeIncidentState = "SubmitChangeIncidentState",
|
|
9
|
+
ViewExecuteIncidentOnCallPolicy = "ViewExecuteIncidentOnCallPolicy",
|
|
10
|
+
SubmitExecuteIncidentOnCallPolicy = "SubmitExecuteIncidentOnCallPolicy",
|
|
11
|
+
ViewIncident = "ViewIncident",
|
|
12
|
+
NewIncident = "/incident", // new incident slash command
|
|
13
|
+
SubmitNewIncident = "SubmitNewIncident",
|
|
14
|
+
|
|
15
|
+
// Alert Actions just like Incident Actions
|
|
16
|
+
AcknowledgeAlert = "AcknowledgeAlert",
|
|
17
|
+
ResolveAlert = "ResolveAlert",
|
|
18
|
+
ViewAddAlertNote = "ViewAddAlertNote",
|
|
19
|
+
SubmitAlertNote = "SubmitAlertNote",
|
|
20
|
+
ViewChangeAlertState = "ViewChangeAlertState",
|
|
21
|
+
SubmitChangeAlertState = "SubmitChangeAlertState",
|
|
22
|
+
ViewExecuteAlertOnCallPolicy = "ViewExecuteAlertOnCallPolicy",
|
|
23
|
+
SubmitExecuteAlertOnCallPolicy = "SubmitExecuteAlertOnCallPolicy",
|
|
24
|
+
ViewAlert = "ViewAlert",
|
|
25
|
+
|
|
26
|
+
// Scheduled Maintenance Actions just like Incident Actions.
|
|
27
|
+
MarkScheduledMaintenanceAsComplete = "MarkScheduledMaintenanceAsComplete",
|
|
28
|
+
MarkScheduledMaintenanceAsOngoing = "MarkScheduledMaintenanceAsOngoing",
|
|
29
|
+
ViewAddScheduledMaintenanceNote = "ViewAddScheduledMaintenanceNote",
|
|
30
|
+
SubmitScheduledMaintenanceNote = "SubmitScheduledMaintenanceNote",
|
|
31
|
+
ViewChangeScheduledMaintenanceState = "ViewChangeScheduledMaintenanceState",
|
|
32
|
+
SubmitChangeScheduledMaintenanceState = "SubmitChangeScheduledMaintenanceState",
|
|
33
|
+
ViewScheduledMaintenance = "ViewScheduledMaintenance",
|
|
34
|
+
NewScheduledMaintenance = "/maintenance", // new scheduled maintenance slash command
|
|
35
|
+
SubmitNewScheduledMaintenance = "SubmitNewScheduledMaintenance",
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export default SlackActionType;
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import BadDataException from "../../../../../Types/Exception/BadDataException";
|
|
2
|
+
import ObjectID from "../../../../../Types/ObjectID";
|
|
3
|
+
import {
|
|
4
|
+
WorkspaceMessageBlock,
|
|
5
|
+
WorkspaceMessagePayloadButton,
|
|
6
|
+
WorkspacePayloadButtons,
|
|
7
|
+
WorkspacePayloadDivider,
|
|
8
|
+
} from "../../../../../Types/Workspace/WorkspaceMessagePayload";
|
|
9
|
+
import AlertService from "../../../../Services/AlertService";
|
|
10
|
+
import MicrosoftTeamsActionType from "../../../../Utils/Workspace/MicrosoftTeams/Actions/ActionTypes";
|
|
11
|
+
|
|
12
|
+
export default class MicrosoftTeamsAlertMessages {
|
|
13
|
+
public static async getAlertCreateMessageBlocks(data: {
|
|
14
|
+
alertId: ObjectID;
|
|
15
|
+
projectId: ObjectID;
|
|
16
|
+
}): Promise<Array<WorkspaceMessageBlock>> {
|
|
17
|
+
if (!data.alertId) {
|
|
18
|
+
throw new BadDataException("Alert ID is required");
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
// MicrosoftTeams.
|
|
22
|
+
|
|
23
|
+
const blockMicrosoftTeams: Array<WorkspaceMessageBlock> = [];
|
|
24
|
+
|
|
25
|
+
// add divider.
|
|
26
|
+
|
|
27
|
+
const dividerBlock: WorkspacePayloadDivider = {
|
|
28
|
+
_type: "WorkspacePayloadDivider",
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
blockMicrosoftTeams.push(dividerBlock);
|
|
32
|
+
|
|
33
|
+
// now add buttons.
|
|
34
|
+
// View data.
|
|
35
|
+
// Execute On Call
|
|
36
|
+
// Acknowledge alert
|
|
37
|
+
// Resolve data.
|
|
38
|
+
// Change Alert State.
|
|
39
|
+
// Add Note.
|
|
40
|
+
|
|
41
|
+
const buttons: Array<WorkspaceMessagePayloadButton> = [];
|
|
42
|
+
|
|
43
|
+
// view data.
|
|
44
|
+
const viewAlertButton: WorkspaceMessagePayloadButton = {
|
|
45
|
+
_type: "WorkspaceMessagePayloadButton",
|
|
46
|
+
title: "🔗 View Alert",
|
|
47
|
+
url: await AlertService.getAlertLinkInDashboard(
|
|
48
|
+
data.projectId!,
|
|
49
|
+
data.alertId!,
|
|
50
|
+
),
|
|
51
|
+
value: data.alertId?.toString() || "",
|
|
52
|
+
actionId: MicrosoftTeamsActionType.ViewAlert,
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
buttons.push(viewAlertButton);
|
|
56
|
+
|
|
57
|
+
// execute on call.
|
|
58
|
+
const executeOnCallButton: WorkspaceMessagePayloadButton = {
|
|
59
|
+
_type: "WorkspaceMessagePayloadButton",
|
|
60
|
+
title: "📞 Execute On Call",
|
|
61
|
+
value: data.alertId?.toString() || "",
|
|
62
|
+
actionId: MicrosoftTeamsActionType.ViewExecuteAlertOnCallPolicy,
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
buttons.push(executeOnCallButton);
|
|
66
|
+
|
|
67
|
+
// acknowledge data.
|
|
68
|
+
const acknowledgeAlertButton: WorkspaceMessagePayloadButton = {
|
|
69
|
+
_type: "WorkspaceMessagePayloadButton",
|
|
70
|
+
title: "👀 Acknowledge Alert",
|
|
71
|
+
value: data.alertId?.toString() || "",
|
|
72
|
+
actionId: MicrosoftTeamsActionType.AcknowledgeAlert,
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
buttons.push(acknowledgeAlertButton);
|
|
76
|
+
|
|
77
|
+
// resolve data.
|
|
78
|
+
const resolveAlertButton: WorkspaceMessagePayloadButton = {
|
|
79
|
+
_type: "WorkspaceMessagePayloadButton",
|
|
80
|
+
title: "✅ Resolve Alert",
|
|
81
|
+
value: data.alertId?.toString() || "",
|
|
82
|
+
actionId: MicrosoftTeamsActionType.ResolveAlert,
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
buttons.push(resolveAlertButton);
|
|
86
|
+
|
|
87
|
+
// change alert state.
|
|
88
|
+
const changeAlertStateButton: WorkspaceMessagePayloadButton = {
|
|
89
|
+
_type: "WorkspaceMessagePayloadButton",
|
|
90
|
+
title: "➡️ Change Alert State",
|
|
91
|
+
value: data.alertId?.toString() || "",
|
|
92
|
+
actionId: MicrosoftTeamsActionType.ViewChangeAlertState,
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
buttons.push(changeAlertStateButton);
|
|
96
|
+
|
|
97
|
+
// add note.
|
|
98
|
+
const addNoteButton: WorkspaceMessagePayloadButton = {
|
|
99
|
+
_type: "WorkspaceMessagePayloadButton",
|
|
100
|
+
title: "📄 Add Note",
|
|
101
|
+
value: data.alertId?.toString() || "",
|
|
102
|
+
actionId: MicrosoftTeamsActionType.ViewAddAlertNote,
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
buttons.push(addNoteButton);
|
|
106
|
+
|
|
107
|
+
const workspacePayloadButtons: WorkspacePayloadButtons = {
|
|
108
|
+
buttons: buttons,
|
|
109
|
+
_type: "WorkspacePayloadButtons",
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
blockMicrosoftTeams.push(workspacePayloadButtons);
|
|
113
|
+
|
|
114
|
+
return blockMicrosoftTeams;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
@@ -1,105 +1,26 @@
|
|
|
1
|
-
import Incident from "../../../../../Models/DatabaseModels/Incident";
|
|
2
1
|
import BadDataException from "../../../../../Types/Exception/BadDataException";
|
|
2
|
+
import ObjectID from "../../../../../Types/ObjectID";
|
|
3
3
|
import {
|
|
4
4
|
WorkspaceMessageBlock,
|
|
5
5
|
WorkspaceMessagePayloadButton,
|
|
6
6
|
WorkspacePayloadButtons,
|
|
7
7
|
WorkspacePayloadDivider,
|
|
8
|
-
WorkspacePayloadHeader,
|
|
9
|
-
WorkspacePayloadMarkdown,
|
|
10
8
|
} from "../../../../../Types/Workspace/WorkspaceMessagePayload";
|
|
11
9
|
import IncidentService from "../../../../Services/IncidentService";
|
|
12
|
-
import
|
|
13
|
-
import SlackActionType from "../../../../Utils/Workspace/Slack/Actions/ActionTypes";
|
|
10
|
+
import MicrosoftTeamsActionType from "../../../../Utils/Workspace/MicrosoftTeams/Actions/ActionTypes";
|
|
14
11
|
|
|
15
12
|
export default class MicrosoftTeamsIncidentMessages {
|
|
16
13
|
public static async getIncidentCreateMessageBlocks(data: {
|
|
17
|
-
|
|
14
|
+
incidentId: ObjectID;
|
|
15
|
+
projectId: ObjectID;
|
|
18
16
|
}): Promise<Array<WorkspaceMessageBlock>> {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
if (!incident) {
|
|
22
|
-
throw new BadDataException("Incident not found");
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
// Slack.
|
|
26
|
-
|
|
27
|
-
const blockSlack: Array<WorkspaceMessageBlock> = [];
|
|
28
|
-
|
|
29
|
-
if (incident.incidentNumber) {
|
|
30
|
-
const markdownBlock1: WorkspacePayloadHeader = {
|
|
31
|
-
_type: "WorkspacePayloadHeader",
|
|
32
|
-
text: `:rotating_light: **Incident #${incident.incidentNumber}**`,
|
|
33
|
-
};
|
|
34
|
-
blockSlack.push(markdownBlock1);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
if (incident.title) {
|
|
38
|
-
const markdownBlock2: WorkspacePayloadMarkdown = {
|
|
39
|
-
_type: "WorkspacePayloadMarkdown",
|
|
40
|
-
text: `**[${incident.title}](${(await IncidentService.getIncidentLinkInDashboard(incident.projectId!, incident.id!)).toString()})**`,
|
|
41
|
-
};
|
|
42
|
-
blockSlack.push(markdownBlock2);
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
if (incident.description) {
|
|
46
|
-
const markdownBlock3: WorkspacePayloadMarkdown = {
|
|
47
|
-
_type: "WorkspacePayloadMarkdown",
|
|
48
|
-
text: `${incident.description}`,
|
|
49
|
-
};
|
|
50
|
-
blockSlack.push(markdownBlock3);
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
if (incident.currentIncidentState?.name) {
|
|
54
|
-
const markdownBlock7: WorkspacePayloadMarkdown = {
|
|
55
|
-
_type: "WorkspacePayloadMarkdown",
|
|
56
|
-
text: `:arrow_right: **Incident State**: ${incident.currentIncidentState.name}`,
|
|
57
|
-
};
|
|
58
|
-
blockSlack.push(markdownBlock7);
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
if (incident.incidentSeverity?.name) {
|
|
62
|
-
const markdownBlock4: WorkspacePayloadMarkdown = {
|
|
63
|
-
_type: "WorkspacePayloadMarkdown",
|
|
64
|
-
text: `:warning: **Severity**: ${incident.incidentSeverity.name}`,
|
|
65
|
-
};
|
|
66
|
-
blockSlack.push(markdownBlock4);
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
// check for monitors.
|
|
70
|
-
if (incident.monitors && incident.monitors.length > 0) {
|
|
71
|
-
let text: string = `:earth_americas: *Resources Affected*:\n`;
|
|
72
|
-
|
|
73
|
-
for (const monitor of incident.monitors) {
|
|
74
|
-
text += `- [${monitor.name}](${(await MonitorService.getMonitorLinkInDashboard(incident.projectId!, monitor.id!)).toString()})\n`;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
// now add text to markdwon block.
|
|
78
|
-
const markdownBlock5: WorkspacePayloadMarkdown = {
|
|
79
|
-
_type: "WorkspacePayloadMarkdown",
|
|
80
|
-
text: text,
|
|
81
|
-
};
|
|
82
|
-
|
|
83
|
-
blockSlack.push(markdownBlock5);
|
|
17
|
+
if (!data.incidentId) {
|
|
18
|
+
throw new BadDataException("Incident ID is required");
|
|
84
19
|
}
|
|
85
20
|
|
|
86
|
-
|
|
87
|
-
const markdownBlock5: WorkspacePayloadMarkdown = {
|
|
88
|
-
_type: "WorkspacePayloadMarkdown",
|
|
89
|
-
text: `:page_facing_up: **Root Cause**:
|
|
90
|
-
${incident.rootCause}`,
|
|
91
|
-
};
|
|
92
|
-
blockSlack.push(markdownBlock5);
|
|
93
|
-
}
|
|
21
|
+
// MicrosoftTeams.
|
|
94
22
|
|
|
95
|
-
|
|
96
|
-
const markdownBlock6: WorkspacePayloadMarkdown = {
|
|
97
|
-
_type: "WorkspacePayloadMarkdown",
|
|
98
|
-
text: `:dart: **Remediation Notes**:
|
|
99
|
-
${incident.remediationNotes}`,
|
|
100
|
-
};
|
|
101
|
-
blockSlack.push(markdownBlock6);
|
|
102
|
-
}
|
|
23
|
+
const blockMicrosoftTeams: Array<WorkspaceMessageBlock> = [];
|
|
103
24
|
|
|
104
25
|
// add divider.
|
|
105
26
|
|
|
@@ -107,28 +28,28 @@ export default class MicrosoftTeamsIncidentMessages {
|
|
|
107
28
|
_type: "WorkspacePayloadDivider",
|
|
108
29
|
};
|
|
109
30
|
|
|
110
|
-
|
|
31
|
+
blockMicrosoftTeams.push(dividerBlock);
|
|
111
32
|
|
|
112
33
|
// now add buttons.
|
|
113
|
-
// View
|
|
34
|
+
// View data.
|
|
114
35
|
// Execute On Call
|
|
115
36
|
// Acknowledge incident
|
|
116
|
-
// Resolve
|
|
37
|
+
// Resolve data.
|
|
117
38
|
// Change Incident State.
|
|
118
39
|
// Add Note.
|
|
119
40
|
|
|
120
41
|
const buttons: Array<WorkspaceMessagePayloadButton> = [];
|
|
121
42
|
|
|
122
|
-
// view
|
|
43
|
+
// view data.
|
|
123
44
|
const viewIncidentButton: WorkspaceMessagePayloadButton = {
|
|
124
45
|
_type: "WorkspaceMessagePayloadButton",
|
|
125
|
-
title: "View Incident",
|
|
46
|
+
title: "🔗 View Incident",
|
|
126
47
|
url: await IncidentService.getIncidentLinkInDashboard(
|
|
127
|
-
|
|
128
|
-
|
|
48
|
+
data.projectId!,
|
|
49
|
+
data.incidentId!,
|
|
129
50
|
),
|
|
130
|
-
value: "
|
|
131
|
-
actionId:
|
|
51
|
+
value: data.incidentId?.toString() || "",
|
|
52
|
+
actionId: MicrosoftTeamsActionType.ViewIncident,
|
|
132
53
|
};
|
|
133
54
|
|
|
134
55
|
buttons.push(viewIncidentButton);
|
|
@@ -136,29 +57,29 @@ export default class MicrosoftTeamsIncidentMessages {
|
|
|
136
57
|
// execute on call.
|
|
137
58
|
const executeOnCallButton: WorkspaceMessagePayloadButton = {
|
|
138
59
|
_type: "WorkspaceMessagePayloadButton",
|
|
139
|
-
title: "
|
|
140
|
-
value: "
|
|
141
|
-
actionId:
|
|
60
|
+
title: "📞 Execute On Call",
|
|
61
|
+
value: data.incidentId?.toString() || "",
|
|
62
|
+
actionId: MicrosoftTeamsActionType.ViewExecuteIncidentOnCallPolicy,
|
|
142
63
|
};
|
|
143
64
|
|
|
144
65
|
buttons.push(executeOnCallButton);
|
|
145
66
|
|
|
146
|
-
// acknowledge
|
|
67
|
+
// acknowledge data.
|
|
147
68
|
const acknowledgeIncidentButton: WorkspaceMessagePayloadButton = {
|
|
148
69
|
_type: "WorkspaceMessagePayloadButton",
|
|
149
|
-
title: "
|
|
150
|
-
value: "
|
|
151
|
-
actionId:
|
|
70
|
+
title: "👀 Acknowledge Incident",
|
|
71
|
+
value: data.incidentId?.toString() || "",
|
|
72
|
+
actionId: MicrosoftTeamsActionType.AcknowledgeIncident,
|
|
152
73
|
};
|
|
153
74
|
|
|
154
75
|
buttons.push(acknowledgeIncidentButton);
|
|
155
76
|
|
|
156
|
-
// resolve
|
|
77
|
+
// resolve data.
|
|
157
78
|
const resolveIncidentButton: WorkspaceMessagePayloadButton = {
|
|
158
79
|
_type: "WorkspaceMessagePayloadButton",
|
|
159
|
-
title: "
|
|
160
|
-
value: "
|
|
161
|
-
actionId:
|
|
80
|
+
title: "✅ Resolve Incident",
|
|
81
|
+
value: data.incidentId?.toString() || "",
|
|
82
|
+
actionId: MicrosoftTeamsActionType.ResolveIncident,
|
|
162
83
|
};
|
|
163
84
|
|
|
164
85
|
buttons.push(resolveIncidentButton);
|
|
@@ -166,9 +87,9 @@ export default class MicrosoftTeamsIncidentMessages {
|
|
|
166
87
|
// change incident state.
|
|
167
88
|
const changeIncidentStateButton: WorkspaceMessagePayloadButton = {
|
|
168
89
|
_type: "WorkspaceMessagePayloadButton",
|
|
169
|
-
title: "
|
|
170
|
-
value: "
|
|
171
|
-
actionId:
|
|
90
|
+
title: "➡️ Change Incident State",
|
|
91
|
+
value: data.incidentId?.toString() || "",
|
|
92
|
+
actionId: MicrosoftTeamsActionType.ViewChangeIncidentState,
|
|
172
93
|
};
|
|
173
94
|
|
|
174
95
|
buttons.push(changeIncidentStateButton);
|
|
@@ -176,9 +97,9 @@ export default class MicrosoftTeamsIncidentMessages {
|
|
|
176
97
|
// add note.
|
|
177
98
|
const addNoteButton: WorkspaceMessagePayloadButton = {
|
|
178
99
|
_type: "WorkspaceMessagePayloadButton",
|
|
179
|
-
title: "
|
|
180
|
-
value: "
|
|
181
|
-
actionId:
|
|
100
|
+
title: "📄 Add Note",
|
|
101
|
+
value: data.incidentId?.toString() || "",
|
|
102
|
+
actionId: MicrosoftTeamsActionType.ViewAddIncidentNote,
|
|
182
103
|
};
|
|
183
104
|
|
|
184
105
|
buttons.push(addNoteButton);
|
|
@@ -188,8 +109,8 @@ export default class MicrosoftTeamsIncidentMessages {
|
|
|
188
109
|
_type: "WorkspacePayloadButtons",
|
|
189
110
|
};
|
|
190
111
|
|
|
191
|
-
|
|
112
|
+
blockMicrosoftTeams.push(workspacePayloadButtons);
|
|
192
113
|
|
|
193
|
-
return
|
|
114
|
+
return blockMicrosoftTeams;
|
|
194
115
|
}
|
|
195
116
|
}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import BadDataException from "../../../../../Types/Exception/BadDataException";
|
|
2
|
+
import ObjectID from "../../../../../Types/ObjectID";
|
|
3
|
+
import {
|
|
4
|
+
WorkspaceMessageBlock,
|
|
5
|
+
WorkspaceMessagePayloadButton,
|
|
6
|
+
WorkspacePayloadButtons,
|
|
7
|
+
WorkspacePayloadDivider,
|
|
8
|
+
} from "../../../../../Types/Workspace/WorkspaceMessagePayload";
|
|
9
|
+
import ScheduledMaintenanceService from "../../../../Services/ScheduledMaintenanceService";
|
|
10
|
+
import MicrosoftTeamsActionType from "../../../../Utils/Workspace/MicrosoftTeams/Actions/ActionTypes";
|
|
11
|
+
|
|
12
|
+
export default class MicrosoftTeamsScheduledMaintenanceMessages {
|
|
13
|
+
public static async getScheduledMaintenanceCreateMessageBlocks(data: {
|
|
14
|
+
scheduledMaintenanceId: ObjectID;
|
|
15
|
+
projectId: ObjectID;
|
|
16
|
+
}): Promise<Array<WorkspaceMessageBlock>> {
|
|
17
|
+
if (!data.scheduledMaintenanceId) {
|
|
18
|
+
throw new BadDataException("ScheduledMaintenance ID is required");
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
// MicrosoftTeams.
|
|
22
|
+
|
|
23
|
+
const blockMicrosoftTeams: Array<WorkspaceMessageBlock> = [];
|
|
24
|
+
|
|
25
|
+
// add divider.
|
|
26
|
+
|
|
27
|
+
const dividerBlock: WorkspacePayloadDivider = {
|
|
28
|
+
_type: "WorkspacePayloadDivider",
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
blockMicrosoftTeams.push(dividerBlock);
|
|
32
|
+
|
|
33
|
+
// now add buttons.
|
|
34
|
+
// View data.
|
|
35
|
+
// Execute On Call
|
|
36
|
+
// Acknowledge scheduledMaintenance
|
|
37
|
+
// Resolve data.
|
|
38
|
+
// Change ScheduledMaintenance State.
|
|
39
|
+
// Add Note.
|
|
40
|
+
|
|
41
|
+
const buttons: Array<WorkspaceMessagePayloadButton> = [];
|
|
42
|
+
|
|
43
|
+
// view data.
|
|
44
|
+
const viewScheduledMaintenanceButton: WorkspaceMessagePayloadButton = {
|
|
45
|
+
_type: "WorkspaceMessagePayloadButton",
|
|
46
|
+
title: "🔗 View ScheduledMaintenance",
|
|
47
|
+
url: await ScheduledMaintenanceService.getScheduledMaintenanceLinkInDashboard(
|
|
48
|
+
data.projectId!,
|
|
49
|
+
data.scheduledMaintenanceId!,
|
|
50
|
+
),
|
|
51
|
+
value: data.scheduledMaintenanceId?.toString() || "",
|
|
52
|
+
actionId: MicrosoftTeamsActionType.ViewScheduledMaintenance,
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
buttons.push(viewScheduledMaintenanceButton);
|
|
56
|
+
|
|
57
|
+
// acknowledge data.
|
|
58
|
+
const acknowledgeScheduledMaintenanceButton: WorkspaceMessagePayloadButton =
|
|
59
|
+
{
|
|
60
|
+
_type: "WorkspaceMessagePayloadButton",
|
|
61
|
+
title: "⌛ Mark as Ongoing",
|
|
62
|
+
value: data.scheduledMaintenanceId?.toString() || "",
|
|
63
|
+
actionId: MicrosoftTeamsActionType.MarkScheduledMaintenanceAsOngoing,
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
buttons.push(acknowledgeScheduledMaintenanceButton);
|
|
67
|
+
|
|
68
|
+
// resolve data.
|
|
69
|
+
const resolveScheduledMaintenanceButton: WorkspaceMessagePayloadButton = {
|
|
70
|
+
_type: "WorkspaceMessagePayloadButton",
|
|
71
|
+
title: "✅ Mark as Completed",
|
|
72
|
+
value: data.scheduledMaintenanceId?.toString() || "",
|
|
73
|
+
actionId: MicrosoftTeamsActionType.MarkScheduledMaintenanceAsComplete,
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
buttons.push(resolveScheduledMaintenanceButton);
|
|
77
|
+
|
|
78
|
+
// change scheduledMaintenance state.
|
|
79
|
+
const changeScheduledMaintenanceStateButton: WorkspaceMessagePayloadButton =
|
|
80
|
+
{
|
|
81
|
+
_type: "WorkspaceMessagePayloadButton",
|
|
82
|
+
title: "➡️ Change Scheduled Maintenance State",
|
|
83
|
+
value: data.scheduledMaintenanceId?.toString() || "",
|
|
84
|
+
actionId: MicrosoftTeamsActionType.ViewChangeScheduledMaintenanceState,
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
buttons.push(changeScheduledMaintenanceStateButton);
|
|
88
|
+
|
|
89
|
+
// add note.
|
|
90
|
+
const addNoteButton: WorkspaceMessagePayloadButton = {
|
|
91
|
+
_type: "WorkspaceMessagePayloadButton",
|
|
92
|
+
title: "📄 Add Note",
|
|
93
|
+
value: data.scheduledMaintenanceId?.toString() || "",
|
|
94
|
+
actionId: MicrosoftTeamsActionType.ViewAddScheduledMaintenanceNote,
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
buttons.push(addNoteButton);
|
|
98
|
+
|
|
99
|
+
const workspacePayloadButtons: WorkspacePayloadButtons = {
|
|
100
|
+
buttons: buttons,
|
|
101
|
+
_type: "WorkspacePayloadButtons",
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
blockMicrosoftTeams.push(workspacePayloadButtons);
|
|
105
|
+
|
|
106
|
+
return blockMicrosoftTeams;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
@@ -12,9 +12,27 @@ enum SlackActionType {
|
|
|
12
12
|
NewIncident = "/incident", // new incident slash command
|
|
13
13
|
SubmitNewIncident = "SubmitNewIncident",
|
|
14
14
|
|
|
15
|
-
// Alert Actions
|
|
15
|
+
// Alert Actions just like Incident Actions
|
|
16
|
+
AcknowledgeAlert = "AcknowledgeAlert",
|
|
17
|
+
ResolveAlert = "ResolveAlert",
|
|
18
|
+
ViewAddAlertNote = "ViewAddAlertNote",
|
|
19
|
+
SubmitAlertNote = "SubmitAlertNote",
|
|
20
|
+
ViewChangeAlertState = "ViewChangeAlertState",
|
|
21
|
+
SubmitChangeAlertState = "SubmitChangeAlertState",
|
|
22
|
+
ViewExecuteAlertOnCallPolicy = "ViewExecuteAlertOnCallPolicy",
|
|
23
|
+
SubmitExecuteAlertOnCallPolicy = "SubmitExecuteAlertOnCallPolicy",
|
|
24
|
+
ViewAlert = "ViewAlert",
|
|
16
25
|
|
|
17
|
-
// Scheduled Maintenance Actions.
|
|
26
|
+
// Scheduled Maintenance Actions just like Incident Actions.
|
|
27
|
+
MarkScheduledMaintenanceAsComplete = "MarkScheduledMaintenanceAsComplete",
|
|
28
|
+
MarkScheduledMaintenanceAsOngoing = "MarkScheduledMaintenanceAsOngoing",
|
|
29
|
+
ViewAddScheduledMaintenanceNote = "ViewAddScheduledMaintenanceNote",
|
|
30
|
+
SubmitScheduledMaintenanceNote = "SubmitScheduledMaintenanceNote",
|
|
31
|
+
ViewChangeScheduledMaintenanceState = "ViewChangeScheduledMaintenanceState",
|
|
32
|
+
SubmitChangeScheduledMaintenanceState = "SubmitChangeScheduledMaintenanceState",
|
|
33
|
+
ViewScheduledMaintenance = "ViewScheduledMaintenance",
|
|
34
|
+
NewScheduledMaintenance = "/maintenance", // new scheduled maintenance slash command
|
|
35
|
+
SubmitNewScheduledMaintenance = "SubmitNewScheduledMaintenance",
|
|
18
36
|
}
|
|
19
37
|
|
|
20
38
|
export default SlackActionType;
|