@oneuptime/common 8.0.5312 → 8.0.5326

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.
Files changed (124) hide show
  1. package/Models/DatabaseModels/GlobalConfig.ts +90 -0
  2. package/Models/DatabaseModels/Index.ts +4 -0
  3. package/Models/DatabaseModels/Project.ts +27 -0
  4. package/Models/DatabaseModels/UserNotificationRule.ts +48 -0
  5. package/Models/DatabaseModels/UserNotificationSetting.ts +16 -0
  6. package/Models/DatabaseModels/UserOnCallLogTimeline.ts +48 -0
  7. package/Models/DatabaseModels/UserWhatsApp.ts +288 -0
  8. package/Models/DatabaseModels/WhatsAppLog.ts +884 -0
  9. package/Server/API/NotificationAPI.ts +4 -4
  10. package/Server/API/ProjectSSO.ts +41 -33
  11. package/Server/API/ShortLinkAPI.ts +33 -25
  12. package/Server/API/UserCallAPI.ts +82 -73
  13. package/Server/API/UserEmailAPI.ts +82 -73
  14. package/Server/API/UserOnCallLogTimelineAPI.ts +227 -214
  15. package/Server/API/UserPushAPI.ts +177 -169
  16. package/Server/API/UserSmsAPI.ts +82 -73
  17. package/Server/API/UserWhatsAppAPI.ts +136 -0
  18. package/Server/Infrastructure/Postgres/SchemaMigrations/1759838763506-MigrationName.ts +105 -0
  19. package/Server/Infrastructure/Postgres/SchemaMigrations/1759839342566-MigrationName.ts +71 -0
  20. package/Server/Infrastructure/Postgres/SchemaMigrations/Index.ts +4 -0
  21. package/Server/Services/Index.ts +4 -0
  22. package/Server/Services/MonitorService.ts +32 -4
  23. package/Server/Services/OnCallDutyPolicyEscalationRuleScheduleService.ts +36 -4
  24. package/Server/Services/OnCallDutyPolicyEscalationRuleTeamService.ts +34 -4
  25. package/Server/Services/OnCallDutyPolicyEscalationRuleUserService.ts +34 -4
  26. package/Server/Services/OnCallDutyPolicyScheduleService.ts +47 -6
  27. package/Server/Services/ProbeService.ts +17 -2
  28. package/Server/Services/UserNotificationRuleService.ts +258 -7
  29. package/Server/Services/UserNotificationSettingService.ts +60 -0
  30. package/Server/Services/UserWhatsAppService.ts +203 -0
  31. package/Server/Services/WhatsAppLogService.ts +15 -0
  32. package/Server/Services/WhatsAppService.ts +141 -0
  33. package/Server/Types/Workflow/Components/BaseModel/OnTriggerBaseModel.ts +17 -5
  34. package/Server/Types/Workflow/Components/Webhook.ts +2 -2
  35. package/Server/Utils/StartServer.ts +57 -31
  36. package/Server/Utils/WhatsAppTemplateUtil.ts +247 -0
  37. package/Types/Icon/IconProp.ts +1 -0
  38. package/Types/WhatsApp/WhatsAppMessage.ts +12 -0
  39. package/Types/WhatsApp/WhatsAppTemplates.ts +197 -0
  40. package/Types/WhatsAppStatus.ts +8 -0
  41. package/UI/Components/Icon/Icon.tsx +12 -0
  42. package/build/dist/Models/DatabaseModels/GlobalConfig.js +98 -0
  43. package/build/dist/Models/DatabaseModels/GlobalConfig.js.map +1 -1
  44. package/build/dist/Models/DatabaseModels/Index.js +4 -0
  45. package/build/dist/Models/DatabaseModels/Index.js.map +1 -1
  46. package/build/dist/Models/DatabaseModels/Project.js +29 -0
  47. package/build/dist/Models/DatabaseModels/Project.js.map +1 -1
  48. package/build/dist/Models/DatabaseModels/UserNotificationRule.js +48 -0
  49. package/build/dist/Models/DatabaseModels/UserNotificationRule.js.map +1 -1
  50. package/build/dist/Models/DatabaseModels/UserNotificationSetting.js +18 -0
  51. package/build/dist/Models/DatabaseModels/UserNotificationSetting.js.map +1 -1
  52. package/build/dist/Models/DatabaseModels/UserOnCallLogTimeline.js +48 -0
  53. package/build/dist/Models/DatabaseModels/UserOnCallLogTimeline.js.map +1 -1
  54. package/build/dist/Models/DatabaseModels/UserWhatsApp.js +308 -0
  55. package/build/dist/Models/DatabaseModels/UserWhatsApp.js.map +1 -0
  56. package/build/dist/Models/DatabaseModels/WhatsAppLog.js +911 -0
  57. package/build/dist/Models/DatabaseModels/WhatsAppLog.js.map +1 -0
  58. package/build/dist/Server/API/NotificationAPI.js +2 -2
  59. package/build/dist/Server/API/NotificationAPI.js.map +1 -1
  60. package/build/dist/Server/API/ProjectSSO.js +26 -21
  61. package/build/dist/Server/API/ProjectSSO.js.map +1 -1
  62. package/build/dist/Server/API/ShortLinkAPI.js +17 -12
  63. package/build/dist/Server/API/ShortLinkAPI.js.map +1 -1
  64. package/build/dist/Server/API/UserCallAPI.js +54 -44
  65. package/build/dist/Server/API/UserCallAPI.js.map +1 -1
  66. package/build/dist/Server/API/UserEmailAPI.js +54 -44
  67. package/build/dist/Server/API/UserEmailAPI.js.map +1 -1
  68. package/build/dist/Server/API/UserOnCallLogTimelineAPI.js +142 -127
  69. package/build/dist/Server/API/UserOnCallLogTimelineAPI.js.map +1 -1
  70. package/build/dist/Server/API/UserPushAPI.js +111 -96
  71. package/build/dist/Server/API/UserPushAPI.js.map +1 -1
  72. package/build/dist/Server/API/UserSmsAPI.js +54 -44
  73. package/build/dist/Server/API/UserSmsAPI.js.map +1 -1
  74. package/build/dist/Server/API/UserWhatsAppAPI.js +76 -0
  75. package/build/dist/Server/API/UserWhatsAppAPI.js.map +1 -0
  76. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1759838763506-MigrationName.js +42 -0
  77. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1759838763506-MigrationName.js.map +1 -0
  78. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1759839342566-MigrationName.js +30 -0
  79. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1759839342566-MigrationName.js.map +1 -0
  80. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/Index.js +4 -0
  81. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/Index.js.map +1 -1
  82. package/build/dist/Server/Services/Index.js +4 -0
  83. package/build/dist/Server/Services/Index.js.map +1 -1
  84. package/build/dist/Server/Services/MonitorService.js +23 -2
  85. package/build/dist/Server/Services/MonitorService.js.map +1 -1
  86. package/build/dist/Server/Services/OnCallDutyPolicyEscalationRuleScheduleService.js +29 -6
  87. package/build/dist/Server/Services/OnCallDutyPolicyEscalationRuleScheduleService.js.map +1 -1
  88. package/build/dist/Server/Services/OnCallDutyPolicyEscalationRuleTeamService.js +27 -6
  89. package/build/dist/Server/Services/OnCallDutyPolicyEscalationRuleTeamService.js.map +1 -1
  90. package/build/dist/Server/Services/OnCallDutyPolicyEscalationRuleUserService.js +26 -5
  91. package/build/dist/Server/Services/OnCallDutyPolicyEscalationRuleUserService.js.map +1 -1
  92. package/build/dist/Server/Services/OnCallDutyPolicyScheduleService.js +34 -3
  93. package/build/dist/Server/Services/OnCallDutyPolicyScheduleService.js.map +1 -1
  94. package/build/dist/Server/Services/ProbeService.js +12 -1
  95. package/build/dist/Server/Services/ProbeService.js.map +1 -1
  96. package/build/dist/Server/Services/UserNotificationRuleService.js +196 -19
  97. package/build/dist/Server/Services/UserNotificationRuleService.js.map +1 -1
  98. package/build/dist/Server/Services/UserNotificationSettingService.js +45 -0
  99. package/build/dist/Server/Services/UserNotificationSettingService.js.map +1 -1
  100. package/build/dist/Server/Services/UserWhatsAppService.js +179 -0
  101. package/build/dist/Server/Services/UserWhatsAppService.js.map +1 -0
  102. package/build/dist/Server/Services/WhatsAppLogService.js +13 -0
  103. package/build/dist/Server/Services/WhatsAppLogService.js.map +1 -0
  104. package/build/dist/Server/Services/WhatsAppService.js +103 -0
  105. package/build/dist/Server/Services/WhatsAppService.js.map +1 -0
  106. package/build/dist/Server/Types/Workflow/Components/BaseModel/OnTriggerBaseModel.js +14 -4
  107. package/build/dist/Server/Types/Workflow/Components/BaseModel/OnTriggerBaseModel.js.map +1 -1
  108. package/build/dist/Server/Types/Workflow/Components/Webhook.js +2 -2
  109. package/build/dist/Server/Types/Workflow/Components/Webhook.js.map +1 -1
  110. package/build/dist/Server/Utils/StartServer.js +41 -19
  111. package/build/dist/Server/Utils/StartServer.js.map +1 -1
  112. package/build/dist/Server/Utils/WhatsAppTemplateUtil.js +124 -0
  113. package/build/dist/Server/Utils/WhatsAppTemplateUtil.js.map +1 -0
  114. package/build/dist/Types/Icon/IconProp.js +1 -0
  115. package/build/dist/Types/Icon/IconProp.js.map +1 -1
  116. package/build/dist/Types/WhatsApp/WhatsAppMessage.js +2 -0
  117. package/build/dist/Types/WhatsApp/WhatsAppMessage.js.map +1 -0
  118. package/build/dist/Types/WhatsApp/WhatsAppTemplates.js +118 -0
  119. package/build/dist/Types/WhatsApp/WhatsAppTemplates.js.map +1 -0
  120. package/build/dist/Types/WhatsAppStatus.js +9 -0
  121. package/build/dist/Types/WhatsAppStatus.js.map +1 -0
  122. package/build/dist/UI/Components/Icon/Icon.js +6 -0
  123. package/build/dist/UI/Components/Icon/Icon.js.map +1 -1
  124. package/package.json +1 -1
