@oneuptime/common 8.0.5312 → 8.0.5329
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/GlobalConfig.ts +90 -0
- package/Models/DatabaseModels/Index.ts +4 -0
- package/Models/DatabaseModels/Project.ts +27 -0
- package/Models/DatabaseModels/UserNotificationRule.ts +48 -0
- package/Models/DatabaseModels/UserNotificationSetting.ts +16 -0
- package/Models/DatabaseModels/UserOnCallLogTimeline.ts +48 -0
- package/Models/DatabaseModels/UserWhatsApp.ts +288 -0
- package/Models/DatabaseModels/WhatsAppLog.ts +884 -0
- package/Server/API/NotificationAPI.ts +4 -4
- package/Server/API/ProjectSSO.ts +41 -33
- package/Server/API/ShortLinkAPI.ts +33 -25
- package/Server/API/UserCallAPI.ts +82 -73
- package/Server/API/UserEmailAPI.ts +82 -73
- package/Server/API/UserOnCallLogTimelineAPI.ts +227 -214
- package/Server/API/UserPushAPI.ts +177 -169
- package/Server/API/UserSmsAPI.ts +82 -73
- package/Server/API/UserWhatsAppAPI.ts +136 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/1759838763506-MigrationName.ts +103 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/1759839342566-MigrationName.ts +71 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/Index.ts +4 -0
- package/Server/Services/Index.ts +4 -0
- package/Server/Services/MonitorService.ts +32 -4
- package/Server/Services/OnCallDutyPolicyEscalationRuleScheduleService.ts +36 -4
- package/Server/Services/OnCallDutyPolicyEscalationRuleTeamService.ts +34 -4
- package/Server/Services/OnCallDutyPolicyEscalationRuleUserService.ts +34 -4
- package/Server/Services/OnCallDutyPolicyScheduleService.ts +47 -6
- package/Server/Services/ProbeService.ts +17 -2
- package/Server/Services/UserNotificationRuleService.ts +258 -7
- package/Server/Services/UserNotificationSettingService.ts +60 -0
- package/Server/Services/UserWhatsAppService.ts +203 -0
- package/Server/Services/WhatsAppLogService.ts +15 -0
- package/Server/Services/WhatsAppService.ts +141 -0
- package/Server/Types/Workflow/Components/BaseModel/OnTriggerBaseModel.ts +17 -5
- package/Server/Types/Workflow/Components/Webhook.ts +2 -2
- package/Server/Utils/StartServer.ts +57 -31
- package/Server/Utils/WhatsAppTemplateUtil.ts +247 -0
- package/Types/Icon/IconProp.ts +1 -0
- package/Types/WhatsApp/WhatsAppMessage.ts +12 -0
- package/Types/WhatsApp/WhatsAppTemplates.ts +197 -0
- package/Types/WhatsAppStatus.ts +8 -0
- package/UI/Components/Icon/Icon.tsx +12 -0
- package/build/dist/Models/DatabaseModels/GlobalConfig.js +98 -0
- package/build/dist/Models/DatabaseModels/GlobalConfig.js.map +1 -1
- package/build/dist/Models/DatabaseModels/Index.js +4 -0
- package/build/dist/Models/DatabaseModels/Index.js.map +1 -1
- package/build/dist/Models/DatabaseModels/Project.js +29 -0
- package/build/dist/Models/DatabaseModels/Project.js.map +1 -1
- package/build/dist/Models/DatabaseModels/UserNotificationRule.js +48 -0
- package/build/dist/Models/DatabaseModels/UserNotificationRule.js.map +1 -1
- package/build/dist/Models/DatabaseModels/UserNotificationSetting.js +18 -0
- package/build/dist/Models/DatabaseModels/UserNotificationSetting.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/UserWhatsApp.js +308 -0
- package/build/dist/Models/DatabaseModels/UserWhatsApp.js.map +1 -0
- package/build/dist/Models/DatabaseModels/WhatsAppLog.js +911 -0
- package/build/dist/Models/DatabaseModels/WhatsAppLog.js.map +1 -0
- package/build/dist/Server/API/NotificationAPI.js +2 -2
- package/build/dist/Server/API/NotificationAPI.js.map +1 -1
- package/build/dist/Server/API/ProjectSSO.js +26 -21
- package/build/dist/Server/API/ProjectSSO.js.map +1 -1
- package/build/dist/Server/API/ShortLinkAPI.js +17 -12
- package/build/dist/Server/API/ShortLinkAPI.js.map +1 -1
- package/build/dist/Server/API/UserCallAPI.js +54 -44
- package/build/dist/Server/API/UserCallAPI.js.map +1 -1
- package/build/dist/Server/API/UserEmailAPI.js +54 -44
- package/build/dist/Server/API/UserEmailAPI.js.map +1 -1
- package/build/dist/Server/API/UserOnCallLogTimelineAPI.js +142 -127
- package/build/dist/Server/API/UserOnCallLogTimelineAPI.js.map +1 -1
- package/build/dist/Server/API/UserPushAPI.js +111 -96
- package/build/dist/Server/API/UserPushAPI.js.map +1 -1
- package/build/dist/Server/API/UserSmsAPI.js +54 -44
- package/build/dist/Server/API/UserSmsAPI.js.map +1 -1
- package/build/dist/Server/API/UserWhatsAppAPI.js +76 -0
- package/build/dist/Server/API/UserWhatsAppAPI.js.map +1 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1759838763506-MigrationName.js +41 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1759838763506-MigrationName.js.map +1 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1759839342566-MigrationName.js +30 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1759839342566-MigrationName.js.map +1 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/Index.js +4 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/Index.js.map +1 -1
- package/build/dist/Server/Services/Index.js +4 -0
- package/build/dist/Server/Services/Index.js.map +1 -1
- package/build/dist/Server/Services/MonitorService.js +23 -2
- package/build/dist/Server/Services/MonitorService.js.map +1 -1
- package/build/dist/Server/Services/OnCallDutyPolicyEscalationRuleScheduleService.js +29 -6
- package/build/dist/Server/Services/OnCallDutyPolicyEscalationRuleScheduleService.js.map +1 -1
- package/build/dist/Server/Services/OnCallDutyPolicyEscalationRuleTeamService.js +27 -6
- package/build/dist/Server/Services/OnCallDutyPolicyEscalationRuleTeamService.js.map +1 -1
- package/build/dist/Server/Services/OnCallDutyPolicyEscalationRuleUserService.js +26 -5
- package/build/dist/Server/Services/OnCallDutyPolicyEscalationRuleUserService.js.map +1 -1
- package/build/dist/Server/Services/OnCallDutyPolicyScheduleService.js +34 -3
- package/build/dist/Server/Services/OnCallDutyPolicyScheduleService.js.map +1 -1
- package/build/dist/Server/Services/ProbeService.js +12 -1
- package/build/dist/Server/Services/ProbeService.js.map +1 -1
- package/build/dist/Server/Services/UserNotificationRuleService.js +196 -19
- package/build/dist/Server/Services/UserNotificationRuleService.js.map +1 -1
- package/build/dist/Server/Services/UserNotificationSettingService.js +45 -0
- package/build/dist/Server/Services/UserNotificationSettingService.js.map +1 -1
- package/build/dist/Server/Services/UserWhatsAppService.js +179 -0
- package/build/dist/Server/Services/UserWhatsAppService.js.map +1 -0
- package/build/dist/Server/Services/WhatsAppLogService.js +13 -0
- package/build/dist/Server/Services/WhatsAppLogService.js.map +1 -0
- package/build/dist/Server/Services/WhatsAppService.js +103 -0
- package/build/dist/Server/Services/WhatsAppService.js.map +1 -0
- package/build/dist/Server/Types/Workflow/Components/BaseModel/OnTriggerBaseModel.js +14 -4
- package/build/dist/Server/Types/Workflow/Components/BaseModel/OnTriggerBaseModel.js.map +1 -1
- package/build/dist/Server/Types/Workflow/Components/Webhook.js +2 -2
- package/build/dist/Server/Types/Workflow/Components/Webhook.js.map +1 -1
- package/build/dist/Server/Utils/StartServer.js +41 -19
- package/build/dist/Server/Utils/StartServer.js.map +1 -1
- package/build/dist/Server/Utils/WhatsAppTemplateUtil.js +124 -0
- package/build/dist/Server/Utils/WhatsAppTemplateUtil.js.map +1 -0
- package/build/dist/Types/Icon/IconProp.js +1 -0
- package/build/dist/Types/Icon/IconProp.js.map +1 -1
- package/build/dist/Types/WhatsApp/WhatsAppMessage.js +2 -0
- package/build/dist/Types/WhatsApp/WhatsAppMessage.js.map +1 -0
- package/build/dist/Types/WhatsApp/WhatsAppTemplates.js +118 -0
- package/build/dist/Types/WhatsApp/WhatsAppTemplates.js.map +1 -0
- package/build/dist/Types/WhatsAppStatus.js +9 -0
- package/build/dist/Types/WhatsAppStatus.js.map +1 -0
- package/build/dist/UI/Components/Icon/Icon.js +6 -0
- package/build/dist/UI/Components/Icon/Icon.js.map +1 -1
- package/package.json +1 -1
|
@@ -6,6 +6,7 @@ import UserOnCallLogTimelineService, {
|
|
|
6
6
|
import {
|
|
7
7
|
ExpressRequest,
|
|
8
8
|
ExpressResponse,
|
|
9
|
+
NextFunction,
|
|
9
10
|
OneUptimeRequest,
|
|
10
11
|
} from "../Utils/Express";
|
|
11
12
|
import Response from "../Utils/Response";
|
|
@@ -34,62 +35,66 @@ export default class UserNotificationLogTimelineAPI extends BaseAPI<
|
|
|
34
35
|
.getCrudApiPath()
|
|
35
36
|
?.toString()}/call/gather-input/:itemId`,
|
|
36
37
|
NotificationMiddleware.isValidCallNotificationRequest,
|
|
37
|
-
async (req: ExpressRequest, res: ExpressResponse) => {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
38
|
+
async (req: ExpressRequest, res: ExpressResponse, next: NextFunction) => {
|
|
39
|
+
try {
|
|
40
|
+
req = req as OneUptimeRequest;
|
|
41
|
+
|
|
42
|
+
if (!req.params["itemId"]) {
|
|
43
|
+
return Response.sendErrorResponse(
|
|
44
|
+
req,
|
|
45
|
+
res,
|
|
46
|
+
new BadDataException("Invalid item ID"),
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const token: JSONObject = (req as any).callTokenData;
|
|
51
|
+
|
|
52
|
+
const itemId: ObjectID = new ObjectID(req.params["itemId"]);
|
|
53
|
+
|
|
54
|
+
const timelineItem: UserOnCallLogTimeline | null =
|
|
55
|
+
await this.service.findOneById({
|
|
56
|
+
id: itemId,
|
|
57
|
+
select: {
|
|
58
|
+
_id: true,
|
|
59
|
+
projectId: true,
|
|
60
|
+
triggeredByIncidentId: true,
|
|
61
|
+
triggeredByAlertId: true,
|
|
62
|
+
},
|
|
63
|
+
props: {
|
|
64
|
+
isRoot: true,
|
|
65
|
+
},
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
if (!timelineItem) {
|
|
69
|
+
return Response.sendErrorResponse(
|
|
70
|
+
req,
|
|
71
|
+
res,
|
|
72
|
+
new BadDataException("Invalid item Id"),
|
|
73
|
+
);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// check digits.
|
|
77
|
+
|
|
78
|
+
if (req.body["Digits"] === "1") {
|
|
79
|
+
// then ack incident
|
|
80
|
+
await this.service.updateOneById({
|
|
81
|
+
id: itemId,
|
|
82
|
+
data: {
|
|
83
|
+
acknowledgedAt: OneUptimeDate.getCurrentDate(),
|
|
84
|
+
isAcknowledged: true,
|
|
85
|
+
status: UserNotificationStatus.Acknowledged,
|
|
86
|
+
statusMessage: "Notification Acknowledged",
|
|
87
|
+
},
|
|
88
|
+
props: {
|
|
89
|
+
isRoot: true,
|
|
90
|
+
},
|
|
91
|
+
});
|
|
92
|
+
}
|
|
65
93
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
res,
|
|
70
|
-
new BadDataException("Invalid item Id"),
|
|
71
|
-
);
|
|
94
|
+
return NotificationMiddleware.sendResponse(req, res, token as any);
|
|
95
|
+
} catch (error) {
|
|
96
|
+
return next(error);
|
|
72
97
|
}
|
|
73
|
-
|
|
74
|
-
// check digits.
|
|
75
|
-
|
|
76
|
-
if (req.body["Digits"] === "1") {
|
|
77
|
-
// then ack incident
|
|
78
|
-
await this.service.updateOneById({
|
|
79
|
-
id: itemId,
|
|
80
|
-
data: {
|
|
81
|
-
acknowledgedAt: OneUptimeDate.getCurrentDate(),
|
|
82
|
-
isAcknowledged: true,
|
|
83
|
-
status: UserNotificationStatus.Acknowledged,
|
|
84
|
-
statusMessage: "Notification Acknowledged",
|
|
85
|
-
},
|
|
86
|
-
props: {
|
|
87
|
-
isRoot: true,
|
|
88
|
-
},
|
|
89
|
-
});
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
return NotificationMiddleware.sendResponse(req, res, token as any);
|
|
93
98
|
},
|
|
94
99
|
);
|
|
95
100
|
|
|
@@ -102,73 +107,77 @@ export default class UserNotificationLogTimelineAPI extends BaseAPI<
|
|
|
102
107
|
`${new this.entityType()
|
|
103
108
|
.getCrudApiPath()
|
|
104
109
|
?.toString()}/acknowledge-page/:itemId`,
|
|
105
|
-
async (req: ExpressRequest, res: ExpressResponse) => {
|
|
106
|
-
|
|
110
|
+
async (req: ExpressRequest, res: ExpressResponse, next: NextFunction) => {
|
|
111
|
+
try {
|
|
112
|
+
req = req as OneUptimeRequest;
|
|
113
|
+
|
|
114
|
+
if (!req.params["itemId"]) {
|
|
115
|
+
return Response.sendErrorResponse(
|
|
116
|
+
req,
|
|
117
|
+
res,
|
|
118
|
+
new BadDataException("Item ID is required"),
|
|
119
|
+
);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
const itemId: ObjectID = new ObjectID(req.params["itemId"]);
|
|
123
|
+
|
|
124
|
+
const timelineItem: UserOnCallLogTimeline | null =
|
|
125
|
+
await this.service.findOneById({
|
|
126
|
+
id: itemId,
|
|
127
|
+
select: {
|
|
128
|
+
_id: true,
|
|
129
|
+
projectId: true,
|
|
130
|
+
triggeredByIncidentId: true,
|
|
131
|
+
triggeredByIncident: {
|
|
132
|
+
title: true,
|
|
133
|
+
description: true,
|
|
134
|
+
},
|
|
135
|
+
triggeredByAlertId: true,
|
|
136
|
+
triggeredByAlert: {
|
|
137
|
+
title: true,
|
|
138
|
+
description: true,
|
|
139
|
+
},
|
|
140
|
+
},
|
|
141
|
+
props: {
|
|
142
|
+
isRoot: true,
|
|
143
|
+
},
|
|
144
|
+
});
|
|
107
145
|
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
146
|
+
if (!timelineItem) {
|
|
147
|
+
return Response.sendErrorResponse(
|
|
148
|
+
req,
|
|
149
|
+
res,
|
|
150
|
+
new BadDataException("Invalid item Id"),
|
|
151
|
+
);
|
|
152
|
+
}
|
|
115
153
|
|
|
116
|
-
|
|
154
|
+
const notificationType: string = timelineItem.triggeredByIncidentId
|
|
155
|
+
? "Incident"
|
|
156
|
+
: "Alert";
|
|
117
157
|
|
|
118
|
-
|
|
119
|
-
await
|
|
120
|
-
id: itemId,
|
|
121
|
-
select: {
|
|
122
|
-
_id: true,
|
|
123
|
-
projectId: true,
|
|
124
|
-
triggeredByIncidentId: true,
|
|
125
|
-
triggeredByIncident: {
|
|
126
|
-
title: true,
|
|
127
|
-
description: true,
|
|
128
|
-
},
|
|
129
|
-
triggeredByAlertId: true,
|
|
130
|
-
triggeredByAlert: {
|
|
131
|
-
title: true,
|
|
132
|
-
description: true,
|
|
133
|
-
},
|
|
134
|
-
},
|
|
135
|
-
props: {
|
|
136
|
-
isRoot: true,
|
|
137
|
-
},
|
|
138
|
-
});
|
|
158
|
+
const host: Hostname = await DatabaseConfig.getHost();
|
|
159
|
+
const httpProtocol: Protocol = await DatabaseConfig.getHttpProtocol();
|
|
139
160
|
|
|
140
|
-
|
|
141
|
-
return Response.sendErrorResponse(
|
|
161
|
+
return Response.render(
|
|
142
162
|
req,
|
|
143
163
|
res,
|
|
144
|
-
|
|
164
|
+
"/usr/src/Common/Server/Views/AcknowledgeUserOnCallNotification.ejs",
|
|
165
|
+
{
|
|
166
|
+
title: `Acknowledge ${notificationType} - ${timelineItem.triggeredByIncident?.title || timelineItem.triggeredByAlert?.title}`,
|
|
167
|
+
message: `Do you want to acknowledge this ${notificationType}?`,
|
|
168
|
+
acknowledgeText: `Acknowledge ${notificationType}`,
|
|
169
|
+
acknowledgeUrl: new URL(
|
|
170
|
+
httpProtocol,
|
|
171
|
+
host,
|
|
172
|
+
new Route(AppApiRoute.toString())
|
|
173
|
+
.addRoute(new UserOnCallLogTimeline().crudApiPath!)
|
|
174
|
+
.addRoute("/acknowledge/" + itemId.toString()),
|
|
175
|
+
).toString(),
|
|
176
|
+
},
|
|
145
177
|
);
|
|
178
|
+
} catch (error) {
|
|
179
|
+
return next(error);
|
|
146
180
|
}
|
|
147
|
-
|
|
148
|
-
const notificationType: string = timelineItem.triggeredByIncidentId
|
|
149
|
-
? "Incident"
|
|
150
|
-
: "Alert";
|
|
151
|
-
|
|
152
|
-
const host: Hostname = await DatabaseConfig.getHost();
|
|
153
|
-
const httpProtocol: Protocol = await DatabaseConfig.getHttpProtocol();
|
|
154
|
-
|
|
155
|
-
return Response.render(
|
|
156
|
-
req,
|
|
157
|
-
res,
|
|
158
|
-
"/usr/src/Common/Server/Views/AcknowledgeUserOnCallNotification.ejs",
|
|
159
|
-
{
|
|
160
|
-
title: `Acknowledge ${notificationType} - ${timelineItem.triggeredByIncident?.title || timelineItem.triggeredByAlert?.title}`,
|
|
161
|
-
message: `Do you want to acknowledge this ${notificationType}?`,
|
|
162
|
-
acknowledgeText: `Acknowledge ${notificationType}`,
|
|
163
|
-
acknowledgeUrl: new URL(
|
|
164
|
-
httpProtocol,
|
|
165
|
-
host,
|
|
166
|
-
new Route(AppApiRoute.toString())
|
|
167
|
-
.addRoute(new UserOnCallLogTimeline().crudApiPath!)
|
|
168
|
-
.addRoute("/acknowledge/" + itemId.toString()),
|
|
169
|
-
).toString(),
|
|
170
|
-
},
|
|
171
|
-
);
|
|
172
181
|
},
|
|
173
182
|
);
|
|
174
183
|
|
|
@@ -177,124 +186,128 @@ export default class UserNotificationLogTimelineAPI extends BaseAPI<
|
|
|
177
186
|
`${new this.entityType()
|
|
178
187
|
.getCrudApiPath()
|
|
179
188
|
?.toString()}/acknowledge/:itemId`,
|
|
180
|
-
async (req: ExpressRequest, res: ExpressResponse) => {
|
|
181
|
-
|
|
189
|
+
async (req: ExpressRequest, res: ExpressResponse, next: NextFunction) => {
|
|
190
|
+
try {
|
|
191
|
+
req = req as OneUptimeRequest;
|
|
192
|
+
|
|
193
|
+
if (!req.params["itemId"]) {
|
|
194
|
+
return Response.sendErrorResponse(
|
|
195
|
+
req,
|
|
196
|
+
res,
|
|
197
|
+
new BadDataException("Item ID is required"),
|
|
198
|
+
);
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
const itemId: ObjectID = new ObjectID(req.params["itemId"]);
|
|
202
|
+
|
|
203
|
+
const timelineItem: UserOnCallLogTimeline | null =
|
|
204
|
+
await this.service.findOneById({
|
|
205
|
+
id: itemId,
|
|
206
|
+
select: {
|
|
207
|
+
_id: true,
|
|
208
|
+
projectId: true,
|
|
209
|
+
triggeredByIncidentId: true,
|
|
210
|
+
triggeredByAlertId: true,
|
|
211
|
+
triggeredByAlert: {
|
|
212
|
+
title: true,
|
|
213
|
+
},
|
|
214
|
+
triggeredByIncident: {
|
|
215
|
+
title: true,
|
|
216
|
+
},
|
|
217
|
+
acknowledgedAt: true,
|
|
218
|
+
isAcknowledged: true,
|
|
219
|
+
},
|
|
220
|
+
props: {
|
|
221
|
+
isRoot: true,
|
|
222
|
+
},
|
|
223
|
+
});
|
|
182
224
|
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
225
|
+
if (!timelineItem) {
|
|
226
|
+
return Response.sendErrorResponse(
|
|
227
|
+
req,
|
|
228
|
+
res,
|
|
229
|
+
new BadDataException("Invalid item Id"),
|
|
230
|
+
);
|
|
231
|
+
}
|
|
190
232
|
|
|
191
|
-
|
|
233
|
+
const host: Hostname = await DatabaseConfig.getHost();
|
|
234
|
+
const httpProtocol: Protocol = await DatabaseConfig.getHttpProtocol();
|
|
192
235
|
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
236
|
+
if (timelineItem.isAcknowledged) {
|
|
237
|
+
// already acknowledged. Then show already acknowledged page with view details button.
|
|
238
|
+
|
|
239
|
+
const viewDetailsUrl: URL = new URL(
|
|
240
|
+
httpProtocol,
|
|
241
|
+
host,
|
|
242
|
+
DashboardRoute.addRoute(
|
|
243
|
+
`/${timelineItem.projectId?.toString()}/${timelineItem.triggeredByIncidentId ? "incidents" : "alerts"}/${timelineItem.triggeredByIncidentId ? timelineItem.triggeredByIncidentId!.toString() : timelineItem.triggeredByAlertId!.toString()}`,
|
|
244
|
+
),
|
|
245
|
+
);
|
|
246
|
+
|
|
247
|
+
return Response.render(
|
|
248
|
+
req,
|
|
249
|
+
res,
|
|
250
|
+
"/usr/src/Common/Server/Views/ViewMessage.ejs",
|
|
251
|
+
{
|
|
252
|
+
title: `Notification Already Acknowledged - ${timelineItem.triggeredByIncident?.title || timelineItem.triggeredByAlert?.title}`,
|
|
253
|
+
message: `This notification has already been acknowledged.`,
|
|
254
|
+
viewDetailsText: `View ${timelineItem.triggeredByIncidentId ? "Incident" : "Alert"}`,
|
|
255
|
+
viewDetailsUrl: viewDetailsUrl.toString(),
|
|
206
256
|
},
|
|
207
|
-
|
|
257
|
+
);
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
await this.service.updateOneById({
|
|
261
|
+
id: itemId,
|
|
262
|
+
data: {
|
|
263
|
+
acknowledgedAt: OneUptimeDate.getCurrentDate(),
|
|
208
264
|
isAcknowledged: true,
|
|
265
|
+
status: UserNotificationStatus.Acknowledged,
|
|
266
|
+
statusMessage: "Notification Acknowledged",
|
|
209
267
|
},
|
|
210
268
|
props: {
|
|
211
269
|
isRoot: true,
|
|
212
270
|
},
|
|
213
271
|
});
|
|
214
272
|
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
// already acknowledged. Then show already acknowledged page with view details button.
|
|
228
|
-
|
|
229
|
-
const viewDetailsUrl: URL = new URL(
|
|
230
|
-
httpProtocol,
|
|
231
|
-
host,
|
|
232
|
-
DashboardRoute.addRoute(
|
|
233
|
-
`/${timelineItem.projectId?.toString()}/${timelineItem.triggeredByIncidentId ? "incidents" : "alerts"}/${timelineItem.triggeredByIncidentId ? timelineItem.triggeredByIncidentId!.toString() : timelineItem.triggeredByAlertId!.toString()}`,
|
|
234
|
-
),
|
|
235
|
-
);
|
|
236
|
-
|
|
237
|
-
return Response.render(
|
|
238
|
-
req,
|
|
239
|
-
res,
|
|
240
|
-
"/usr/src/Common/Server/Views/ViewMessage.ejs",
|
|
241
|
-
{
|
|
242
|
-
title: `Notification Already Acknowledged - ${timelineItem.triggeredByIncident?.title || timelineItem.triggeredByAlert?.title}`,
|
|
243
|
-
message: `This notification has already been acknowledged.`,
|
|
244
|
-
viewDetailsText: `View ${timelineItem.triggeredByIncidentId ? "Incident" : "Alert"}`,
|
|
245
|
-
viewDetailsUrl: viewDetailsUrl.toString(),
|
|
246
|
-
},
|
|
247
|
-
);
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
await this.service.updateOneById({
|
|
251
|
-
id: itemId,
|
|
252
|
-
data: {
|
|
253
|
-
acknowledgedAt: OneUptimeDate.getCurrentDate(),
|
|
254
|
-
isAcknowledged: true,
|
|
255
|
-
status: UserNotificationStatus.Acknowledged,
|
|
256
|
-
statusMessage: "Notification Acknowledged",
|
|
257
|
-
},
|
|
258
|
-
props: {
|
|
259
|
-
isRoot: true,
|
|
260
|
-
},
|
|
261
|
-
});
|
|
262
|
-
|
|
263
|
-
// redirect to dashboard to incidents page.
|
|
264
|
-
|
|
265
|
-
if (timelineItem.triggeredByIncidentId) {
|
|
266
|
-
return Response.redirect(
|
|
267
|
-
req,
|
|
268
|
-
res,
|
|
269
|
-
new URL(
|
|
270
|
-
httpProtocol,
|
|
271
|
-
host,
|
|
272
|
-
DashboardRoute.addRoute(
|
|
273
|
-
`/${timelineItem.projectId?.toString()}/incidents/${timelineItem.triggeredByIncidentId!.toString()}`,
|
|
273
|
+
// redirect to dashboard to incidents page.
|
|
274
|
+
|
|
275
|
+
if (timelineItem.triggeredByIncidentId) {
|
|
276
|
+
return Response.redirect(
|
|
277
|
+
req,
|
|
278
|
+
res,
|
|
279
|
+
new URL(
|
|
280
|
+
httpProtocol,
|
|
281
|
+
host,
|
|
282
|
+
DashboardRoute.addRoute(
|
|
283
|
+
`/${timelineItem.projectId?.toString()}/incidents/${timelineItem.triggeredByIncidentId!.toString()}`,
|
|
284
|
+
),
|
|
274
285
|
),
|
|
275
|
-
)
|
|
276
|
-
|
|
277
|
-
|
|
286
|
+
);
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
if (timelineItem.triggeredByAlertId) {
|
|
290
|
+
return Response.redirect(
|
|
291
|
+
req,
|
|
292
|
+
res,
|
|
293
|
+
new URL(
|
|
294
|
+
httpProtocol,
|
|
295
|
+
host,
|
|
296
|
+
DashboardRoute.addRoute(
|
|
297
|
+
`/${timelineItem.projectId?.toString()}/alerts/${timelineItem.triggeredByAlertId!.toString()}`,
|
|
298
|
+
),
|
|
299
|
+
),
|
|
300
|
+
);
|
|
301
|
+
}
|
|
278
302
|
|
|
279
|
-
|
|
280
|
-
return Response.redirect(
|
|
303
|
+
return Response.sendErrorResponse(
|
|
281
304
|
req,
|
|
282
305
|
res,
|
|
283
|
-
new
|
|
284
|
-
httpProtocol,
|
|
285
|
-
host,
|
|
286
|
-
DashboardRoute.addRoute(
|
|
287
|
-
`/${timelineItem.projectId?.toString()}/alerts/${timelineItem.triggeredByAlertId!.toString()}`,
|
|
288
|
-
),
|
|
289
|
-
),
|
|
306
|
+
new BadDataException("Invalid item Id"),
|
|
290
307
|
);
|
|
308
|
+
} catch (error) {
|
|
309
|
+
return next(error);
|
|
291
310
|
}
|
|
292
|
-
|
|
293
|
-
return Response.sendErrorResponse(
|
|
294
|
-
req,
|
|
295
|
-
res,
|
|
296
|
-
new BadDataException("Invalid item Id"),
|
|
297
|
-
);
|
|
298
311
|
},
|
|
299
312
|
);
|
|
300
313
|
}
|