@oneuptime/common 7.0.3717 → 7.0.3786

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 (203) hide show
  1. package/Models/DatabaseModels/Alert.ts +3 -2
  2. package/Models/DatabaseModels/Incident.ts +3 -2
  3. package/Models/DatabaseModels/Index.ts +3 -0
  4. package/Models/DatabaseModels/ProjectUser.ts +335 -0
  5. package/Models/DatabaseModels/ScheduledMaintenance.ts +3 -2
  6. package/Server/API/SlackAPI.ts +65 -97
  7. package/Server/API/UserOnCallLogTimelineAPI.ts +2 -9
  8. package/Server/Infrastructure/Postgres/SchemaMigrations/1740597525803-MigrationName.ts +17 -0
  9. package/Server/Infrastructure/Postgres/SchemaMigrations/1740598793630-MigrationName.ts +17 -0
  10. package/Server/Infrastructure/Postgres/SchemaMigrations/1741031019972-MigrationName.ts +17 -0
  11. package/Server/Infrastructure/Postgres/SchemaMigrations/1741209339971-MigrationName.ts +101 -0
  12. package/Server/Infrastructure/Postgres/SchemaMigrations/Index.ts +8 -0
  13. package/Server/Middleware/SlackAuthorization.ts +11 -2
  14. package/Server/Services/AlertFeedService.ts +2 -2
  15. package/Server/Services/AlertInternalNoteService.ts +2 -2
  16. package/Server/Services/AlertOwnerTeamService.ts +4 -4
  17. package/Server/Services/AlertOwnerUserService.ts +3 -3
  18. package/Server/Services/AlertService.ts +62 -20
  19. package/Server/Services/AlertStateTimelineService.ts +8 -18
  20. package/Server/Services/IncidentFeedService.ts +101 -2
  21. package/Server/Services/IncidentInternalNoteService.ts +47 -4
  22. package/Server/Services/IncidentOwnerTeamService.ts +57 -4
  23. package/Server/Services/IncidentOwnerUserService.ts +59 -15
  24. package/Server/Services/IncidentPublicNoteService.ts +41 -4
  25. package/Server/Services/IncidentService.ts +279 -193
  26. package/Server/Services/IncidentStateService.ts +25 -0
  27. package/Server/Services/IncidentStateTimelineService.ts +37 -19
  28. package/Server/Services/MonitorStatusTimelineService.ts +7 -17
  29. package/Server/Services/OnCallDutyPolicyEscalationRuleService.ts +2 -0
  30. package/Server/Services/OnCallDutyPolicyExecutionLogService.ts +74 -7
  31. package/Server/Services/OnCallDutyPolicyExecutionLogTimelineService.ts +63 -4
  32. package/Server/Services/OnCallDutyPolicyService.ts +13 -0
  33. package/Server/Services/ProjectUserService.ts +130 -0
  34. package/Server/Services/ScheduledMaintenanceFeedService.ts +2 -2
  35. package/Server/Services/ScheduledMaintenanceInternalNoteService.ts +12 -10
  36. package/Server/Services/ScheduledMaintenanceOwnerTeamService.ts +22 -18
  37. package/Server/Services/ScheduledMaintenanceOwnerUserService.ts +28 -30
  38. package/Server/Services/ScheduledMaintenancePublicNoteService.ts +12 -10
  39. package/Server/Services/ScheduledMaintenanceService.ts +16 -10
  40. package/Server/Services/ScheduledMaintenanceStateTimelineService.ts +1 -1
  41. package/Server/Services/StatusPageSubscriberService.ts +3 -0
  42. package/Server/Services/TeamMemberService.ts +20 -0
  43. package/Server/Services/UserNotificationRuleService.ts +74 -0
  44. package/Server/Services/UserOnCallLogService.ts +1 -1
  45. package/Server/Services/UserService.ts +35 -0
  46. package/Server/Services/WorkspaceNotificationRuleService.ts +508 -149
  47. package/Server/Services/WorkspaceUserAuthTokenService.ts +23 -0
  48. package/Server/Utils/Express.ts +1 -1
  49. package/Server/Utils/StartServer.ts +6 -1
  50. package/Server/Utils/Workspace/MicrosoftTeams/Messages/Incident.ts +195 -0
  51. package/Server/Utils/Workspace/Slack/Actions/ActionTypes.ts +20 -0
  52. package/Server/Utils/Workspace/Slack/Actions/Auth.ts +266 -0
  53. package/Server/Utils/Workspace/Slack/Actions/Incident.ts +1117 -0
  54. package/Server/Utils/Workspace/Slack/Messages/Incident.ts +116 -0
  55. package/Server/Utils/Workspace/Slack/Slack.ts +555 -18
  56. package/Server/Utils/Workspace/Slack/app-manifest.json +18 -10
  57. package/Server/Utils/Workspace/Workspace.ts +194 -1
  58. package/Server/Utils/Workspace/WorkspaceBase.ts +145 -19
  59. package/Server/Utils/Workspace/WorkspaceMessages/Incident.ts +68 -0
  60. package/Types/Icon/IconProp.ts +1 -0
  61. package/Types/Workspace/NotificationRules/NotificationRuleCondition.ts +2 -1
  62. package/Types/Workspace/NotificationRules/NotificationRuleUtil.ts +251 -121
  63. package/Types/Workspace/NotificationRules/NotificationRuleWorkspaceChannel.ts +6 -0
  64. package/Types/Workspace/WorkspaceMessagePayload.ts +71 -2
  65. package/UI/Components/ComingSoon/ComingSoon.tsx +13 -3
  66. package/UI/Components/Forms/Fields/FormField.tsx +2 -2
  67. package/UI/Components/Icon/Icon.tsx +39 -2
  68. package/UI/Components/ModelTable/BaseModelTable.tsx +16 -0
  69. package/UI/Components/Radio/Radio.tsx +11 -2
  70. package/UI/Components/Table/TableCard.tsx +2 -2
  71. package/build/dist/Models/DatabaseModels/Alert.js.map +1 -1
  72. package/build/dist/Models/DatabaseModels/Incident.js.map +1 -1
  73. package/build/dist/Models/DatabaseModels/Index.js +2 -0
  74. package/build/dist/Models/DatabaseModels/Index.js.map +1 -1
  75. package/build/dist/Models/DatabaseModels/ProjectUser.js +340 -0
  76. package/build/dist/Models/DatabaseModels/ProjectUser.js.map +1 -0
  77. package/build/dist/Models/DatabaseModels/ScheduledMaintenance.js.map +1 -1
  78. package/build/dist/Server/API/SlackAPI.js +39 -79
  79. package/build/dist/Server/API/SlackAPI.js.map +1 -1
  80. package/build/dist/Server/API/UserOnCallLogTimelineAPI.js.map +1 -1
  81. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1740597525803-MigrationName.js +12 -0
  82. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1740597525803-MigrationName.js.map +1 -0
  83. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1740598793630-MigrationName.js +12 -0
  84. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1740598793630-MigrationName.js.map +1 -0
  85. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1741031019972-MigrationName.js +12 -0
  86. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1741031019972-MigrationName.js.map +1 -0
  87. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1741209339971-MigrationName.js +42 -0
  88. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1741209339971-MigrationName.js.map +1 -0
  89. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/Index.js +8 -0
  90. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/Index.js.map +1 -1
  91. package/build/dist/Server/Middleware/SlackAuthorization.js +8 -2
  92. package/build/dist/Server/Middleware/SlackAuthorization.js.map +1 -1
  93. package/build/dist/Server/Services/AlertFeedService.js +2 -2
  94. package/build/dist/Server/Services/AlertFeedService.js.map +1 -1
  95. package/build/dist/Server/Services/AlertInternalNoteService.js +2 -2
  96. package/build/dist/Server/Services/AlertInternalNoteService.js.map +1 -1
  97. package/build/dist/Server/Services/AlertOwnerTeamService.js +4 -4
  98. package/build/dist/Server/Services/AlertOwnerTeamService.js.map +1 -1
  99. package/build/dist/Server/Services/AlertOwnerUserService.js +3 -3
  100. package/build/dist/Server/Services/AlertOwnerUserService.js.map +1 -1
  101. package/build/dist/Server/Services/AlertService.js +44 -19
  102. package/build/dist/Server/Services/AlertService.js.map +1 -1
  103. package/build/dist/Server/Services/AlertStateTimelineService.js +6 -16
  104. package/build/dist/Server/Services/AlertStateTimelineService.js.map +1 -1
  105. package/build/dist/Server/Services/IncidentFeedService.js +62 -2
  106. package/build/dist/Server/Services/IncidentFeedService.js.map +1 -1
  107. package/build/dist/Server/Services/IncidentInternalNoteService.js +35 -4
  108. package/build/dist/Server/Services/IncidentInternalNoteService.js.map +1 -1
  109. package/build/dist/Server/Services/IncidentOwnerTeamService.js +42 -4
  110. package/build/dist/Server/Services/IncidentOwnerTeamService.js.map +1 -1
  111. package/build/dist/Server/Services/IncidentOwnerUserService.js +43 -15
  112. package/build/dist/Server/Services/IncidentOwnerUserService.js.map +1 -1
  113. package/build/dist/Server/Services/IncidentPublicNoteService.js +32 -4
  114. package/build/dist/Server/Services/IncidentPublicNoteService.js.map +1 -1
  115. package/build/dist/Server/Services/IncidentService.js +221 -170
  116. package/build/dist/Server/Services/IncidentService.js.map +1 -1
  117. package/build/dist/Server/Services/IncidentStateService.js +14 -0
  118. package/build/dist/Server/Services/IncidentStateService.js.map +1 -1
  119. package/build/dist/Server/Services/IncidentStateTimelineService.js +31 -17
  120. package/build/dist/Server/Services/IncidentStateTimelineService.js.map +1 -1
  121. package/build/dist/Server/Services/MonitorStatusTimelineService.js +5 -15
  122. package/build/dist/Server/Services/MonitorStatusTimelineService.js.map +1 -1
  123. package/build/dist/Server/Services/OnCallDutyPolicyEscalationRuleService.js +1 -0
  124. package/build/dist/Server/Services/OnCallDutyPolicyEscalationRuleService.js.map +1 -1
  125. package/build/dist/Server/Services/OnCallDutyPolicyExecutionLogService.js +62 -7
  126. package/build/dist/Server/Services/OnCallDutyPolicyExecutionLogService.js.map +1 -1
  127. package/build/dist/Server/Services/OnCallDutyPolicyExecutionLogTimelineService.js +51 -5
  128. package/build/dist/Server/Services/OnCallDutyPolicyExecutionLogTimelineService.js.map +1 -1
  129. package/build/dist/Server/Services/OnCallDutyPolicyService.js +6 -0
  130. package/build/dist/Server/Services/OnCallDutyPolicyService.js.map +1 -1
  131. package/build/dist/Server/Services/ProjectUserService.js +106 -0
  132. package/build/dist/Server/Services/ProjectUserService.js.map +1 -0
  133. package/build/dist/Server/Services/ScheduledMaintenanceFeedService.js +2 -2
  134. package/build/dist/Server/Services/ScheduledMaintenanceFeedService.js.map +1 -1
  135. package/build/dist/Server/Services/ScheduledMaintenanceInternalNoteService.js +2 -2
  136. package/build/dist/Server/Services/ScheduledMaintenanceInternalNoteService.js.map +1 -1
  137. package/build/dist/Server/Services/ScheduledMaintenanceOwnerTeamService.js +4 -4
  138. package/build/dist/Server/Services/ScheduledMaintenanceOwnerTeamService.js.map +1 -1
  139. package/build/dist/Server/Services/ScheduledMaintenanceOwnerUserService.js +8 -16
  140. package/build/dist/Server/Services/ScheduledMaintenanceOwnerUserService.js.map +1 -1
  141. package/build/dist/Server/Services/ScheduledMaintenancePublicNoteService.js +2 -2
  142. package/build/dist/Server/Services/ScheduledMaintenancePublicNoteService.js.map +1 -1
  143. package/build/dist/Server/Services/ScheduledMaintenanceService.js +5 -2
  144. package/build/dist/Server/Services/ScheduledMaintenanceService.js.map +1 -1
  145. package/build/dist/Server/Services/ScheduledMaintenanceStateTimelineService.js +1 -1
  146. package/build/dist/Server/Services/ScheduledMaintenanceStateTimelineService.js.map +1 -1
  147. package/build/dist/Server/Services/StatusPageSubscriberService.js +3 -0
  148. package/build/dist/Server/Services/StatusPageSubscriberService.js.map +1 -1
  149. package/build/dist/Server/Services/TeamMemberService.js +17 -0
  150. package/build/dist/Server/Services/TeamMemberService.js.map +1 -1
  151. package/build/dist/Server/Services/UserNotificationRuleService.js +52 -0
  152. package/build/dist/Server/Services/UserNotificationRuleService.js.map +1 -1
  153. package/build/dist/Server/Services/UserOnCallLogService.js +1 -1
  154. package/build/dist/Server/Services/UserOnCallLogService.js.map +1 -1
  155. package/build/dist/Server/Services/UserService.js +23 -0
  156. package/build/dist/Server/Services/UserService.js.map +1 -1
  157. package/build/dist/Server/Services/WorkspaceNotificationRuleService.js +306 -84
  158. package/build/dist/Server/Services/WorkspaceNotificationRuleService.js.map +1 -1
  159. package/build/dist/Server/Services/WorkspaceUserAuthTokenService.js +18 -0
  160. package/build/dist/Server/Services/WorkspaceUserAuthTokenService.js.map +1 -1
  161. package/build/dist/Server/Utils/StartServer.js +4 -0
  162. package/build/dist/Server/Utils/StartServer.js.map +1 -1
  163. package/build/dist/Server/Utils/Workspace/MicrosoftTeams/Messages/Incident.js +148 -0
  164. package/build/dist/Server/Utils/Workspace/MicrosoftTeams/Messages/Incident.js.map +1 -0
  165. package/build/dist/Server/Utils/Workspace/Slack/Actions/ActionTypes.js +19 -0
  166. package/build/dist/Server/Utils/Workspace/Slack/Actions/ActionTypes.js.map +1 -0
  167. package/build/dist/Server/Utils/Workspace/Slack/Actions/Auth.js +167 -0
  168. package/build/dist/Server/Utils/Workspace/Slack/Actions/Auth.js.map +1 -0
  169. package/build/dist/Server/Utils/Workspace/Slack/Actions/Incident.js +727 -0
  170. package/build/dist/Server/Utils/Workspace/Slack/Actions/Incident.js.map +1 -0
  171. package/build/dist/Server/Utils/Workspace/Slack/Messages/Incident.js +82 -0
  172. package/build/dist/Server/Utils/Workspace/Slack/Messages/Incident.js.map +1 -0
  173. package/build/dist/Server/Utils/Workspace/Slack/Slack.js +397 -14
  174. package/build/dist/Server/Utils/Workspace/Slack/Slack.js.map +1 -1
  175. package/build/dist/Server/Utils/Workspace/Slack/app-manifest.json +18 -10
  176. package/build/dist/Server/Utils/Workspace/Workspace.js +126 -0
  177. package/build/dist/Server/Utils/Workspace/Workspace.js.map +1 -1
  178. package/build/dist/Server/Utils/Workspace/WorkspaceBase.js +69 -11
  179. package/build/dist/Server/Utils/Workspace/WorkspaceBase.js.map +1 -1
  180. package/build/dist/Server/Utils/Workspace/WorkspaceMessages/Incident.js +47 -0
  181. package/build/dist/Server/Utils/Workspace/WorkspaceMessages/Incident.js.map +1 -0
  182. package/build/dist/Types/Icon/IconProp.js +1 -0
  183. package/build/dist/Types/Icon/IconProp.js.map +1 -1
  184. package/build/dist/Types/Workspace/NotificationRules/NotificationRuleCondition.js +2 -1
  185. package/build/dist/Types/Workspace/NotificationRules/NotificationRuleCondition.js.map +1 -1
  186. package/build/dist/Types/Workspace/NotificationRules/NotificationRuleUtil.js +214 -120
  187. package/build/dist/Types/Workspace/NotificationRules/NotificationRuleUtil.js.map +1 -1
  188. package/build/dist/Types/Workspace/NotificationRules/NotificationRuleWorkspaceChannel.js +2 -0
  189. package/build/dist/Types/Workspace/NotificationRules/NotificationRuleWorkspaceChannel.js.map +1 -0
  190. package/build/dist/UI/Components/ComingSoon/ComingSoon.js +3 -2
  191. package/build/dist/UI/Components/ComingSoon/ComingSoon.js.map +1 -1
  192. package/build/dist/UI/Components/Forms/Fields/FormField.js +2 -2
  193. package/build/dist/UI/Components/Forms/Fields/FormField.js.map +1 -1
  194. package/build/dist/UI/Components/Icon/Icon.js +19 -2
  195. package/build/dist/UI/Components/Icon/Icon.js.map +1 -1
  196. package/build/dist/UI/Components/ModelTable/BaseModelTable.js +11 -0
  197. package/build/dist/UI/Components/ModelTable/BaseModelTable.js.map +1 -1
  198. package/build/dist/UI/Components/Radio/Radio.js +5 -2
  199. package/build/dist/UI/Components/Radio/Radio.js.map +1 -1
  200. package/build/dist/UI/Components/Table/TableCard.js +2 -2
  201. package/build/dist/UI/Components/Table/TableCard.js.map +1 -1
  202. package/package.json +3 -2
  203. package/Server/Utils/Workspace/Slack/app-manifest.example.json +0 -198