@@ -0,0 +1,136 @@
1
+ import UserMiddleware from "../Middleware/UserAuthorization";
2
+ import UserWhatsAppService, {
3
+ Service as UserWhatsAppServiceType,
4
+ } from "../Services/UserWhatsAppService";
5
+ import {
6
+ ExpressRequest,
7
+ ExpressResponse,
8
+ NextFunction,
9
+ OneUptimeRequest,
10
+ } from "../Utils/Express";
11
+ import Response from "../Utils/Response";
12
+ import BaseAPI from "./BaseAPI";
13
+ import BadDataException from "../../Types/Exception/BadDataException";
14
+ import UserWhatsApp from "../../Models/DatabaseModels/UserWhatsApp";
15
+
16
+ export default class UserWhatsAppAPI extends BaseAPI<
17
+ UserWhatsApp,
18
+ UserWhatsAppServiceType
19
+ > {
20
+ public constructor() {
21
+ super(UserWhatsApp, UserWhatsAppService);
22
+
23
+ this.router.post(
24
+ `${new this.entityType().getCrudApiPath()?.toString()}/verify`,
25
+ UserMiddleware.getUserMiddleware,
26
+ async (req: ExpressRequest, res: ExpressResponse, next: NextFunction) => {
27
+ try {
28
+ req = req as OneUptimeRequest;
29
+
30
+ if (!req.body.itemId) {
31
+ return Response.sendErrorResponse(
32
+ req,
33
+ res,
34
+ new BadDataException("Invalid item ID"),
35
+ );
36
+ }
37
+
38
+ if (!req.body.code) {
39
+ return Response.sendErrorResponse(
40
+ req,
41
+ res,
42
+ new BadDataException("Invalid code"),
43
+ );
44
+ }
45
+
46
+ const item: UserWhatsApp | null = await this.service.findOneById({
47
+ id: req.body["itemId"],
48
+ props: {
49
+ isRoot: true,
50
+ },
51
+ select: {
52
+ userId: true,
53
+ verificationCode: true,
54
+ isVerified: true,
55
+ },
56
+ });
57
+
58
+ if (!item) {
59
+ return Response.sendErrorResponse(
60
+ req,
61
+ res,
62
+ new BadDataException("Item not found"),
63
+ );
64
+ }
65
+
66
+ if (item.isVerified) {
67
+ return Response.sendErrorResponse(
68
+ req,
69
+ res,
70
+ new BadDataException("WhatsApp number already verified"),
71
+ );
72
+ }
73
+
74
+ if (
75
+ item.userId?.toString() !==
76
+ (req as OneUptimeRequest)?.userAuthorization?.userId?.toString()
77
+ ) {
78
+ return Response.sendErrorResponse(
79
+ req,
80
+ res,
81
+ new BadDataException("Invalid user ID"),
82
+ );
83
+ }
84
+
85
+ if (item.verificationCode !== req.body["code"]) {
86
+ return Response.sendErrorResponse(
87
+ req,
88
+ res,
89
+ new BadDataException("Invalid code"),
90
+ );
91
+ }
92
+
93
+ await this.service.updateOneById({
94
+ id: item.id!,
95
+ props: {
96
+ isRoot: true,
97
+ },
98
+ data: {
99
+ isVerified: true,
100
+ },
101
+ });
102
+
103
+ return Response.sendEmptySuccessResponse(req, res);
104
+ } catch (err) {
105
+ return next(err);
106
+ }
107
+ },
108
+ );
109
+
110
+ this.router.post(
111
+ `${new this.entityType()
112
+ .getCrudApiPath()
113
+ ?.toString()}/resend-verification-code`,
114
+ UserMiddleware.getUserMiddleware,
115
+ async (req: ExpressRequest, res: ExpressResponse, next: NextFunction) => {
116
+ try {
117
+ req = req as OneUptimeRequest;
118
+
119
+ if (!req.body.itemId) {
120
+ return Response.sendErrorResponse(
121
+ req,
122
+ res,
123
+ new BadDataException("Invalid item ID"),
124
+ );
125
+ }
126
+
127
+ await this.service.resendVerificationCode(req.body.itemId);
128
+
129
+ return Response.sendEmptySuccessResponse(req, res);
130
+ } catch (err) {
131
+ return next(err);
132
+ }
133
+ },
134
+ );
135
+ }
136
+ }
@@ -0,0 +1,105 @@
1
+ import { MigrationInterface, QueryRunner } from "typeorm";
2
+
3
+ export class MigrationName1759838763506 implements MigrationInterface {
4
+ public name = "MigrationName1759838763506";
5
+
6
+ public async up(queryRunner: QueryRunner): Promise<void> {
7
+ await queryRunner.query(
8
+ `ALTER TABLE "WhatsAppLog" DROP COLUMN "whatsAppText"`,
9
+ );
10
+ await queryRunner.query(
11
+ `ALTER TABLE "Project" ADD "enableWhatsAppNotifications" boolean NOT NULL DEFAULT false`,
12
+ );
13
+ await queryRunner.query(`ALTER TABLE "WhatsAppLog" ADD "messageText" text`);
14
+ await queryRunner.query(
15
+ `ALTER TABLE "UserNotificationRule" ADD "userWhatsAppId" uuid`,
16
+ );
17
+ await queryRunner.query(
18
+ `ALTER TABLE "UserNotificationSetting" ADD "alertByWhatsApp" boolean NOT NULL DEFAULT false`,
19
+ );
20
+ await queryRunner.query(
21
+ `ALTER TABLE "UserOnCallLogTimeline" ADD "userWhatsAppId" uuid`,
22
+ );
23
+ await queryRunner.query(
24
+ `ALTER TABLE "OnCallDutyPolicyScheduleLayer" ALTER COLUMN "rotation" SET DEFAULT '{"_type":"Recurring","value":{"intervalType":"Day","intervalCount":{"_type":"PositiveNumber","value":1}}}'`,
25
+ );
26
+ await queryRunner.query(
27
+ `ALTER TABLE "OnCallDutyPolicyScheduleLayer" ALTER COLUMN "restrictionTimes" SET DEFAULT '{"_type":"RestrictionTimes","value":{"restictionType":"None","dayRestrictionTimes":null,"weeklyRestrictionTimes":[]}}'`,
28
+ );
29
+ await queryRunner.query(
30
+ `ALTER TABLE "WhatsAppLog" ALTER COLUMN "whatsAppCostInUSDCents" SET NOT NULL`,
31
+ );
32
+ await queryRunner.query(
33
+ `ALTER TABLE "WhatsAppLog" ALTER COLUMN "whatsAppCostInUSDCents" SET DEFAULT '0'`,
34
+ );
35
+ await queryRunner.query(
36
+ `ALTER TABLE "UserWhatsApp" ALTER COLUMN "verificationCode" SET NOT NULL`,
37
+ );
38
+ await queryRunner.query(
39
+ `CREATE INDEX "IDX_98e71cf97956e7938195be8451" ON "WhatsAppLog" ("whatsAppCostInUSDCents") `,
40
+ );
41
+ await queryRunner.query(
42
+ `CREATE INDEX "IDX_73297560a1a70e4fe47eac2986" ON "UserNotificationRule" ("userWhatsAppId") `,
43
+ );
44
+ await queryRunner.query(
45
+ `CREATE INDEX "IDX_0a67c82e4e093ae5c89d2d76bd" ON "UserOnCallLogTimeline" ("userWhatsAppId") `,
46
+ );
47
+ await queryRunner.query(
48
+ `ALTER TABLE "UserNotificationRule" ADD CONSTRAINT "FK_73297560a1a70e4fe47eac29861" FOREIGN KEY ("userWhatsAppId") REFERENCES "UserWhatsApp"("_id") ON DELETE CASCADE ON UPDATE NO ACTION`,
49
+ );
50
+ await queryRunner.query(
51
+ `ALTER TABLE "UserOnCallLogTimeline" ADD CONSTRAINT "FK_0a67c82e4e093ae5c89d2d76bdf" FOREIGN KEY ("userWhatsAppId") REFERENCES "UserWhatsApp"("_id") ON DELETE CASCADE ON UPDATE NO ACTION`,
52
+ );
53
+ }
54
+
55
+ public async down(queryRunner: QueryRunner): Promise<void> {
56
+ await queryRunner.query(
57
+ `ALTER TABLE "UserOnCallLogTimeline" DROP CONSTRAINT "FK_0a67c82e4e093ae5c89d2d76bdf"`,
58
+ );
59
+ await queryRunner.query(
60
+ `ALTER TABLE "UserNotificationRule" DROP CONSTRAINT "FK_73297560a1a70e4fe47eac29861"`,
61
+ );
62
+ await queryRunner.query(
63
+ `DROP INDEX "public"."IDX_0a67c82e4e093ae5c89d2d76bd"`,
64
+ );
65
+ await queryRunner.query(
66
+ `DROP INDEX "public"."IDX_73297560a1a70e4fe47eac2986"`,
67
+ );
68
+ await queryRunner.query(
69
+ `DROP INDEX "public"."IDX_98e71cf97956e7938195be8451"`,
70
+ );
71
+ await queryRunner.query(
72
+ `ALTER TABLE "UserWhatsApp" ALTER COLUMN "verificationCode" DROP NOT NULL`,
73
+ );
74
+ await queryRunner.query(
75
+ `ALTER TABLE "WhatsAppLog" ALTER COLUMN "whatsAppCostInUSDCents" DROP DEFAULT`,
76
+ );
77
+ await queryRunner.query(
78
+ `ALTER TABLE "WhatsAppLog" ALTER COLUMN "whatsAppCostInUSDCents" DROP NOT NULL`,
79
+ );
80
+ await queryRunner.query(
81
+ `ALTER TABLE "OnCallDutyPolicyScheduleLayer" ALTER COLUMN "restrictionTimes" SET DEFAULT '{"_type": "RestrictionTimes", "value": {"restictionType": "None", "dayRestrictionTimes": null, "weeklyRestrictionTimes": []}}'`,
82
+ );
83
+ await queryRunner.query(
84
+ `ALTER TABLE "OnCallDutyPolicyScheduleLayer" ALTER COLUMN "rotation" SET DEFAULT '{"_type": "Recurring", "value": {"intervalType": "Day", "intervalCount": {"_type": "PositiveNumber", "value": 1}}}'`,
85
+ );
86
+ await queryRunner.query(
87
+ `ALTER TABLE "UserOnCallLogTimeline" DROP COLUMN "userWhatsAppId"`,
88
+ );
89
+ await queryRunner.query(
90
+ `ALTER TABLE "UserNotificationSetting" DROP COLUMN "alertByWhatsApp"`,
91
+ );
92
+ await queryRunner.query(
93
+ `ALTER TABLE "UserNotificationRule" DROP COLUMN "userWhatsAppId"`,
94
+ );
95
+ await queryRunner.query(
96
+ `ALTER TABLE "WhatsAppLog" DROP COLUMN "messageText"`,
97
+ );
98
+ await queryRunner.query(
99
+ `ALTER TABLE "Project" DROP COLUMN "enableWhatsAppNotifications"`,
100
+ );
101
+ await queryRunner.query(
102
+ `ALTER TABLE "WhatsAppLog" ADD "whatsAppText" character varying(500) NOT NULL`,
103
+ );
104
+ }
105
+ }
@@ -0,0 +1,71 @@
1
+ import { MigrationInterface, QueryRunner } from "typeorm";
2
+
3
+ export class MigrationName1759839342566 implements MigrationInterface {
4
+ public name = "MigrationName1759839342566";
5
+
6
+ public async up(queryRunner: QueryRunner): Promise<void> {
7
+ await queryRunner.query(
8
+ `ALTER TABLE "GlobalConfig" ADD "metaWhatsAppAccessToken" text`,
9
+ );
10
+ await queryRunner.query(
11
+ `ALTER TABLE "GlobalConfig" ADD CONSTRAINT "UQ_83bd5d0c54a21bfe12316fa6520" UNIQUE ("metaWhatsAppAccessToken")`,
12
+ );
13
+ await queryRunner.query(
14
+ `ALTER TABLE "GlobalConfig" ADD "metaWhatsAppPhoneNumberId" character varying(100)`,
15
+ );
16
+ await queryRunner.query(
17
+ `ALTER TABLE "GlobalConfig" ADD CONSTRAINT "UQ_ef032cda9dd2fac68daeedd7bd2" UNIQUE ("metaWhatsAppPhoneNumberId")`,
18
+ );
19
+ await queryRunner.query(
20
+ `ALTER TABLE "GlobalConfig" ADD "metaWhatsAppBusinessAccountId" character varying(100)`,
21
+ );
22
+ await queryRunner.query(
23
+ `ALTER TABLE "GlobalConfig" ADD CONSTRAINT "UQ_607e6e88215689951d9b3645f00" UNIQUE ("metaWhatsAppBusinessAccountId")`,
24
+ );
25
+ await queryRunner.query(
26
+ `ALTER TABLE "GlobalConfig" ADD "metaWhatsAppAppId" character varying(100)`,
27
+ );
28
+ await queryRunner.query(
29
+ `ALTER TABLE "GlobalConfig" ADD CONSTRAINT "UQ_e67fd0998ca781ec7db0e573e91" UNIQUE ("metaWhatsAppAppId")`,
30
+ );
31
+ await queryRunner.query(
32
+ `ALTER TABLE "GlobalConfig" ADD "metaWhatsAppAppSecret" text`,
33
+ );
34
+ await queryRunner.query(
35
+ `ALTER TABLE "GlobalConfig" ADD CONSTRAINT "UQ_d4669bf754f937bae16c4a1837c" UNIQUE ("metaWhatsAppAppSecret")`,
36
+ );
37
+ }
38
+
39
+ public async down(queryRunner: QueryRunner): Promise<void> {
40
+ await queryRunner.query(
41
+ `ALTER TABLE "GlobalConfig" DROP CONSTRAINT "UQ_d4669bf754f937bae16c4a1837c"`,
42
+ );
43
+ await queryRunner.query(
44
+ `ALTER TABLE "GlobalConfig" DROP COLUMN "metaWhatsAppAppSecret"`,
45
+ );
46
+ await queryRunner.query(
47
+ `ALTER TABLE "GlobalConfig" DROP CONSTRAINT "UQ_e67fd0998ca781ec7db0e573e91"`,
48
+ );
49
+ await queryRunner.query(
50
+ `ALTER TABLE "GlobalConfig" DROP COLUMN "metaWhatsAppAppId"`,
51
+ );
52
+ await queryRunner.query(
53
+ `ALTER TABLE "GlobalConfig" DROP CONSTRAINT "UQ_607e6e88215689951d9b3645f00"`,
54
+ );
55
+ await queryRunner.query(
56
+ `ALTER TABLE "GlobalConfig" DROP COLUMN "metaWhatsAppBusinessAccountId"`,
57
+ );
58
+ await queryRunner.query(
59
+ `ALTER TABLE "GlobalConfig" DROP CONSTRAINT "UQ_ef032cda9dd2fac68daeedd7bd2"`,
60
+ );
61
+ await queryRunner.query(
62
+ `ALTER TABLE "GlobalConfig" DROP COLUMN "metaWhatsAppPhoneNumberId"`,
63
+ );
64
+ await queryRunner.query(
65
+ `ALTER TABLE "GlobalConfig" DROP CONSTRAINT "UQ_83bd5d0c54a21bfe12316fa6520"`,
66
+ );
67
+ await queryRunner.query(
68
+ `ALTER TABLE "GlobalConfig" DROP COLUMN "metaWhatsAppAccessToken"`,
69
+ );
70
+ }
71
+ }
@@ -174,6 +174,8 @@ import { MigrationName1758798730753 } from "./1758798730753-MigrationName";
174
174
  import { MigrationName1759175457008 } from "./1759175457008-MigrationName";
