@oneuptime/common 10.2.2 → 10.2.3
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/Index.ts +4 -0
- package/Models/DatabaseModels/UserNotificationRule.ts +49 -0
- package/Models/DatabaseModels/UserNotificationSetting.ts +17 -0
- package/Models/DatabaseModels/UserOnCallLogTimeline.ts +48 -0
- package/Models/DatabaseModels/UserWebhook.ts +290 -0
- package/Models/DatabaseModels/WebhookLog.ts +992 -0
- package/Server/API/UserWebhookAPI.ts +159 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/1778506655291-AddProjectOIDC.ts +1 -1
- package/Server/Infrastructure/Postgres/SchemaMigrations/1778514515756-MigrationName.ts +259 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/Index.ts +2 -0
- package/Server/Services/UserNotificationRuleService.ts +213 -1
- package/Server/Services/UserNotificationSettingService.ts +95 -0
- package/Server/Services/UserWebhookService.ts +208 -0
- package/Server/Services/WebhookLogService.ts +15 -0
- package/Server/Services/WebhookService.ts +126 -0
- package/Types/Permission.ts +12 -0
- package/Types/Webhook/WebhookMessage.ts +8 -0
- package/Types/WebhookStatus.ts +6 -0
- package/build/dist/Models/DatabaseModels/Index.js +4 -0
- package/build/dist/Models/DatabaseModels/Index.js.map +1 -1
- package/build/dist/Models/DatabaseModels/UserNotificationRule.js +49 -0
- package/build/dist/Models/DatabaseModels/UserNotificationRule.js.map +1 -1
- package/build/dist/Models/DatabaseModels/UserNotificationSetting.js +19 -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/UserWebhook.js +307 -0
- package/build/dist/Models/DatabaseModels/UserWebhook.js.map +1 -0
- package/build/dist/Models/DatabaseModels/WebhookLog.js +1021 -0
- package/build/dist/Models/DatabaseModels/WebhookLog.js.map +1 -0
- package/build/dist/Server/API/UserWebhookAPI.js +99 -0
- package/build/dist/Server/API/UserWebhookAPI.js.map +1 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1778506655291-AddProjectOIDC.js.map +1 -1
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1778514515756-MigrationName.js +94 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1778514515756-MigrationName.js.map +1 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/Index.js +2 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/Index.js.map +1 -1
- package/build/dist/Server/Services/UserNotificationRuleService.js +178 -21
- package/build/dist/Server/Services/UserNotificationRuleService.js.map +1 -1
- package/build/dist/Server/Services/UserNotificationSettingService.js +84 -1
- package/build/dist/Server/Services/UserNotificationSettingService.js.map +1 -1
- package/build/dist/Server/Services/UserWebhookService.js +190 -0
- package/build/dist/Server/Services/UserWebhookService.js.map +1 -0
- package/build/dist/Server/Services/WebhookLogService.js +13 -0
- package/build/dist/Server/Services/WebhookLogService.js.map +1 -0
- package/build/dist/Server/Services/WebhookService.js +92 -0
- package/build/dist/Server/Services/WebhookService.js.map +1 -0
- package/build/dist/Types/Permission.js +10 -0
- package/build/dist/Types/Permission.js.map +1 -1
- package/build/dist/Types/Webhook/WebhookMessage.js +2 -0
- package/build/dist/Types/Webhook/WebhookMessage.js.map +1 -0
- package/build/dist/Types/WebhookStatus.js +7 -0
- package/build/dist/Types/WebhookStatus.js.map +1 -0
- package/package.json +1 -1
|
@@ -17,6 +17,7 @@ import MailService from "./MailService";
|
|
|
17
17
|
import ShortLinkService from "./ShortLinkService";
|
|
18
18
|
import SmsService from "./SmsService";
|
|
19
19
|
import TelegramService from "./TelegramService";
|
|
20
|
+
import WebhookService from "./WebhookService";
|
|
20
21
|
import WhatsAppService from "./WhatsAppService";
|
|
21
22
|
import UserEmailService from "./UserEmailService";
|
|
22
23
|
import UserOnCallLogService from "./UserOnCallLogService";
|
|
@@ -61,7 +62,7 @@ export class Service extends DatabaseService {
|
|
|
61
62
|
}
|
|
62
63
|
async executeNotificationRuleItem(userNotificationRuleId, options) {
|
|
63
64
|
// get user notification log and see if this rule has already been executed. If so then skip.
|
|
64
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24;
|
|
65
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32, _33, _34, _35, _36, _37, _38, _39, _40, _41, _42, _43, _44, _45, _46, _47, _48, _49;
|
|
65
66
|
const userOnCallLog = await UserOnCallLogService.findOneById({
|
|
66
67
|
id: options.userNotificationLogId,
|
|
67
68
|
props: {
|
|
@@ -116,6 +117,11 @@ export class Service extends DatabaseService {
|
|
|
116
117
|
telegramUserHandle: true,
|
|
117
118
|
isVerified: true,
|
|
118
119
|
},
|
|
120
|
+
userWebhook: {
|
|
121
|
+
webhookUrl: true,
|
|
122
|
+
name: true,
|
|
123
|
+
secret: true,
|
|
124
|
+
},
|
|
119
125
|
userEmail: {
|
|
120
126
|
email: true,
|
|
121
127
|
isVerified: true,
|
|
@@ -817,16 +823,159 @@ export class Service extends DatabaseService {
|
|
|
817
823
|
},
|
|
818
824
|
});
|
|
819
825
|
}
|
|
826
|
+
// send webhook.
|
|
827
|
+
if ((_6 = notificationRuleItem.userWebhook) === null || _6 === void 0 ? void 0 : _6.webhookUrl) {
|
|
828
|
+
const webhookUrl = notificationRuleItem.userWebhook.webhookUrl;
|
|
829
|
+
const webhookSecret = notificationRuleItem.userWebhook.secret;
|
|
830
|
+
const userWebhookId = notificationRuleItem.userWebhook.id;
|
|
831
|
+
const dispatchWebhook = async (params) => {
|
|
832
|
+
logTimelineItem.status = UserNotificationStatus.Sending;
|
|
833
|
+
logTimelineItem.statusMessage = `Sending webhook to ${webhookUrl}.`;
|
|
834
|
+
logTimelineItem.userWebhookId = userWebhookId;
|
|
835
|
+
const updatedLog = await UserOnCallLogTimelineService.create({
|
|
836
|
+
data: logTimelineItem,
|
|
837
|
+
props: {
|
|
838
|
+
isRoot: true,
|
|
839
|
+
},
|
|
840
|
+
});
|
|
841
|
+
const callbacksByKind = {};
|
|
842
|
+
if (params.entityKind === "alert" && params.entityId) {
|
|
843
|
+
callbacksByKind.alert = { alertId: params.entityId };
|
|
844
|
+
}
|
|
845
|
+
else if (params.entityKind === "incident" && params.entityId) {
|
|
846
|
+
callbacksByKind.incident = { incidentId: params.entityId };
|
|
847
|
+
}
|
|
848
|
+
WebhookService.sendWebhook({
|
|
849
|
+
url: webhookUrl,
|
|
850
|
+
eventType: params.eventType,
|
|
851
|
+
payload: params.payload,
|
|
852
|
+
secret: webhookSecret,
|
|
853
|
+
}, Object.assign(Object.assign({ projectId: options.projectId, userOnCallLogTimelineId: updatedLog.id, userId: notificationRuleItem.userId, onCallPolicyId: options.onCallPolicyId, onCallPolicyEscalationRuleId: options.onCallPolicyEscalationRuleId, teamId: options.userBelongsToTeamId, onCallDutyPolicyExecutionLogTimelineId: options.onCallDutyPolicyExecutionLogTimelineId, onCallScheduleId: options.onCallScheduleId }, callbacksByKind.alert), callbacksByKind.incident)).catch(async (err) => {
|
|
854
|
+
await UserOnCallLogTimelineService.updateOneById({
|
|
855
|
+
id: updatedLog.id,
|
|
856
|
+
data: {
|
|
857
|
+
status: UserNotificationStatus.Error,
|
|
858
|
+
statusMessage: err.message || "Error sending webhook.",
|
|
859
|
+
},
|
|
860
|
+
props: {
|
|
861
|
+
isRoot: true,
|
|
862
|
+
},
|
|
863
|
+
});
|
|
864
|
+
});
|
|
865
|
+
};
|
|
866
|
+
if (options.userNotificationEventType ===
|
|
867
|
+
UserNotificationEventType.AlertCreated &&
|
|
868
|
+
alert) {
|
|
869
|
+
await dispatchWebhook({
|
|
870
|
+
eventType: "on-call.alert.created",
|
|
871
|
+
entityKind: "alert",
|
|
872
|
+
entityId: alert.id,
|
|
873
|
+
payload: {
|
|
874
|
+
eventType: "on-call.alert.created",
|
|
875
|
+
timestamp: new Date().toISOString(),
|
|
876
|
+
projectId: ((_7 = alert.projectId) === null || _7 === void 0 ? void 0 : _7.toString()) || "",
|
|
877
|
+
userId: notificationRuleItem.userId.toString(),
|
|
878
|
+
alert: {
|
|
879
|
+
id: ((_8 = alert.id) === null || _8 === void 0 ? void 0 : _8.toString()) || "",
|
|
880
|
+
title: alert.title || "",
|
|
881
|
+
description: alert.description || "",
|
|
882
|
+
alertNumber: alert.alertNumber || null,
|
|
883
|
+
alertNumberWithPrefix: alert.alertNumberWithPrefix || null,
|
|
884
|
+
severity: ((_9 = alert.alertSeverity) === null || _9 === void 0 ? void 0 : _9.name) || null,
|
|
885
|
+
state: ((_10 = alert.currentAlertState) === null || _10 === void 0 ? void 0 : _10.name) || null,
|
|
886
|
+
},
|
|
887
|
+
onCallPolicyId: ((_11 = options.onCallPolicyId) === null || _11 === void 0 ? void 0 : _11.toString()) || null,
|
|
888
|
+
onCallPolicyEscalationRuleId: ((_12 = options.onCallPolicyEscalationRuleId) === null || _12 === void 0 ? void 0 : _12.toString()) || null,
|
|
889
|
+
},
|
|
890
|
+
});
|
|
891
|
+
}
|
|
892
|
+
if (options.userNotificationEventType ===
|
|
893
|
+
UserNotificationEventType.IncidentCreated &&
|
|
894
|
+
incident) {
|
|
895
|
+
await dispatchWebhook({
|
|
896
|
+
eventType: "on-call.incident.created",
|
|
897
|
+
entityKind: "incident",
|
|
898
|
+
entityId: incident.id,
|
|
899
|
+
payload: {
|
|
900
|
+
eventType: "on-call.incident.created",
|
|
901
|
+
timestamp: new Date().toISOString(),
|
|
902
|
+
projectId: ((_13 = incident.projectId) === null || _13 === void 0 ? void 0 : _13.toString()) || "",
|
|
903
|
+
userId: notificationRuleItem.userId.toString(),
|
|
904
|
+
incident: {
|
|
905
|
+
id: ((_14 = incident.id) === null || _14 === void 0 ? void 0 : _14.toString()) || "",
|
|
906
|
+
title: incident.title || "",
|
|
907
|
+
description: incident.description || "",
|
|
908
|
+
incidentNumber: incident.incidentNumber || null,
|
|
909
|
+
incidentNumberWithPrefix: incident.incidentNumberWithPrefix || null,
|
|
910
|
+
severity: ((_15 = incident.incidentSeverity) === null || _15 === void 0 ? void 0 : _15.name) || null,
|
|
911
|
+
state: ((_16 = incident.currentIncidentState) === null || _16 === void 0 ? void 0 : _16.name) || null,
|
|
912
|
+
},
|
|
913
|
+
onCallPolicyId: ((_17 = options.onCallPolicyId) === null || _17 === void 0 ? void 0 : _17.toString()) || null,
|
|
914
|
+
onCallPolicyEscalationRuleId: ((_18 = options.onCallPolicyEscalationRuleId) === null || _18 === void 0 ? void 0 : _18.toString()) || null,
|
|
915
|
+
},
|
|
916
|
+
});
|
|
917
|
+
}
|
|
918
|
+
if (options.userNotificationEventType ===
|
|
919
|
+
UserNotificationEventType.AlertEpisodeCreated &&
|
|
920
|
+
alertEpisode) {
|
|
921
|
+
await dispatchWebhook({
|
|
922
|
+
eventType: "on-call.alertEpisode.created",
|
|
923
|
+
entityKind: "alertEpisode",
|
|
924
|
+
payload: {
|
|
925
|
+
eventType: "on-call.alertEpisode.created",
|
|
926
|
+
timestamp: new Date().toISOString(),
|
|
927
|
+
projectId: ((_19 = alertEpisode.projectId) === null || _19 === void 0 ? void 0 : _19.toString()) || "",
|
|
928
|
+
userId: notificationRuleItem.userId.toString(),
|
|
929
|
+
alertEpisode: {
|
|
930
|
+
id: ((_20 = alertEpisode.id) === null || _20 === void 0 ? void 0 : _20.toString()) || "",
|
|
931
|
+
title: alertEpisode.title || "",
|
|
932
|
+
description: alertEpisode.description || "",
|
|
933
|
+
episodeNumber: alertEpisode.episodeNumber || null,
|
|
934
|
+
episodeNumberWithPrefix: alertEpisode.episodeNumberWithPrefix || null,
|
|
935
|
+
severity: ((_21 = alertEpisode.alertSeverity) === null || _21 === void 0 ? void 0 : _21.name) || null,
|
|
936
|
+
state: ((_22 = alertEpisode.currentAlertState) === null || _22 === void 0 ? void 0 : _22.name) || null,
|
|
937
|
+
},
|
|
938
|
+
onCallPolicyId: ((_23 = options.onCallPolicyId) === null || _23 === void 0 ? void 0 : _23.toString()) || null,
|
|
939
|
+
onCallPolicyEscalationRuleId: ((_24 = options.onCallPolicyEscalationRuleId) === null || _24 === void 0 ? void 0 : _24.toString()) || null,
|
|
940
|
+
},
|
|
941
|
+
});
|
|
942
|
+
}
|
|
943
|
+
if (options.userNotificationEventType ===
|
|
944
|
+
UserNotificationEventType.IncidentEpisodeCreated &&
|
|
945
|
+
incidentEpisode) {
|
|
946
|
+
await dispatchWebhook({
|
|
947
|
+
eventType: "on-call.incidentEpisode.created",
|
|
948
|
+
entityKind: "incidentEpisode",
|
|
949
|
+
payload: {
|
|
950
|
+
eventType: "on-call.incidentEpisode.created",
|
|
951
|
+
timestamp: new Date().toISOString(),
|
|
952
|
+
projectId: ((_25 = incidentEpisode.projectId) === null || _25 === void 0 ? void 0 : _25.toString()) || "",
|
|
953
|
+
userId: notificationRuleItem.userId.toString(),
|
|
954
|
+
incidentEpisode: {
|
|
955
|
+
id: ((_26 = incidentEpisode.id) === null || _26 === void 0 ? void 0 : _26.toString()) || "",
|
|
956
|
+
title: incidentEpisode.title || "",
|
|
957
|
+
description: incidentEpisode.description || "",
|
|
958
|
+
episodeNumber: incidentEpisode.episodeNumber || null,
|
|
959
|
+
episodeNumberWithPrefix: incidentEpisode.episodeNumberWithPrefix || null,
|
|
960
|
+
severity: ((_27 = incidentEpisode.incidentSeverity) === null || _27 === void 0 ? void 0 : _27.name) || null,
|
|
961
|
+
state: ((_28 = incidentEpisode.currentIncidentState) === null || _28 === void 0 ? void 0 : _28.name) || null,
|
|
962
|
+
},
|
|
963
|
+
onCallPolicyId: ((_29 = options.onCallPolicyId) === null || _29 === void 0 ? void 0 : _29.toString()) || null,
|
|
964
|
+
onCallPolicyEscalationRuleId: ((_30 = options.onCallPolicyEscalationRuleId) === null || _30 === void 0 ? void 0 : _30.toString()) || null,
|
|
965
|
+
},
|
|
966
|
+
});
|
|
967
|
+
}
|
|
968
|
+
}
|
|
820
969
|
// send call.
|
|
821
|
-
if (((
|
|
822
|
-
((
|
|
970
|
+
if (((_31 = notificationRuleItem.userCall) === null || _31 === void 0 ? void 0 : _31.phone) &&
|
|
971
|
+
((_32 = notificationRuleItem.userCall) === null || _32 === void 0 ? void 0 : _32.isVerified)) {
|
|
823
972
|
// send call for alert
|
|
824
973
|
if (options.userNotificationEventType ===
|
|
825
974
|
UserNotificationEventType.AlertCreated &&
|
|
826
975
|
alert) {
|
|
827
976
|
// create an error log.
|
|
828
977
|
logTimelineItem.status = UserNotificationStatus.Sending;
|
|
829
|
-
logTimelineItem.statusMessage = `Making a call to ${(
|
|
978
|
+
logTimelineItem.statusMessage = `Making a call to ${(_33 = notificationRuleItem.userCall) === null || _33 === void 0 ? void 0 : _33.phone.toString()}.`;
|
|
830
979
|
logTimelineItem.userCallId = notificationRuleItem.userCall.id;
|
|
831
980
|
const updatedLog = await UserOnCallLogTimelineService.create({
|
|
832
981
|
data: logTimelineItem,
|
|
@@ -834,7 +983,7 @@ export class Service extends DatabaseService {
|
|
|
834
983
|
isRoot: true,
|
|
835
984
|
},
|
|
836
985
|
});
|
|
837
|
-
const callRequest = await this.generateCallTemplateForAlertCreated((
|
|
986
|
+
const callRequest = await this.generateCallTemplateForAlertCreated((_34 = notificationRuleItem.userCall) === null || _34 === void 0 ? void 0 : _34.phone, alert, updatedLog.id);
|
|
838
987
|
// send call.
|
|
839
988
|
CallService.makeCall(callRequest, {
|
|
840
989
|
projectId: alert.projectId,
|
|
@@ -864,7 +1013,7 @@ export class Service extends DatabaseService {
|
|
|
864
1013
|
incident) {
|
|
865
1014
|
// send call for incident
|
|
866
1015
|
logTimelineItem.status = UserNotificationStatus.Sending;
|
|
867
|
-
logTimelineItem.statusMessage = `Making a call to ${(
|
|
1016
|
+
logTimelineItem.statusMessage = `Making a call to ${(_35 = notificationRuleItem.userCall) === null || _35 === void 0 ? void 0 : _35.phone.toString()}.`;
|
|
868
1017
|
logTimelineItem.userCallId = notificationRuleItem.userCall.id;
|
|
869
1018
|
const updatedLog = await UserOnCallLogTimelineService.create({
|
|
870
1019
|
data: logTimelineItem,
|
|
@@ -872,7 +1021,7 @@ export class Service extends DatabaseService {
|
|
|
872
1021
|
isRoot: true,
|
|
873
1022
|
},
|
|
874
1023
|
});
|
|
875
|
-
const callRequest = await this.generateCallTemplateForIncidentCreated((
|
|
1024
|
+
const callRequest = await this.generateCallTemplateForIncidentCreated((_36 = notificationRuleItem.userCall) === null || _36 === void 0 ? void 0 : _36.phone, incident, updatedLog.id);
|
|
876
1025
|
// send call.
|
|
877
1026
|
CallService.makeCall(callRequest, {
|
|
878
1027
|
projectId: incident.projectId,
|
|
@@ -902,7 +1051,7 @@ export class Service extends DatabaseService {
|
|
|
902
1051
|
UserNotificationEventType.AlertEpisodeCreated &&
|
|
903
1052
|
alertEpisode) {
|
|
904
1053
|
logTimelineItem.status = UserNotificationStatus.Sending;
|
|
905
|
-
logTimelineItem.statusMessage = `Making a call to ${(
|
|
1054
|
+
logTimelineItem.statusMessage = `Making a call to ${(_37 = notificationRuleItem.userCall) === null || _37 === void 0 ? void 0 : _37.phone.toString()}.`;
|
|
906
1055
|
logTimelineItem.userCallId = notificationRuleItem.userCall.id;
|
|
907
1056
|
const updatedLog = await UserOnCallLogTimelineService.create({
|
|
908
1057
|
data: logTimelineItem,
|
|
@@ -910,7 +1059,7 @@ export class Service extends DatabaseService {
|
|
|
910
1059
|
isRoot: true,
|
|
911
1060
|
},
|
|
912
1061
|
});
|
|
913
|
-
const callRequest = await this.generateCallTemplateForAlertEpisodeCreated((
|
|
1062
|
+
const callRequest = await this.generateCallTemplateForAlertEpisodeCreated((_38 = notificationRuleItem.userCall) === null || _38 === void 0 ? void 0 : _38.phone, alertEpisode, updatedLog.id);
|
|
914
1063
|
CallService.makeCall(callRequest, {
|
|
915
1064
|
projectId: alertEpisode.projectId,
|
|
916
1065
|
userOnCallLogTimelineId: updatedLog.id,
|
|
@@ -935,11 +1084,11 @@ export class Service extends DatabaseService {
|
|
|
935
1084
|
});
|
|
936
1085
|
}
|
|
937
1086
|
}
|
|
938
|
-
if (((
|
|
939
|
-
!((
|
|
1087
|
+
if (((_39 = notificationRuleItem.userCall) === null || _39 === void 0 ? void 0 : _39.phone) &&
|
|
1088
|
+
!((_40 = notificationRuleItem.userCall) === null || _40 === void 0 ? void 0 : _40.isVerified)) {
|
|
940
1089
|
// create a log.
|
|
941
1090
|
logTimelineItem.status = UserNotificationStatus.Error;
|
|
942
|
-
logTimelineItem.statusMessage = `Call not sent because phone ${(
|
|
1091
|
+
logTimelineItem.statusMessage = `Call not sent because phone ${(_41 = notificationRuleItem.userCall) === null || _41 === void 0 ? void 0 : _41.phone.toString()} is not verified.`;
|
|
943
1092
|
await UserOnCallLogTimelineService.create({
|
|
944
1093
|
data: logTimelineItem,
|
|
945
1094
|
props: {
|
|
@@ -948,8 +1097,8 @@ export class Service extends DatabaseService {
|
|
|
948
1097
|
});
|
|
949
1098
|
}
|
|
950
1099
|
// send push notification.
|
|
951
|
-
if (((
|
|
952
|
-
((
|
|
1100
|
+
if (((_42 = notificationRuleItem.userPush) === null || _42 === void 0 ? void 0 : _42.deviceToken) &&
|
|
1101
|
+
((_43 = notificationRuleItem.userPush) === null || _43 === void 0 ? void 0 : _43.isVerified)) {
|
|
953
1102
|
// send push notification for alert
|
|
954
1103
|
if (options.userNotificationEventType ===
|
|
955
1104
|
UserNotificationEventType.AlertCreated &&
|
|
@@ -964,7 +1113,7 @@ export class Service extends DatabaseService {
|
|
|
964
1113
|
isRoot: true,
|
|
965
1114
|
},
|
|
966
1115
|
});
|
|
967
|
-
const pushMessage = PushNotificationUtil.createAlertCreatedNotification(Object.assign(Object.assign(Object.assign({ alertTitle: alert.title, projectName: ((
|
|
1116
|
+
const pushMessage = PushNotificationUtil.createAlertCreatedNotification(Object.assign(Object.assign(Object.assign({ alertTitle: alert.title, projectName: ((_44 = alert.project) === null || _44 === void 0 ? void 0 : _44.name) || "OneUptime", alertViewLink: (await AlertService.getAlertLinkInDashboard(alert.projectId, alert.id)).toString() }, (alert.alertNumber !== undefined && {
|
|
968
1117
|
alertNumber: alert.alertNumber,
|
|
969
1118
|
})), (alert.alertNumberWithPrefix && {
|
|
970
1119
|
alertNumberWithPrefix: alert.alertNumberWithPrefix,
|
|
@@ -1016,7 +1165,7 @@ export class Service extends DatabaseService {
|
|
|
1016
1165
|
isRoot: true,
|
|
1017
1166
|
},
|
|
1018
1167
|
});
|
|
1019
|
-
const pushMessage = PushNotificationUtil.createIncidentCreatedNotification(Object.assign(Object.assign(Object.assign({ incidentTitle: incident.title, projectName: ((
|
|
1168
|
+
const pushMessage = PushNotificationUtil.createIncidentCreatedNotification(Object.assign(Object.assign(Object.assign({ incidentTitle: incident.title, projectName: ((_45 = incident.project) === null || _45 === void 0 ? void 0 : _45.name) || "OneUptime", incidentViewLink: (await IncidentService.getIncidentLinkInDashboard(incident.projectId, incident.id)).toString() }, (incident.incidentNumber !== undefined && {
|
|
1020
1169
|
incidentNumber: incident.incidentNumber,
|
|
1021
1170
|
})), (incident.incidentNumberWithPrefix && {
|
|
1022
1171
|
incidentNumberWithPrefix: incident.incidentNumberWithPrefix,
|
|
@@ -1067,7 +1216,7 @@ export class Service extends DatabaseService {
|
|
|
1067
1216
|
isRoot: true,
|
|
1068
1217
|
},
|
|
1069
1218
|
});
|
|
1070
|
-
const pushMessage = PushNotificationUtil.createAlertEpisodeCreatedNotification(Object.assign(Object.assign(Object.assign({ alertEpisodeTitle: alertEpisode.title, projectName: ((
|
|
1219
|
+
const pushMessage = PushNotificationUtil.createAlertEpisodeCreatedNotification(Object.assign(Object.assign(Object.assign({ alertEpisodeTitle: alertEpisode.title, projectName: ((_46 = alertEpisode.project) === null || _46 === void 0 ? void 0 : _46.name) || "OneUptime", alertEpisodeViewLink: (await AlertEpisodeService.getEpisodeLinkInDashboard(alertEpisode.projectId, alertEpisode.id)).toString() }, (alertEpisode.episodeNumber !== undefined && {
|
|
1071
1220
|
episodeNumber: alertEpisode.episodeNumber,
|
|
1072
1221
|
})), (alertEpisode.episodeNumberWithPrefix && {
|
|
1073
1222
|
episodeNumberWithPrefix: alertEpisode.episodeNumberWithPrefix,
|
|
@@ -1117,7 +1266,7 @@ export class Service extends DatabaseService {
|
|
|
1117
1266
|
isRoot: true,
|
|
1118
1267
|
},
|
|
1119
1268
|
});
|
|
1120
|
-
const pushMessage = PushNotificationUtil.createIncidentEpisodeCreatedNotification(Object.assign(Object.assign(Object.assign({ incidentEpisodeTitle: incidentEpisode.title, projectName: ((
|
|
1269
|
+
const pushMessage = PushNotificationUtil.createIncidentEpisodeCreatedNotification(Object.assign(Object.assign(Object.assign({ incidentEpisodeTitle: incidentEpisode.title, projectName: ((_47 = incidentEpisode.project) === null || _47 === void 0 ? void 0 : _47.name) || "OneUptime", incidentEpisodeViewLink: (await IncidentEpisodeService.getEpisodeLinkInDashboard(incidentEpisode.projectId, incidentEpisode.id)).toString() }, (incidentEpisode.episodeNumber !== undefined && {
|
|
1121
1270
|
episodeNumber: incidentEpisode.episodeNumber,
|
|
1122
1271
|
})), (incidentEpisode.episodeNumberWithPrefix && {
|
|
1123
1272
|
episodeNumberWithPrefix: incidentEpisode.episodeNumberWithPrefix,
|
|
@@ -1154,8 +1303,8 @@ export class Service extends DatabaseService {
|
|
|
1154
1303
|
});
|
|
1155
1304
|
}
|
|
1156
1305
|
}
|
|
1157
|
-
if (((
|
|
1158
|
-
!((
|
|
1306
|
+
if (((_48 = notificationRuleItem.userPush) === null || _48 === void 0 ? void 0 : _48.deviceToken) &&
|
|
1307
|
+
!((_49 = notificationRuleItem.userPush) === null || _49 === void 0 ? void 0 : _49.isVerified)) {
|
|
1159
1308
|
// create a log.
|
|
1160
1309
|
logTimelineItem.status = UserNotificationStatus.Error;
|
|
1161
1310
|
logTimelineItem.statusMessage = `Push notification not sent because device is not verified.`;
|
|
@@ -1798,10 +1947,12 @@ export class Service extends DatabaseService {
|
|
|
1798
1947
|
!createBy.data.userWhatsAppId &&
|
|
1799
1948
|
!createBy.data.userTelegram &&
|
|
1800
1949
|
!createBy.data.userTelegramId &&
|
|
1950
|
+
!createBy.data.userWebhook &&
|
|
1951
|
+
!createBy.data.userWebhookId &&
|
|
1801
1952
|
!createBy.data.userEmailId &&
|
|
1802
1953
|
!createBy.data.userPushId &&
|
|
1803
1954
|
!createBy.data.userPush) {
|
|
1804
|
-
throw new BadDataException("Call, SMS, WhatsApp, Telegram, Email, or Push notification is required");
|
|
1955
|
+
throw new BadDataException("Call, SMS, WhatsApp, Telegram, Webhook, Email, or Push notification is required");
|
|
1805
1956
|
}
|
|
1806
1957
|
return {
|
|
1807
1958
|
createBy,
|
|
@@ -1833,6 +1984,9 @@ export class Service extends DatabaseService {
|
|
|
1833
1984
|
if (descriptor.userTelegramId) {
|
|
1834
1985
|
rule.userTelegramId = descriptor.userTelegramId;
|
|
1835
1986
|
}
|
|
1987
|
+
if (descriptor.userWebhookId) {
|
|
1988
|
+
rule.userWebhookId = descriptor.userWebhookId;
|
|
1989
|
+
}
|
|
1836
1990
|
if (descriptor.userPushId) {
|
|
1837
1991
|
rule.userPushId = descriptor.userPushId;
|
|
1838
1992
|
}
|
|
@@ -1854,6 +2008,9 @@ export class Service extends DatabaseService {
|
|
|
1854
2008
|
if (descriptor.userTelegramId) {
|
|
1855
2009
|
query["userTelegramId"] = descriptor.userTelegramId;
|
|
1856
2010
|
}
|
|
2011
|
+
if (descriptor.userWebhookId) {
|
|
2012
|
+
query["userWebhookId"] = descriptor.userWebhookId;
|
|
2013
|
+
}
|
|
1857
2014
|
if (descriptor.userPushId) {
|
|
1858
2015
|
query["userPushId"] = descriptor.userPushId;
|
|
1859
2016
|
}
|