@@ -25,6 +25,29 @@ export class Service extends DatabaseService {
25
25
  constructor() {
26
26
  super(Model);
27
27
  }
28
+ async getUserMarkdownString(data) {
29
+ var _a, _b;
30
+ const user = await this.findOneBy({
31
+ query: {
32
+ _id: data.userId,
33
+ },
34
+ select: {
35
+ name: true,
36
+ email: true,
37
+ },
38
+ props: {
39
+ isRoot: true,
40
+ },
41
+ });
42
+ if (!user) {
43
+ return "";
44
+ }
45
+ return `[${((_a = user.name) === null || _a === void 0 ? void 0 : _a.toString()) || ((_b = user.email) === null || _b === void 0 ? void 0 : _b.toString()) || "User"}](${(await this.getUserLinkInDashboard(data.projectId, data.userId)).toString()})`;
46
+ }
47
+ async getUserLinkInDashboard(projectId, userId) {
48
+ const dashboardUrl = await DatabaseConfig.getDashboardUrl();
49
+ return URL.fromString(dashboardUrl.toString()).addRoute(`/${projectId.toString()}/settings/users/${userId.toString()}`);
50
+ }
28
51
  async onCreateSuccess(_onCreate, createdItem) {
29
52
  var _a, _b, _c, _d;
30
53
  if (NotificationSlackWebhookOnCreateUser) {
@@ -1 +1 @@
1
- {"version":3,"file":"UserService.js","sourceRoot":"","sources":["../../../../Server/Services/UserService.ts"],"names":[],"mappings":"AAAA,OAAO,cAAc,MAAM,mBAAmB,CAAC;AAC/C,O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AE;4BACL,MAAM,EAAE,IAAI;4BACZ,WAAW,EAAE,IAAI;yBAClB;qBACF,CAAC,CAAC;gBACL,CAAC;YACH,CAAC;QACH,CAAC;QAED,OAAO,QAAQ,CAAC;IAClB,CAAC;IAEM,KAAK,CAAC,aAAa,CAAC,IAM1B;QACC,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,IAAI,CAAC;QAE9B,MAAM,IAAI,GAAU,IAAI,KAAK,EAAE,CAAC;QAChC,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC;YACd,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC;QACxB,CAAC;QACD,IAAI,CAAC,eAAe,GAAG,IAAI,CAAC,eAAe,IAAI,KAAK,CAAC;QAErD,IAAI,IAAI,CAAC,sBAAsB,EAAE,CAAC;YAChC,IAAI,CAAC,QAAQ,GAAG,IAAI,YAAY,CAAC,IAAI,CAAC,kBAAkB,CAAC,EAAE,CAAC,CAAC,CAAC;QAChE,CAAC;QAED,IAAI,CAAC,gBAAgB,EAAE,CAAC;YACtB,gEAAgE;YAChE,IAAI,CAAC,eAAe,GAAG,IAAI,CAAC;QAC9B,CAAC;QAED,OAAO,MAAM,IAAI,CAAC,MAAM,CAAC;YACvB,IAAI,EAAE,IAAI;YACV,KAAK,EAAE,KAAK;SACb,CAAC,CAAC;IACL,CAAC;CACF;AAED,eAAe,IAAI,OAAO,EAAE,CAAC"}
1
+ {"version":3,"file":"UserService.js","sourceRoot":"","sources":["../../../../Server/Services/UserService.ts"],"names":[],"mappings":"AAAA,OAAO,cAAc,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EACL,gBAAgB,EAChB,oCAAoC,GACrC,MAAM,sBAAsB,CAAC;AAG9B,OAAO,MAAM,MAAM,iBAAiB,CAAC;AACrC,OAAO,eAAe,MAAM,mBAAmB,CAAC;AAChD,OAAO,6BAA6B,MAAM,iCAAiC,CAAC;AAC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AI,CAAC,eAAe,IAAI,KAAK,CAAC;QAErD,IAAI,IAAI,CAAC,sBAAsB,EAAE,CAAC;YAChC,IAAI,CAAC,QAAQ,GAAG,IAAI,YAAY,CAAC,IAAI,CAAC,kBAAkB,CAAC,EAAE,CAAC,CAAC,CAAC;QAChE,CAAC;QAED,IAAI,CAAC,gBAAgB,EAAE,CAAC;YACtB,gEAAgE;YAChE,IAAI,CAAC,eAAe,GAAG,IAAI,CAAC;QAC9B,CAAC;QAED,OAAO,MAAM,IAAI,CAAC,MAAM,CAAC;YACvB,IAAI,EAAE,IAAI;YACV,KAAK,EAAE,KAAK;SACb,CAAC,CAAC;IACL,CAAC;CACF;AAED,eAAe,IAAI,OAAO,EAAE,CAAC"}
@@ -1,7 +1,6 @@
1
1
  import ObjectID from "../../Types/ObjectID";
2
2
  import WorkspaceType from "../../Types/Workspace/WorkspaceType";
3
3
  import DatabaseService from "./DatabaseService";
4
- import Model from "Common/Models/DatabaseModels/WorkspaceNotificationRule";
5
4
  import { LIMIT_PER_PROJECT } from "../../Types/Database/LimitMax";
6
5
  import IncidentService from "./IncidentService";
7
6
  import { NotificationRuleConditionCheckOn } from "../../Types/Workspace/NotificationRules/NotificationRuleCondition";
@@ -16,9 +15,14 @@ import WorkspaceUtil from "../Utils/Workspace/Workspace";
16
15
  import WorkspaceUserAuthTokenService from "./WorkspaceUserAuthTokenService";
17
16
  import WorkspaceProjectAuthTokenService from "./WorkspaceProjectAuthTokenService";
18
17
  import logger from "../Utils/Logger";
18
+ import WorkspaceNotificationRule from "Common/Models/DatabaseModels/WorkspaceNotificationRule";
19
+ import UserService from "./UserService";
19
20
  export class Service extends DatabaseService {
20
21
  constructor() {
21
- super(Model);
22
+ super(WorkspaceNotificationRule);
23
+ }
24
+ static getAllWorkspaceTypes() {
25
+ return [WorkspaceType.Slack, WorkspaceType.MicrosoftTeams];
22
26
  }
23
27
  getBotUserIdFromprojectAuthToken(data) {
24
28
  const miscData = data.projectAuthToken.miscData;
@@ -34,7 +38,26 @@ export class Service extends DatabaseService {
34
38
  }
35
39
  throw new BadDataException("Workspace type not supported");
36
40
  }
37
- async createInviteAndPostToChannelsBasedOnRules(data) {
41
+ async getExistingChannelNamesBasedOnEventType(data) {
42
+ logger.debug("getExistingChannelNamesBasedOnEventType called with data:");
43
+ logger.debug(data);
44
+ const notificationRules = await this.getNotificationRules({
45
+ projectId: data.projectId,
46
+ workspaceType: data.workspaceType,
47
+ notificationRuleEventType: data.notificationRuleEventType,
48
+ });
49
+ logger.debug("Notification rules retrieved:");
50
+ logger.debug(notificationRules);
51
+ const existingChannelNames = this.getExistingChannelNamesFromNotificationRules({
52
+ notificationRules: notificationRules.map((rule) => {
53
+ return rule.notificationRule;
54
+ }),
55
+ }) || [];
56
+ logger.debug("Existing channel names:");
57
+ logger.debug(existingChannelNames);
58
+ return existingChannelNames;
59
+ }
60
+ async createChannelsAndInviteUsersToChannelsBasedOnRules(data) {
38
61
  logger.debug("WorkspaceNotificationRuleService.createInviteAndPostToChannelsBasedOnRules");
39
62
  logger.debug(data);
40
63
  const channelsCreated = [];
@@ -69,11 +92,9 @@ export class Service extends DatabaseService {
69
92
  }
70
93
  logger.debug("Creating channels based on rules");
71
94
  const createdWorkspaceChannels = await this.createChannelsBasedOnRules({
72
- projectOrUserAuthTokenForWorkspasce: authToken,
95
+ projectOrUserAuthTokenForWorkspace: authToken,
73
96
  workspaceType: workspaceType,
74
- notificationRules: notificationRules.map((rule) => {
75
- return rule.notificationRule;
76
- }),
97
+ notificationRules: notificationRules,
77
98
  channelNameSiffix: data.channelNameSiffix,
78
99
  notificationEventType: data.notificationRuleEventType,
79
100
  });
@@ -82,14 +103,10 @@ export class Service extends DatabaseService {
82
103
  logger.debug("Inviting users and teams to channels based on rules");
83
104
  await this.inviteUsersAndTeamsToChannelsBasedOnRules({
84
105
  projectId: data.projectId,
85
- projectOrUserAuthTokenForWorkspasce: authToken,
106
+ projectAuth: projectAuth,
86
107
  workspaceType: workspaceType,
87
- notificationRules: notificationRules.map((rule) => {
88
- return rule.notificationRule;
89
- }),
90
- channelNames: createdWorkspaceChannels.map((channel) => {
91
- return channel.name;
92
- }),
108
+ notificationRules: notificationRules,
109
+ notificationChannels: createdWorkspaceChannels,
93
110
  });
94
111
  logger.debug("Getting existing channel names from notification rules");
95
112
  const existingChannelNames = this.getExistingChannelNamesFromNotificationRules({
@@ -108,19 +125,6 @@ export class Service extends DatabaseService {
108
125
  logger.debug("Final list of channel names to post messages to:");
109
126
  logger.debug(existingChannelNames);
110
127
  logger.debug("Posting messages to workspace channels");
111
- await this.postToWorkspaceChannels({
112
- workspaceUserId: this.getBotUserIdFromprojectAuthToken({
113
- projectAuthToken: projectAuth,
114
- workspaceType: workspaceType,
115
- }),
116
- projectOrUserAuthTokenForWorkspasce: authToken,
117
- workspaceType: workspaceType,
118
- workspaceMessagePayload: {
119
- _type: "WorkspaceMessagePayload",
120
- channelNames: existingChannelNames,
121
- messageBlocks: data.messageBlocks,
122
- },
123
- });
124
128
  logger.debug("Channels created:");
125
129
  logger.debug(createdWorkspaceChannels);
126
130
  channelsCreated.push(...createdWorkspaceChannels);
@@ -130,45 +134,238 @@ export class Service extends DatabaseService {
130
134
  channelsCreated: channelsCreated,
131
135
  };
132
136
  }
133
- async postToWorkspaceChannels(data) {
134
- logger.debug("postToWorkspaceChannels called with data:");
135
- logger.debug(data);
136
- await WorkspaceUtil.getWorkspaceTypeUtil(data.workspaceType).sendMessage({
137
- userId: data.workspaceUserId,
138
- workspaceMessagePayload: data.workspaceMessagePayload,
139
- authToken: data.projectOrUserAuthTokenForWorkspasce,
140
- });
141
- logger.debug("Message posted to workspace channels successfully");
137
+ async getNotificationRulesWhereOnCallIsTrue(data) {
138
+ const workspaceTypes = Service.getAllWorkspaceTypes();
139
+ const result = [];
140
+ for (const workspaceType of workspaceTypes) {
141
+ // get matching notification rules
142
+ const notificationRules = await this.getMatchingNotificationRules({
143
+ projectId: data.projectId,
144
+ notificationFor: data.notificationFor,
145
+ workspaceType: workspaceType,
146
+ notificationRuleEventType: data.notificationRuleEventType,
147
+ });
148
+ const filteredNotificationRules = notificationRules.filter((rule) => {
149
+ return rule.notificationRule
150
+ .shouldAutomaticallyInviteOnCallUsersToNewChannel;
151
+ });
152
+ result.push(...filteredNotificationRules);
153
+ }
154
+ return result;
155
+ }
156
+ async getNotificationRulesWhereInviteOwnersIsTrue(data) {
157
+ const workspaceTypes = Service.getAllWorkspaceTypes();
158
+ const result = [];
159
+ for (const workspaceType of workspaceTypes) {
160
+ // get matching notification rules
161
+ const notificationRules = await this.getMatchingNotificationRules({
162
+ projectId: data.projectId,
163
+ notificationFor: data.notificationFor,
164
+ workspaceType: workspaceType,
165
+ notificationRuleEventType: data.notificationRuleEventType,
166
+ });
167
+ const filteredNotificationRules = notificationRules.filter((rule) => {
168
+ return rule.notificationRule
169
+ .shouldInviteOwnersToNewChannel;
170
+ });
171
+ result.push(...filteredNotificationRules);
172
+ }
173
+ return result;
142
174
  }
143
175
  async inviteUsersAndTeamsToChannelsBasedOnRules(data) {
176
+ var _a, _b;
144
177
  logger.debug("inviteUsersAndTeamsToChannelsBasedOnRules called with data:");
145
178
  logger.debug(data);
146
- const inviteUserIds = await this.getUsersIdsToInviteToChannel({
179
+ const inviteUserPayloads = await this.getUsersIdsToInviteToChannel({
147
180
  notificationRules: data.notificationRules,
148
181
  });
149
- logger.debug("User IDs to invite:");
150
- logger.debug(inviteUserIds);
151
- const workspaceUserIds = [];
152
- for (const userId of inviteUserIds) {
153
- const workspaceUserId = await this.getWorkspaceUserIdFromOneUptimeUserId({
154
- projectId: data.projectId,
155
- workspaceType: data.workspaceType,
156
- oneuptimeUserId: userId,
182
+ logger.debug("User IDs to invite by Workspace Notification Rule ID:");
183
+ logger.debug(inviteUserPayloads);
184
+ for (const inviteUserPayload of inviteUserPayloads) {
185
+ const userIds = inviteUserPayload.userIds;
186
+ const workspaceUserIds = [];
187
+ for (const userId of userIds) {
188
+ const workspaceUserId = await this.getWorkspaceUserIdFromOneUptimeUserId({
189
+ projectId: data.projectId,
190
+ workspaceType: data.workspaceType,
191
+ oneuptimeUserId: userId,
192
+ });
193
+ if (workspaceUserId) {
194
+ workspaceUserIds.push(workspaceUserId);
195
+ }
196
+ else {
197
+ try {
198
+ // send a message to channel that user cannot be invited because the account is not connected to workspace.
199
+ const channelIds = ((_b = (_a = data.notificationChannels) === null || _a === void 0 ? void 0 : _a.filter((channel) => {
200
+ return (channel.notificationRuleId ===
201
+ inviteUserPayload.notificationRuleId);
202
+ })) === null || _b === void 0 ? void 0 : _b.map((channel) => {
203
+ return channel.id;
204
+ })) || [];
205
+ logger.debug("Channel IDs to send message to:");
206
+ logger.debug(channelIds);
207
+ await WorkspaceUtil.getWorkspaceTypeUtil(data.workspaceType).sendMessage({
208
+ userId: data.projectAuth.workspaceProjectId,
209
+ authToken: data.projectAuth.authToken,
210
+ workspaceMessagePayload: {
211
+ _type: "WorkspaceMessagePayload",
212
+ channelNames: [],
213
+ channelIds: channelIds,
214
+ workspaceType: data.workspaceType,
215
+ messageBlocks: [
216
+ {
217
+ _type: "WorkspacePayloadMarkdown",
218
+ text: `${await UserService.getUserMarkdownString({
219
+ userId: userId,
220
+ projectId: data.projectId,
221
+ })} cannot be invited to the channel because the account is not connected to ${data.workspaceType}. Please go to User Settings > ${data.workspaceType} on OneUptime Dashboard and connect the account.`,
222
+ },
223
+ ],
224
+ },
225
+ });
226
+ }
227
+ catch (e) {
228
+ logger.error("Error in sending message to channel");
229
+ logger.error(e);
230
+ }
231
+ }
232
+ logger.debug("Workspace User IDs to invite:");
233
+ logger.debug(workspaceUserIds);
234
+ await WorkspaceUtil.getWorkspaceTypeUtil(data.workspaceType).inviteUsersToChannels({
235
+ authToken: data.projectAuth.authToken,
236
+ workspaceChannelInvitationPayload: {
237
+ channelNames: data.notificationChannels
238
+ .filter((channel) => {
239
+ return (channel.notificationRuleId ===
240
+ inviteUserPayload.notificationRuleId);
241
+ })
242
+ .map((channel) => {
243
+ return channel.name;
244
+ }),
245
+ workspaceUserIds: workspaceUserIds,
246
+ },
247
+ });
248
+ }
249
+ }
250
+ logger.debug("Users invited to channels successfully");
251
+ }
252
+ async inviteUsersBasedOnRulesAndWorkspaceChannels(data) {
253
+ logger.debug("inviteUsersBasedOnRulesAndWorkspaceChannels called with data:");
254
+ logger.debug(data);
255
+ const userIds = data.userIds;
256
+ logger.debug("Users:");
257
+ logger.debug(userIds);
258
+ // get all Workspaces.
259
+ const workspaceTypes = Service.getAllWorkspaceTypes();
260
+ for (const workspaceType of workspaceTypes) {
261
+ // filter rules by workspaceType.
262
+ const notificationRules = data.notificationRules.filter((rule) => {
263
+ return rule.workspaceType === workspaceType;
264
+ });
265
+ logger.debug("Notification rules for workspace type:");
266
+ logger.debug(notificationRules);
267
+ const channelsToInviteToBasedOnRule = data.workspaceChannels.filter((channel) => {
268
+ return notificationRules.find((rule) => {
269
+ var _a;
270
+ return ((_a = rule.id) === null || _a === void 0 ? void 0 : _a.toString()) === channel.notificationRuleId;
271
+ });
272
+ });
273
+ logger.debug("Channels to invite to based on rule:");
274
+ logger.debug(channelsToInviteToBasedOnRule);
275
+ if (channelsToInviteToBasedOnRule.length === 0) {
276
+ logger.debug("No channels to invite to based on rule.");
277
+ continue;
278
+ }
279
+ // get auth token for workspace.
280
+ const projectAuth = await WorkspaceProjectAuthTokenService.findOneBy({
281
+ query: {
282
+ projectId: data.projectId,
283
+ workspaceType: workspaceType,
284
+ },
285
+ select: {
286
+ authToken: true,
287
+ },
288
+ props: {
289
+ isRoot: true,
290
+ },
157
291
  });
158
- if (workspaceUserId) {
159
- workspaceUserIds.push(workspaceUserId);
292
+ if (!projectAuth) {
293
+ logger.debug("No project auth found for workspace type");
294
+ continue;
160
295
  }
296
+ // inivte users to channels.
297
+ const workspaceUserIds = [];
298
+ for (const userId of userIds) {
299
+ const workspaceUserId = await this.getWorkspaceUserIdFromOneUptimeUserId({
300
+ projectId: data.projectId,
301
+ workspaceType: workspaceType,
302
+ oneuptimeUserId: userId,
303
+ });
304
+ if (workspaceUserId) {
305
+ workspaceUserIds.push(workspaceUserId);
306
+ }
307
+ else {
308
+ try {
309
+ // send a message to channel that user cannot be invited because the account is not connected to workspace.
310
+ const channelIds = channelsToInviteToBasedOnRule.map((channel) => {
311
+ return channel.id;
312
+ });
313
+ logger.debug("Channel IDs to send message to:");
314
+ logger.debug(channelIds);
315
+ await WorkspaceUtil.getWorkspaceTypeUtil(workspaceType).sendMessage({
316
+ userId: projectAuth.workspaceProjectId,
317
+ authToken: projectAuth.authToken,
318
+ workspaceMessagePayload: {
319
+ _type: "WorkspaceMessagePayload",
320
+ channelNames: [],
321
+ channelIds: channelIds,
322
+ workspaceType: workspaceType,
323
+ messageBlocks: [
324
+ {
325
+ _type: "WorkspacePayloadMarkdown",
326
+ text: `${await UserService.getUserMarkdownString({
327
+ userId: userId,
328
+ projectId: data.projectId,
329
+ })} cannot be invited to the channel because the account is not connected to ${workspaceType}. Please go to User Settings > ${workspaceType} on OneUptime Dashboard and connect the account.`,
330
+ },
331
+ ],
332
+ },
333
+ });
334
+ }
335
+ catch (e) {
336
+ logger.error("Error in sending message to channel");
337
+ logger.error(e);
338
+ }
339
+ }
340
+ }
341
+ logger.debug("Workspace User IDs to invite:");
342
+ logger.debug(workspaceUserIds);
343
+ const channelNames = channelsToInviteToBasedOnRule.map((channel) => {
344
+ return channel.name;
345
+ });
346
+ logger.debug("Channel names to invite to:");
347
+ logger.debug(channelNames);
348
+ await WorkspaceUtil.getWorkspaceTypeUtil(workspaceType).inviteUsersToChannels({
349
+ authToken: projectAuth.authToken,
350
+ workspaceChannelInvitationPayload: {
351
+ channelNames: channelNames,
352
+ workspaceUserIds: workspaceUserIds,
353
+ },
354
+ });
161
355
  }
162
- logger.debug("Workspace User IDs to invite:");
163
- logger.debug(workspaceUserIds);
164
- await WorkspaceUtil.getWorkspaceTypeUtil(data.workspaceType).inviteUsersToChannels({
165
- authToken: data.projectOrUserAuthTokenForWorkspasce,
166
- workspaceChannelInvitationPayload: {
167
- channelNames: data.channelNames,
168
- workspaceUserIds: workspaceUserIds,
169
- },
356
+ }
357
+ async inviteTeamsBasedOnRulesAndWorkspaceChannels(data) {
358
+ const usersInTeam = await TeamMemberService.getUsersInTeams(data.teamIds);
359
+ logger.debug("Users in teams:");
360
+ logger.debug(usersInTeam);
361
+ return this.inviteUsersBasedOnRulesAndWorkspaceChannels({
362
+ workspaceChannels: data.workspaceChannels,
363
+ projectId: data.projectId,
364
+ notificationRules: data.notificationRules,
365
+ userIds: usersInTeam.map((user) => {
366
+ return user.id;
367
+ }),
170
368
  });
171
- logger.debug("Users invited to channels successfully");
172
369
  }
173
370
  async getWorkspaceUserIdFromOneUptimeUserId(data) {
174
371
  var _a;
@@ -200,31 +397,34 @@ export class Service extends DatabaseService {
200
397
  logger.debug(data);
201
398
  const createdWorkspaceChannels = [];
202
399
  const createdChannelNames = [];
203
- const newChannelNames = this.getNewChannelNamesFromNotificationRules({
400
+ const notificationChannels = this.getnotificationChannelssFromNotificationRules({
204
401
  notificationRules: data.notificationRules,
205
402
  channelNameSiffix: data.channelNameSiffix,
206
403
  notificationEventType: data.notificationEventType,
207
404
  });
208
405
  logger.debug("New channel names to be created:");
209
- logger.debug(newChannelNames);
210
- if (!newChannelNames || newChannelNames.length === 0) {
406
+ logger.debug(notificationChannels);
407
+ if (!notificationChannels || notificationChannels.length === 0) {
211
408
  logger.debug("No new channel names found. Returning empty array.");
212
409
  return [];
213
410
  }
214
- for (const newChannelName of newChannelNames) {
215
- if (createdChannelNames.includes(newChannelName)) {
216
- logger.debug(`Channel name ${newChannelName} already created. Skipping.`);
411
+ for (const notificationChannel of notificationChannels) {
412
+ if (createdChannelNames.filter((name) => {
413
+ return name === notificationChannel.channelName;
414
+ }).length > 0) {
415
+ logger.debug(`Channel name ${notificationChannel.channelName} already created. Skipping.`);
217
416
  continue;
218
417
  }
219
- logger.debug(`Creating new channel with name: ${newChannelName}`);
418
+ logger.debug(`Creating new channel with name: ${notificationChannel.channelName}`);
220
419
  const channel = await WorkspaceUtil.getWorkspaceTypeUtil(data.workspaceType).createChannel({
221
- authToken: data.projectOrUserAuthTokenForWorkspasce,
222
- channelName: newChannelName,
420
+ authToken: data.projectOrUserAuthTokenForWorkspace,
421
+ channelName: notificationChannel.channelName,
223
422
  });
423
+ const notificationWorkspaceChannel = Object.assign(Object.assign({}, channel), { notificationRuleId: notificationChannel.notificationRuleId });
224
424
  logger.debug("Channel created:");
225
425
  logger.debug(channel);
226
426
  createdChannelNames.push(channel.name);
227
- createdWorkspaceChannels.push(channel);
427
+ createdWorkspaceChannels.push(notificationWorkspaceChannel);
228
428
  }
229
429
  logger.debug("Returning created workspace channels:");
230
430
  logger.debug(createdWorkspaceChannels);
@@ -234,9 +434,10 @@ export class Service extends DatabaseService {
234
434
  var _a;
235
435
  logger.debug("getUsersIdsToInviteToChannel called with data:");
236
436
  logger.debug(data);
237
- const inviteUserIds = [];
238
- for (const notificationRule of data.notificationRules) {
239
- const workspaceRules = notificationRule;
437
+ const result = [];
438
+ for (const workspaceNotificationRule of data.notificationRules) {
439
+ const inviteUserIds = [];
440
+ const workspaceRules = workspaceNotificationRule.notificationRule;
240
441
  if (workspaceRules.shouldCreateNewChannel) {
241
442
  if (workspaceRules.inviteUsersToNewChannel &&
242
443
  workspaceRules.inviteUsersToNewChannel.length > 0) {
@@ -275,10 +476,16 @@ export class Service extends DatabaseService {
275
476
  }
276
477
  }
277
478
  }
479
+ if (inviteUserIds.length > 0) {
480
+ result.push({
481
+ notificationRuleId: workspaceNotificationRule.id.toString(),
482
+ userIds: inviteUserIds,
483
+ });
484
+ }
278
485
  }
279
486
  logger.debug("Final list of user IDs to invite:");
280
- logger.debug(inviteUserIds);
281
- return inviteUserIds;
487
+ logger.debug(result);
488
+ return result;
282
489
  }
283
490
  getExistingChannelNamesFromNotificationRules(data) {
284
491
  logger.debug("getExistingChannelNamesFromNotificationRules called with data:");
@@ -305,27 +512,31 @@ export class Service extends DatabaseService {
305
512
  logger.debug(channelNames);
306
513
  return channelNames;
307
514
  }
308
- getNewChannelNamesFromNotificationRules(data) {
309
- logger.debug("getNewChannelNamesFromNotificationRules called with data:");
515
+ getnotificationChannelssFromNotificationRules(data) {
516
+ logger.debug("getnotificationChannelssFromNotificationRules called with data:");
310
517
  logger.debug(data);
311
- const channelNames = [];
518
+ const channels = [];
312
519
  for (const notificationRule of data.notificationRules) {
313
- const workspaceRules = notificationRule;
520
+ const workspaceRules = notificationRule.notificationRule;
314
521
  logger.debug("Processing notification rule:");
315
522
  logger.debug(workspaceRules);
316
- if (workspaceRules.shouldCreateNewChannel &&
317
- workspaceRules.newChannelTemplateName) {
318
- const newChannelName = workspaceRules.newChannelTemplateName ||
523
+ if (workspaceRules.shouldCreateNewChannel) {
524
+ const notificationChannels = workspaceRules.newChannelTemplateName ||
319
525
  `oneuptime-${data.notificationEventType.toLowerCase()}-`;
320
526
  logger.debug("New channel template name:");
321
- logger.debug(newChannelName);
527
+ logger.debug(notificationChannels);
322
528
  // add suffix and then check if it is already added or not.
323
- const channelName = newChannelName + data.channelNameSiffix;
529
+ const channelName = notificationChannels + data.channelNameSiffix;
324
530
  logger.debug("Final channel name with suffix:");
325
531
  logger.debug(channelName);
326
- if (!channelNames.includes(channelName)) {
532
+ if (channels.filter((name) => {
533
+ return name.channelName === channelName;
534
+ }).length === 0) {
327
535
  // if channel name is not already added then add it.
328
- channelNames.push(channelName);
536
+ channels.push({
537
+ channelName: channelName,
538
+ notificationRuleId: notificationRule.id.toString() || "",
539
+ });
329
540
  logger.debug(`Channel name ${channelName} added to the list.`);
330
541
  }
331
542
  else {
@@ -334,8 +545,8 @@ export class Service extends DatabaseService {
334
545
  }
335
546
  }
336
547
  logger.debug("Final list of new channel names:");
337
- logger.debug(channelNames);
338
- return channelNames;
548
+ logger.debug(channels);
549
+ return channels;
339
550
  }
340
551
  async getNotificationRules(data) {
341
552
  logger.debug("getNotificationRules called with data:");
@@ -348,6 +559,8 @@ export class Service extends DatabaseService {
348
559
  },
349
560
  select: {
350
561
  notificationRule: true,
562
+ workspaceType: true,
563
+ eventType: true,
351
564
  },
352
565
  props: {
353
566
  isRoot: true,
@@ -604,17 +817,26 @@ export class Service extends DatabaseService {
604
817
  workspaceType: data.workspaceType,
605
818
  notificationRuleEventType: data.notificationRuleEventType,
606
819
  });
820
+ logger.debug("Notification rules retrieved:");
821
+ logger.debug(notificationRules);
607
822
  const values = await this.getValuesBasedOnNotificationFor({
608
823
  notificationFor: data.notificationFor,
609
824
  });
825
+ logger.debug("Values based on notification for:");
826
+ logger.debug(values);
610
827
  const matchingNotificationRules = [];
611
828
  for (const notificationRule of notificationRules) {
829
+ logger.debug("Checking if rule matches:");
612
830
  if (WorkspaceNotificationRuleUtil.isRuleMatching({
613
831
  notificationRule: notificationRule.notificationRule,
614
832
  values: values,
615
833
  })) {
834
+ logger.debug("Rule matches. Adding to the list.");
616
835
  matchingNotificationRules.push(notificationRule);
617
836
  }
837
+ else {
838
+ logger.debug("Rule does not match. Skipping.");
839
+ }
618
840
  }
619
841
  return matchingNotificationRules;
620
842
  }