175
175
  import { MigrationName1759232954703 } from "./1759232954703-MigrationName";
176
176
  import { RenameUserTwoFactorAuthToUserTotpAuth1759234532998 } from "./1759234532998-MigrationName";
177
+ import { MigrationName1759838763506 } from "./1759838763506-MigrationName";
178
+ import { MigrationName1759839342566 } from "./1759839342566-MigrationName";
177
179
 
178
180
  export default [
179
181
  InitialMigration,
@@ -352,4 +354,6 @@ export default [
352
354
  MigrationName1759175457008,
353
355
  MigrationName1759232954703,
354
356
  RenameUserTwoFactorAuthToUserTotpAuth1759234532998,
357
+ MigrationName1759838763506,
358
+ MigrationName1759839342566,
355
359
  ];
@@ -91,6 +91,7 @@ import ServiceCopilotCodeRepositoryService from "./ServiceCopilotCodeRepositoryS
91
91
  import ShortLinkService from "./ShortLinkService";
92
92
  // SMS Log Service
93
93
  import SmsLogService from "./SmsLogService";
94
+ import WhatsAppLogService from "./WhatsAppLogService";
94
95
  import SmsService from "./SmsService";
95
96
  import SpanService from "./SpanService";
96
97
  import StatusPageAnnouncementService from "./StatusPageAnnouncementService";
@@ -126,6 +127,7 @@ import UserService from "./UserService";
126
127
  import UserTotpAuthService from "./UserTotpAuthService";
127
128
  import UserWebAuthnService from "./UserWebAuthnService";
128
129
  import UserSmsService from "./UserSmsService";
130
+ import UserWhatsAppService from "./UserWhatsAppService";
129
131
  import WorkflowLogService from "./WorkflowLogService";
130
132
  // Workflows.
131
133
  import WorkflowService from "./WorkflowService";
@@ -250,6 +252,7 @@ const services: Array<BaseService> = [
250
252
 
251
253
  ShortLinkService,
252
254
  SmsLogService,
255
+ WhatsAppLogService,
253
256
  SmsService,
254
257
 
255
258
  StatusPageAnnouncementService,
@@ -281,6 +284,7 @@ const services: Array<BaseService> = [
281
284
  UserOnCallLogService,
282
285
  UserOnCallLogTimelineService,
283
286
  UserSmsService,
287
+ UserWhatsAppService,
284
288
  UserTotpAuthService,
285
289
  UserWebAuthnService,
286
290
 
@@ -69,6 +69,8 @@ import logger from "../Utils/Logger";
69
69
  import PushNotificationUtil from "../Utils/PushNotificationUtil";
70
70
  import ExceptionMessages from "../../Types/Exception/ExceptionMessages";
71
71
  import Project from "../../Models/DatabaseModels/Project";
72
+ import { createWhatsAppMessageFromTemplate } from "../Utils/WhatsAppTemplateUtil";
73
+ import { WhatsAppMessagePayload } from "../../Types/WhatsApp/WhatsAppMessage";
72
74
 
73
75
  export class Service extends DatabaseService<Model> {
74
76
  public constructor() {
@@ -1191,6 +1193,19 @@ ${createdItem.description?.trim() || "No description provided."}
1191
1193
  ],
1192
1194
  };
1193
1195
 
1196
+ const eventType: NotificationSettingEventType =
1197
+ NotificationSettingEventType.SEND_MONITOR_NOTIFICATION_WHEN_NO_PROBES_ARE_MONITORING_THE_MONITOR;
1198
+
1199
+ const whatsAppMessage: WhatsAppMessagePayload =
1200
+ createWhatsAppMessageFromTemplate({
1201
+ eventType,
1202
+ templateVariables: {
1203
+ monitor_name: monitor.name!,
1204
+ probe_status: enabledStatus,
1205
+ monitor_link: vars["monitorViewLink"] || "",
1206
+ },
1207
+ });
1208
+
1194
1209
  await UserNotificationSettingService.sendUserNotification({
1195
1210
  userId: owner.id!,
1196
1211
  projectId: monitor.projectId!,
@@ -1205,8 +1220,8 @@ ${createdItem.description?.trim() || "No description provided."}
1205
1220
  monitorId: monitor.id!.toString(),
1206
1221
  monitorName: monitor.name!,
1207
1222
  }),
1208
- eventType:
1209
- NotificationSettingEventType.SEND_MONITOR_NOTIFICATION_WHEN_NO_PROBES_ARE_MONITORING_THE_MONITOR,
1223
+ whatsAppMessage,
1224
+ eventType,
1210
1225
  });
1211
1226
  }
1212
1227
  }
@@ -1298,6 +1313,19 @@ ${createdItem.description?.trim() || "No description provided."}
1298
1313
  ],
1299
1314
  };
1300
1315
 
1316
+ const eventType: NotificationSettingEventType =
1317
+ NotificationSettingEventType.SEND_MONITOR_NOTIFICATION_WHEN_PORBE_STATUS_CHANGES;
1318
+
1319
+ const whatsAppMessage: WhatsAppMessagePayload =
1320
+ createWhatsAppMessageFromTemplate({
1321
+ eventType,
1322
+ templateVariables: {
1323
+ monitor_name: monitor.name!,
1324
+ probe_status: status,
1325
+ monitor_link: vars["monitorViewLink"] || "",
1326
+ },
1327
+ });
1328
+
1301
1329
  await UserNotificationSettingService.sendUserNotification({
1302
1330
  userId: owner.id!,
1303
1331
  projectId: monitor.projectId!,
@@ -1309,8 +1337,8 @@ ${createdItem.description?.trim() || "No description provided."}
1309
1337
  monitorName: monitor.name!,
1310
1338
  monitorId: monitor.id!.toString(),
1311
1339
  }),
1312
- eventType:
1313
- NotificationSettingEventType.SEND_MONITOR_NOTIFICATION_WHEN_PORBE_STATUS_CHANGES,
1340
+ whatsAppMessage,
1341
+ eventType,
1314
1342
  });
1315
1343
  }
1316
1344
  }
@@ -20,6 +20,8 @@ import { OnCallDutyPolicyFeedEventType } from "../../Models/DatabaseModels/OnCal
20
20
  import { Gray500, Red500 } from "../../Types/BrandColors";
21
21
  import PushNotificationMessage from "../../Types/PushNotification/PushNotificationMessage";
22
22
  import PushNotificationUtil from "../Utils/PushNotificationUtil";
23
+ import { createWhatsAppMessageFromTemplate } from "../Utils/WhatsAppTemplateUtil";
24
+ import { WhatsAppMessagePayload } from "../../Types/WhatsApp/WhatsAppMessage";
23
25
 
24
26
  export class Service extends DatabaseService<Model> {
25
27
  public constructor() {
@@ -135,6 +137,21 @@ export class Service extends DatabaseService<Model> {
135
137
  policyName: createdModel.onCallDutyPolicy?.name || "No name provided",
136
138
  });
137
139
 
140
+ const eventType: NotificationSettingEventType =
141
+ NotificationSettingEventType.SEND_WHEN_USER_IS_ADDED_TO_ON_CALL_POLICY;
142
+
143
+ const whatsAppMessage: WhatsAppMessagePayload =
144
+ createWhatsAppMessageFromTemplate({
145
+ eventType,
146
+ templateVariables: {
147
+ on_call_policy_name:
148
+ createdModel.onCallDutyPolicy?.name || "No name provided",
149
+ schedule_name: scheduleName,
150
+ on_call_context: `schedule ${scheduleName}`,
151
+ policy_link: vars["onCallPolicyViewLink"] || "",
152
+ },
153
+ });
154
+
138
155
  await UserNotificationSettingService.sendUserNotification({
139
156
  userId: sendEmailToUserId,
140
157
  projectId: createdModel!.projectId!,
@@ -142,8 +159,8 @@ export class Service extends DatabaseService<Model> {
142
159
  smsMessage: sms,
143
160
  callRequestMessage: callMessage,
144
161
  pushNotificationMessage: pushMessage,
145
- eventType:
146
- NotificationSettingEventType.SEND_WHEN_USER_IS_ADDED_TO_ON_CALL_POLICY,
162
+ whatsAppMessage,
163
+ eventType,
147
164
  });
148
165
 
149
166
  // add workspace message.
@@ -317,6 +334,21 @@ export class Service extends DatabaseService<Model> {
317
334
  policyName: deletedItem.onCallDutyPolicy?.name || "No name provided",
318
335
  });
319
336
 
337
+ const eventType: NotificationSettingEventType =
338
+ NotificationSettingEventType.SEND_WHEN_USER_IS_REMOVED_FROM_ON_CALL_POLICY;
339
+
340
+ const whatsAppMessage: WhatsAppMessagePayload =
341
+ createWhatsAppMessageFromTemplate({
342
+ eventType,
343
+ templateVariables: {
344
+ on_call_policy_name:
345
+ deletedItem.onCallDutyPolicy?.name || "No name provided",
346
+ schedule_name: scheduleName,
347
+ on_call_context: `schedule ${scheduleName}`,
348
+ policy_link: vars["onCallPolicyViewLink"] || "",
349
+ },
350
+ });
351
+
320
352
  await UserNotificationSettingService.sendUserNotification({
321
353
  userId: sendEmailToUserId,
322
354
  projectId: deletedItem!.projectId!,
@@ -324,8 +356,8 @@ export class Service extends DatabaseService<Model> {
324
356
  smsMessage: sms,
325
357
  callRequestMessage: callMessage,
326
358
  pushNotificationMessage: pushMessage,
327
- eventType:
328
- NotificationSettingEventType.SEND_WHEN_USER_IS_REMOVED_FROM_ON_CALL_POLICY,
359
+ whatsAppMessage,
360
+ eventType,
329
361
  });
330
362
  }
331
363
 
@@ -20,6 +20,8 @@ import { OnCallDutyPolicyFeedEventType } from "../../Models/DatabaseModels/OnCal
20
20
  import { Gray500, Red500 } from "../../Types/BrandColors";
21
21
  import PushNotificationMessage from "../../Types/PushNotification/PushNotificationMessage";
22
22
  import PushNotificationUtil from "../Utils/PushNotificationUtil";
23
+ import { createWhatsAppMessageFromTemplate } from "../Utils/WhatsAppTemplateUtil";
24
+ import { WhatsAppMessagePayload } from "../../Types/WhatsApp/WhatsAppMessage";
23
25
  import Team from "../../Models/DatabaseModels/Team";
24
26
  import OnCallDutyPolicyTimeLogService from "./OnCallDutyPolicyTimeLogService";
25
27
  import OneUptimeDate from "../../Types/Date";
@@ -134,6 +136,20 @@ export class Service extends DatabaseService<Model> {
134
136
  policyName: createdModel.onCallDutyPolicy?.name || "No name provided",
135
137
  });
136
138
 
139
+ const eventType: NotificationSettingEventType =
140
+ NotificationSettingEventType.SEND_WHEN_USER_IS_ADDED_TO_ON_CALL_POLICY;
141
+
142
+ const whatsAppMessage: WhatsAppMessagePayload =
143
+ createWhatsAppMessageFromTemplate({
144
+ eventType,
145
+ templateVariables: {
146
+ on_call_policy_name:
147
+ createdModel.onCallDutyPolicy?.name || "No name provided",
148
+ on_call_context: `team ${temaName}`,
149
+ policy_link: vars["onCallPolicyViewLink"] || "",
150
+ },
151
+ });
152
+
137
153
  await UserNotificationSettingService.sendUserNotification({
138
154
  userId: sendEmailToUserId,
139
155
  projectId: createdModel!.projectId!,
@@ -141,8 +157,8 @@ export class Service extends DatabaseService<Model> {
141
157
  smsMessage: sms,
142
158
  callRequestMessage: callMessage,
143
159
  pushNotificationMessage: pushMessage,
144
- eventType:
145
- NotificationSettingEventType.SEND_WHEN_USER_IS_ADDED_TO_ON_CALL_POLICY,
160
+ whatsAppMessage,
161
+ eventType,
146
162
  });
147
163
 
148
164
  // add start log
@@ -322,6 +338,20 @@ export class Service extends DatabaseService<Model> {
322
338
  deletedItem.onCallDutyPolicy?.name || "No name provided",
323
339
  });
324
340
 
341
+ const eventType: NotificationSettingEventType =
342
+ NotificationSettingEventType.SEND_WHEN_USER_IS_REMOVED_FROM_ON_CALL_POLICY;
343
+
344
+ const whatsAppMessage: WhatsAppMessagePayload =
345
+ createWhatsAppMessageFromTemplate({
346
+ eventType,
347
+ templateVariables: {
348
+ on_call_policy_name:
349
+ deletedItem.onCallDutyPolicy?.name || "No name provided",
350
+ on_call_context: `team ${teamName}`,
351
+ policy_link: vars["onCallPolicyViewLink"] || "",
352
+ },
353
+ });
354
+
325
355
  UserNotificationSettingService.sendUserNotification({
326
356
  userId: sendEmailToUserId,
327
357
  projectId: deletedItem!.projectId!,
@@ -329,8 +359,8 @@ export class Service extends DatabaseService<Model> {
329
359
  smsMessage: sms,
330
360
  callRequestMessage: callMessage,
331
361
  pushNotificationMessage: pushMessage,
332
- eventType:
333
- NotificationSettingEventType.SEND_WHEN_USER_IS_REMOVED_FROM_ON_CALL_POLICY,
362
+ whatsAppMessage,
363
+ eventType,
334
364
  });
335
365
 
336
366
  // end time log
@@ -22,7 +22,9 @@ import PushNotificationMessage from "../../Types/PushNotification/PushNotificati
22
22
  import PushNotificationUtil from "../Utils/PushNotificationUtil";
23
23
  import OnCallDutyPolicyTimeLogService from "./OnCallDutyPolicyTimeLogService";
24
24
  import OneUptimeDate from "../../Types/Date";
25
+ import { createWhatsAppMessageFromTemplate } from "../Utils/WhatsAppTemplateUtil";
25
26
  import logger from "../Utils/Logger";
27
+ import { WhatsAppMessagePayload } from "../../Types/WhatsApp/WhatsAppMessage";
26
28
 
27
29
  export class Service extends DatabaseService<Model> {
28
30
  public constructor() {
@@ -117,6 +119,20 @@ export class Service extends DatabaseService<Model> {
117
119
  policyName: createdModel.onCallDutyPolicy?.name || "",
118
120
  });
119
121
 
122
+ const eventType: NotificationSettingEventType =
123
+ NotificationSettingEventType.SEND_WHEN_USER_IS_ADDED_TO_ON_CALL_POLICY;
124
+
125
+ const whatsAppMessage: WhatsAppMessagePayload =
126
+ createWhatsAppMessageFromTemplate({
127
+ eventType,
128
+ templateVariables: {
129
+ on_call_policy_name:
130
+ createdModel.onCallDutyPolicy?.name || "No name provided",
131
+ on_call_context: `escalation rule ${createdModel.onCallDutyPolicyEscalationRule?.name || "No name provided"}`,
132
+ policy_link: vars["onCallPolicyViewLink"] || "",
133
+ },
134
+ });
135
+
120
136
  await UserNotificationSettingService.sendUserNotification({
121
137
  userId: sendEmailToUserId,
122
138
  projectId: createdModel!.projectId!,
@@ -124,8 +140,8 @@ export class Service extends DatabaseService<Model> {
124
140
  smsMessage: sms,
125
141
  callRequestMessage: callMessage,
126
142
  pushNotificationMessage: pushMessage,
127
- eventType:
128
- NotificationSettingEventType.SEND_WHEN_USER_IS_ADDED_TO_ON_CALL_POLICY,
143
+ whatsAppMessage,
144
+ eventType,
129
145
  onCallPolicyId: createdModel.onCallDutyPolicy!.id!,
130
146
  onCallPolicyEscalationRuleId:
131
147
  createdModel.onCallDutyPolicyEscalationRule!.id!,
@@ -322,6 +338,20 @@ export class Service extends DatabaseService<Model> {
322
338
  policyName: deletedItem.onCallDutyPolicy?.name || "",
323
339
  });
324
340
 
341
+ const eventType: NotificationSettingEventType =
342
+ NotificationSettingEventType.SEND_WHEN_USER_IS_REMOVED_FROM_ON_CALL_POLICY;
343
+
344
+ const whatsAppMessage: WhatsAppMessagePayload =
345
+ createWhatsAppMessageFromTemplate({
346
+ eventType,
347
+ templateVariables: {
348
+ on_call_policy_name:
349
+ deletedItem.onCallDutyPolicy?.name || "No name provided",
350
+ on_call_context: `escalation rule ${deletedItem.onCallDutyPolicyEscalationRule?.name || "No name provided"}`,
351
+ policy_link: vars["onCallPolicyViewLink"] || "",
352
+ },
353
+ });
354
+
325
355
  UserNotificationSettingService.sendUserNotification({
326
356
  userId: sendEmailToUserId,
327
357
  projectId: deletedItem!.projectId!,
@@ -329,8 +359,8 @@ export class Service extends DatabaseService<Model> {
329
359
  smsMessage: sms,
330
360
  callRequestMessage: callMessage,
331
361
  pushNotificationMessage: pushMessage,
332
- eventType:
333
- NotificationSettingEventType.SEND_WHEN_USER_IS_REMOVED_FROM_ON_CALL_POLICY,
362
+ whatsAppMessage,
363
+ eventType,
334
364
  onCallPolicyId: deletedItem.onCallDutyPolicy!.id!,
335
365
  onCallPolicyEscalationRuleId:
336
366
  deletedItem.onCallDutyPolicyEscalationRule!.id!,