@oneuptime/common 7.0.3718 → 7.0.3815
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Models/DatabaseModels/Alert.ts +3 -2
- package/Models/DatabaseModels/Incident.ts +3 -2
- package/Models/DatabaseModels/Index.ts +3 -0
- package/Models/DatabaseModels/ProjectUser.ts +335 -0
- package/Models/DatabaseModels/ScheduledMaintenance.ts +3 -2
- package/Server/API/SlackAPI.ts +127 -91
- package/Server/Infrastructure/Postgres/SchemaMigrations/1740597525803-MigrationName.ts +17 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/1740598793630-MigrationName.ts +17 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/1741031019972-MigrationName.ts +17 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/1741209339971-MigrationName.ts +101 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/Index.ts +8 -0
- package/Server/Middleware/SlackAuthorization.ts +11 -2
- package/Server/Services/AccessTokenService.ts +21 -0
- package/Server/Services/AlertFeedService.ts +100 -2
- package/Server/Services/AlertInternalNoteService.ts +51 -10
- package/Server/Services/AlertOwnerTeamService.ts +52 -4
- package/Server/Services/AlertOwnerUserService.ts +54 -4
- package/Server/Services/AlertService.ts +295 -54
- package/Server/Services/AlertStateService.ts +24 -0
- package/Server/Services/AlertStateTimelineService.ts +38 -20
- package/Server/Services/IncidentFeedService.ts +101 -2
- package/Server/Services/IncidentInternalNoteService.ts +47 -4
- package/Server/Services/IncidentOwnerTeamService.ts +57 -4
- package/Server/Services/IncidentOwnerUserService.ts +59 -15
- package/Server/Services/IncidentPublicNoteService.ts +47 -7
- package/Server/Services/IncidentService.ts +279 -193
- package/Server/Services/IncidentStateService.ts +25 -0
- package/Server/Services/IncidentStateTimelineService.ts +38 -19
- package/Server/Services/MonitorStatusTimelineService.ts +7 -17
- package/Server/Services/OnCallDutyPolicyEscalationRuleService.ts +2 -0
- package/Server/Services/OnCallDutyPolicyExecutionLogService.ts +74 -7
- package/Server/Services/OnCallDutyPolicyExecutionLogTimelineService.ts +63 -4
- package/Server/Services/OnCallDutyPolicyService.ts +13 -0
- package/Server/Services/ProjectUserService.ts +130 -0
- package/Server/Services/ScheduledMaintenanceFeedService.ts +105 -2
- package/Server/Services/ScheduledMaintenanceInternalNoteService.ts +61 -15
- package/Server/Services/ScheduledMaintenanceOwnerTeamService.ts +59 -18
- package/Server/Services/ScheduledMaintenanceOwnerUserService.ts +62 -30
- package/Server/Services/ScheduledMaintenancePublicNoteService.ts +59 -15
- package/Server/Services/ScheduledMaintenanceService.ts +390 -21
- package/Server/Services/ScheduledMaintenanceStateService.ts +122 -34
- package/Server/Services/ScheduledMaintenanceStateTimelineService.ts +34 -2
- package/Server/Services/StatusPageSubscriberService.ts +3 -0
- package/Server/Services/TeamMemberService.ts +20 -0
- package/Server/Services/UserNotificationRuleService.ts +74 -0
- package/Server/Services/UserOnCallLogService.ts +1 -1
- package/Server/Services/UserService.ts +35 -0
- package/Server/Services/WorkspaceNotificationRuleService.ts +520 -149
- package/Server/Services/WorkspaceUserAuthTokenService.ts +23 -0
- package/Server/Utils/Express.ts +1 -1
- package/Server/Utils/StartServer.ts +6 -1
- package/Server/Utils/Workspace/MicrosoftTeams/Actions/ActionTypes.ts +38 -0
- package/Server/Utils/Workspace/MicrosoftTeams/Messages/Alert.ts +116 -0
- package/Server/Utils/Workspace/MicrosoftTeams/Messages/Incident.ts +116 -0
- package/Server/Utils/Workspace/MicrosoftTeams/Messages/ScheduledMaintenance.ts +108 -0
- package/Server/Utils/Workspace/Slack/Actions/ActionTypes.ts +38 -0
- package/Server/Utils/Workspace/Slack/Actions/Alert.ts +697 -0
- package/Server/Utils/Workspace/Slack/Actions/Auth.ts +273 -0
- package/Server/Utils/Workspace/Slack/Actions/Incident.ts +1123 -0
- package/Server/Utils/Workspace/Slack/Actions/ScheduledMaintenance.ts +956 -0
- package/Server/Utils/Workspace/Slack/Messages/Alert.ts +116 -0
- package/Server/Utils/Workspace/Slack/Messages/Incident.ts +116 -0
- package/Server/Utils/Workspace/Slack/Messages/ScheduledMaintenance.ts +108 -0
- package/Server/Utils/Workspace/Slack/Slack.ts +601 -18
- package/Server/Utils/Workspace/Slack/app-manifest.json +19 -11
- package/Server/Utils/Workspace/Workspace.ts +194 -1
- package/Server/Utils/Workspace/WorkspaceBase.ts +159 -19
- package/Server/Utils/Workspace/WorkspaceMessages/Alert.ts +69 -0
- package/Server/Utils/Workspace/WorkspaceMessages/Incident.ts +68 -0
- package/Server/Utils/Workspace/WorkspaceMessages/ScheduledMaintenance.ts +73 -0
- package/Types/Date.ts +5 -0
- package/Types/Icon/IconProp.ts +1 -0
- package/Types/Workspace/NotificationRules/NotificationRuleCondition.ts +2 -1
- package/Types/Workspace/NotificationRules/NotificationRuleUtil.ts +251 -121
- package/Types/Workspace/NotificationRules/NotificationRuleWorkspaceChannel.ts +6 -0
- package/Types/Workspace/WorkspaceMessagePayload.ts +80 -2
- package/UI/Components/ComingSoon/ComingSoon.tsx +13 -3
- package/UI/Components/Forms/Fields/FormField.tsx +2 -2
- package/UI/Components/Icon/Icon.tsx +39 -2
- package/UI/Components/ModelTable/BaseModelTable.tsx +16 -0
- package/UI/Components/Radio/Radio.tsx +11 -2
- package/UI/Components/Table/TableCard.tsx +2 -2
- package/build/dist/Models/DatabaseModels/Alert.js.map +1 -1
- package/build/dist/Models/DatabaseModels/Incident.js.map +1 -1
- package/build/dist/Models/DatabaseModels/Index.js +2 -0
- package/build/dist/Models/DatabaseModels/Index.js.map +1 -1
- package/build/dist/Models/DatabaseModels/ProjectUser.js +340 -0
- package/build/dist/Models/DatabaseModels/ProjectUser.js.map +1 -0
- package/build/dist/Models/DatabaseModels/ScheduledMaintenance.js.map +1 -1
- package/build/dist/Server/API/SlackAPI.js +93 -79
- package/build/dist/Server/API/SlackAPI.js.map +1 -1
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1740597525803-MigrationName.js +12 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1740597525803-MigrationName.js.map +1 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1740598793630-MigrationName.js +12 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1740598793630-MigrationName.js.map +1 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1741031019972-MigrationName.js +12 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1741031019972-MigrationName.js.map +1 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1741209339971-MigrationName.js +42 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1741209339971-MigrationName.js.map +1 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/Index.js +8 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/Index.js.map +1 -1
- package/build/dist/Server/Middleware/SlackAuthorization.js +8 -2
- package/build/dist/Server/Middleware/SlackAuthorization.js.map +1 -1
- package/build/dist/Server/Services/AccessTokenService.js +11 -0
- package/build/dist/Server/Services/AccessTokenService.js.map +1 -1
- package/build/dist/Server/Services/AlertFeedService.js +62 -2
- package/build/dist/Server/Services/AlertFeedService.js.map +1 -1
- package/build/dist/Server/Services/AlertInternalNoteService.js +41 -10
- package/build/dist/Server/Services/AlertInternalNoteService.js.map +1 -1
- package/build/dist/Server/Services/AlertOwnerTeamService.js +42 -4
- package/build/dist/Server/Services/AlertOwnerTeamService.js.map +1 -1
- package/build/dist/Server/Services/AlertOwnerUserService.js +43 -5
- package/build/dist/Server/Services/AlertOwnerUserService.js.map +1 -1
- package/build/dist/Server/Services/AlertService.js +233 -51
- package/build/dist/Server/Services/AlertService.js.map +1 -1
- package/build/dist/Server/Services/AlertStateService.js +13 -0
- package/build/dist/Server/Services/AlertStateService.js.map +1 -1
- package/build/dist/Server/Services/AlertStateTimelineService.js +32 -18
- package/build/dist/Server/Services/AlertStateTimelineService.js.map +1 -1
- package/build/dist/Server/Services/IncidentFeedService.js +62 -2
- package/build/dist/Server/Services/IncidentFeedService.js.map +1 -1
- package/build/dist/Server/Services/IncidentInternalNoteService.js +35 -4
- package/build/dist/Server/Services/IncidentInternalNoteService.js.map +1 -1
- package/build/dist/Server/Services/IncidentOwnerTeamService.js +42 -4
- package/build/dist/Server/Services/IncidentOwnerTeamService.js.map +1 -1
- package/build/dist/Server/Services/IncidentOwnerUserService.js +43 -15
- package/build/dist/Server/Services/IncidentOwnerUserService.js.map +1 -1
- package/build/dist/Server/Services/IncidentPublicNoteService.js +36 -7
- package/build/dist/Server/Services/IncidentPublicNoteService.js.map +1 -1
- package/build/dist/Server/Services/IncidentService.js +221 -170
- package/build/dist/Server/Services/IncidentService.js.map +1 -1
- package/build/dist/Server/Services/IncidentStateService.js +14 -0
- package/build/dist/Server/Services/IncidentStateService.js.map +1 -1
- package/build/dist/Server/Services/IncidentStateTimelineService.js +31 -17
- package/build/dist/Server/Services/IncidentStateTimelineService.js.map +1 -1
- package/build/dist/Server/Services/MonitorStatusTimelineService.js +5 -15
- package/build/dist/Server/Services/MonitorStatusTimelineService.js.map +1 -1
- package/build/dist/Server/Services/OnCallDutyPolicyEscalationRuleService.js +1 -0
- package/build/dist/Server/Services/OnCallDutyPolicyEscalationRuleService.js.map +1 -1
- package/build/dist/Server/Services/OnCallDutyPolicyExecutionLogService.js +62 -7
- package/build/dist/Server/Services/OnCallDutyPolicyExecutionLogService.js.map +1 -1
- package/build/dist/Server/Services/OnCallDutyPolicyExecutionLogTimelineService.js +51 -5
- package/build/dist/Server/Services/OnCallDutyPolicyExecutionLogTimelineService.js.map +1 -1
- package/build/dist/Server/Services/OnCallDutyPolicyService.js +6 -0
- package/build/dist/Server/Services/OnCallDutyPolicyService.js.map +1 -1
- package/build/dist/Server/Services/ProjectUserService.js +106 -0
- package/build/dist/Server/Services/ProjectUserService.js.map +1 -0
- package/build/dist/Server/Services/ScheduledMaintenanceFeedService.js +62 -2
- package/build/dist/Server/Services/ScheduledMaintenanceFeedService.js.map +1 -1
- package/build/dist/Server/Services/ScheduledMaintenanceInternalNoteService.js +38 -8
- package/build/dist/Server/Services/ScheduledMaintenanceInternalNoteService.js.map +1 -1
- package/build/dist/Server/Services/ScheduledMaintenanceOwnerTeamService.js +28 -4
- package/build/dist/Server/Services/ScheduledMaintenanceOwnerTeamService.js.map +1 -1
- package/build/dist/Server/Services/ScheduledMaintenanceOwnerUserService.js +30 -16
- package/build/dist/Server/Services/ScheduledMaintenanceOwnerUserService.js.map +1 -1
- package/build/dist/Server/Services/ScheduledMaintenancePublicNoteService.js +38 -9
- package/build/dist/Server/Services/ScheduledMaintenancePublicNoteService.js.map +1 -1
- package/build/dist/Server/Services/ScheduledMaintenanceService.js +279 -14
- package/build/dist/Server/Services/ScheduledMaintenanceService.js.map +1 -1
- package/build/dist/Server/Services/ScheduledMaintenanceStateService.js +52 -4
- package/build/dist/Server/Services/ScheduledMaintenanceStateService.js.map +1 -1
- package/build/dist/Server/Services/ScheduledMaintenanceStateTimelineService.js +29 -2
- package/build/dist/Server/Services/ScheduledMaintenanceStateTimelineService.js.map +1 -1
- package/build/dist/Server/Services/StatusPageSubscriberService.js +3 -0
- package/build/dist/Server/Services/StatusPageSubscriberService.js.map +1 -1
- package/build/dist/Server/Services/TeamMemberService.js +17 -0
- package/build/dist/Server/Services/TeamMemberService.js.map +1 -1
- package/build/dist/Server/Services/UserNotificationRuleService.js +52 -0
- package/build/dist/Server/Services/UserNotificationRuleService.js.map +1 -1
- package/build/dist/Server/Services/UserOnCallLogService.js +1 -1
- package/build/dist/Server/Services/UserOnCallLogService.js.map +1 -1
- package/build/dist/Server/Services/UserService.js +23 -0
- package/build/dist/Server/Services/UserService.js.map +1 -1
- package/build/dist/Server/Services/WorkspaceNotificationRuleService.js +316 -84
- package/build/dist/Server/Services/WorkspaceNotificationRuleService.js.map +1 -1
- package/build/dist/Server/Services/WorkspaceUserAuthTokenService.js +18 -0
- package/build/dist/Server/Services/WorkspaceUserAuthTokenService.js.map +1 -1
- package/build/dist/Server/Utils/StartServer.js +4 -0
- package/build/dist/Server/Utils/StartServer.js.map +1 -1
- package/build/dist/Server/Utils/Workspace/MicrosoftTeams/Actions/ActionTypes.js +37 -0
- package/build/dist/Server/Utils/Workspace/MicrosoftTeams/Actions/ActionTypes.js.map +1 -0
- package/build/dist/Server/Utils/Workspace/MicrosoftTeams/Messages/Alert.js +82 -0
- package/build/dist/Server/Utils/Workspace/MicrosoftTeams/Messages/Alert.js.map +1 -0
- package/build/dist/Server/Utils/Workspace/MicrosoftTeams/Messages/Incident.js +82 -0
- package/build/dist/Server/Utils/Workspace/MicrosoftTeams/Messages/Incident.js.map +1 -0
- package/build/dist/Server/Utils/Workspace/MicrosoftTeams/Messages/ScheduledMaintenance.js +74 -0
- package/build/dist/Server/Utils/Workspace/MicrosoftTeams/Messages/ScheduledMaintenance.js.map +1 -0
- package/build/dist/Server/Utils/Workspace/Slack/Actions/ActionTypes.js +37 -0
- package/build/dist/Server/Utils/Workspace/Slack/Actions/ActionTypes.js.map +1 -0
- package/build/dist/Server/Utils/Workspace/Slack/Actions/Alert.js +425 -0
- package/build/dist/Server/Utils/Workspace/Slack/Actions/Alert.js.map +1 -0
- package/build/dist/Server/Utils/Workspace/Slack/Actions/Auth.js +169 -0
- package/build/dist/Server/Utils/Workspace/Slack/Actions/Auth.js.map +1 -0
- package/build/dist/Server/Utils/Workspace/Slack/Actions/Incident.js +730 -0
- package/build/dist/Server/Utils/Workspace/Slack/Actions/Incident.js.map +1 -0
- package/build/dist/Server/Utils/Workspace/Slack/Actions/ScheduledMaintenance.js +599 -0
- package/build/dist/Server/Utils/Workspace/Slack/Actions/ScheduledMaintenance.js.map +1 -0
- package/build/dist/Server/Utils/Workspace/Slack/Messages/Alert.js +82 -0
- package/build/dist/Server/Utils/Workspace/Slack/Messages/Alert.js.map +1 -0
- package/build/dist/Server/Utils/Workspace/Slack/Messages/Incident.js +82 -0
- package/build/dist/Server/Utils/Workspace/Slack/Messages/Incident.js.map +1 -0
- package/build/dist/Server/Utils/Workspace/Slack/Messages/ScheduledMaintenance.js +74 -0
- package/build/dist/Server/Utils/Workspace/Slack/Messages/ScheduledMaintenance.js.map +1 -0
- package/build/dist/Server/Utils/Workspace/Slack/Slack.js +431 -14
- package/build/dist/Server/Utils/Workspace/Slack/Slack.js.map +1 -1
- package/build/dist/Server/Utils/Workspace/Slack/app-manifest.json +19 -11
- package/build/dist/Server/Utils/Workspace/Workspace.js +126 -0
- package/build/dist/Server/Utils/Workspace/Workspace.js.map +1 -1
- package/build/dist/Server/Utils/Workspace/WorkspaceBase.js +77 -11
- package/build/dist/Server/Utils/Workspace/WorkspaceBase.js.map +1 -1
- package/build/dist/Server/Utils/Workspace/WorkspaceMessages/Alert.js +48 -0
- package/build/dist/Server/Utils/Workspace/WorkspaceMessages/Alert.js.map +1 -0
- package/build/dist/Server/Utils/Workspace/WorkspaceMessages/Incident.js +47 -0
- package/build/dist/Server/Utils/Workspace/WorkspaceMessages/Incident.js.map +1 -0
- package/build/dist/Server/Utils/Workspace/WorkspaceMessages/ScheduledMaintenance.js +47 -0
- package/build/dist/Server/Utils/Workspace/WorkspaceMessages/ScheduledMaintenance.js.map +1 -0
- package/build/dist/Types/Date.js +4 -0
- package/build/dist/Types/Date.js.map +1 -1
- package/build/dist/Types/Icon/IconProp.js +1 -0
- package/build/dist/Types/Icon/IconProp.js.map +1 -1
- package/build/dist/Types/Workspace/NotificationRules/NotificationRuleCondition.js +2 -1
- package/build/dist/Types/Workspace/NotificationRules/NotificationRuleCondition.js.map +1 -1
- package/build/dist/Types/Workspace/NotificationRules/NotificationRuleUtil.js +214 -120
- package/build/dist/Types/Workspace/NotificationRules/NotificationRuleUtil.js.map +1 -1
- package/build/dist/Types/Workspace/NotificationRules/NotificationRuleWorkspaceChannel.js +2 -0
- package/build/dist/Types/Workspace/NotificationRules/NotificationRuleWorkspaceChannel.js.map +1 -0
- package/build/dist/UI/Components/ComingSoon/ComingSoon.js +3 -2
- package/build/dist/UI/Components/ComingSoon/ComingSoon.js.map +1 -1
- package/build/dist/UI/Components/Forms/Fields/FormField.js +2 -2
- package/build/dist/UI/Components/Forms/Fields/FormField.js.map +1 -1
- package/build/dist/UI/Components/Icon/Icon.js +19 -2
- package/build/dist/UI/Components/Icon/Icon.js.map +1 -1
- package/build/dist/UI/Components/ModelTable/BaseModelTable.js +11 -0
- package/build/dist/UI/Components/ModelTable/BaseModelTable.js.map +1 -1
- package/build/dist/UI/Components/Radio/Radio.js +5 -2
- package/build/dist/UI/Components/Radio/Radio.js.map +1 -1
- package/build/dist/UI/Components/Table/TableCard.js +2 -2
- package/build/dist/UI/Components/Table/TableCard.js.map +1 -1
- package/package.json +3 -2
- package/Server/Utils/Workspace/Slack/app-manifest.example.json +0 -198
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { MigrationInterface, QueryRunner } from "typeorm";
|
|
2
|
+
|
|
3
|
+
export class MigrationName1740598793630 implements MigrationInterface {
|
|
4
|
+
public name = "MigrationName1740598793630";
|
|
5
|
+
|
|
6
|
+
public async up(queryRunner: QueryRunner): Promise<void> {
|
|
7
|
+
await queryRunner.query(
|
|
8
|
+
`ALTER TABLE "Incident" RENAME COLUMN "workspaceThreadIds" TO "workspaceSendMessageResponse"`,
|
|
9
|
+
);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
public async down(queryRunner: QueryRunner): Promise<void> {
|
|
13
|
+
await queryRunner.query(
|
|
14
|
+
`ALTER TABLE "Incident" RENAME COLUMN "workspaceSendMessageResponse" TO "workspaceThreadIds"`,
|
|
15
|
+
);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { MigrationInterface, QueryRunner } from "typeorm";
|
|
2
|
+
|
|
3
|
+
export class MigrationName1741031019972 implements MigrationInterface {
|
|
4
|
+
public name = "MigrationName1741031019972";
|
|
5
|
+
|
|
6
|
+
public async up(queryRunner: QueryRunner): Promise<void> {
|
|
7
|
+
await queryRunner.query(
|
|
8
|
+
`ALTER TABLE "Incident" DROP COLUMN "workspaceSendMessageResponse"`,
|
|
9
|
+
);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
public async down(queryRunner: QueryRunner): Promise<void> {
|
|
13
|
+
await queryRunner.query(
|
|
14
|
+
`ALTER TABLE "Incident" ADD "workspaceSendMessageResponse" jsonb`,
|
|
15
|
+
);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { MigrationInterface, QueryRunner } from "typeorm";
|
|
2
|
+
|
|
3
|
+
export class MigrationName1741209339971 implements MigrationInterface {
|
|
4
|
+
public name = "MigrationName1741209339971";
|
|
5
|
+
|
|
6
|
+
public async up(queryRunner: QueryRunner): Promise<void> {
|
|
7
|
+
await queryRunner.query(
|
|
8
|
+
`CREATE TABLE "ProjectUser" ("_id" uuid NOT NULL DEFAULT uuid_generate_v4(), "createdAt" TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), "updatedAt" TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), "deletedAt" TIMESTAMP WITH TIME ZONE, "version" integer NOT NULL, "projectId" uuid NOT NULL, "userId" uuid NOT NULL, "createdByUserId" uuid, "deletedByUserId" uuid, CONSTRAINT "PK_912199af7fc0be254b07b37306b" PRIMARY KEY ("_id"))`,
|
|
9
|
+
);
|
|
10
|
+
await queryRunner.query(
|
|
11
|
+
`CREATE INDEX "IDX_770271904cf388001552bc4755" ON "ProjectUser" ("projectId") `,
|
|
12
|
+
);
|
|
13
|
+
await queryRunner.query(
|
|
14
|
+
`CREATE TABLE "ProjectUserAcceptedTeams" ("projectUserId" uuid NOT NULL, "teamId" uuid NOT NULL, CONSTRAINT "PK_93ca44f68c74f4a859f2bcf260f" PRIMARY KEY ("projectUserId", "teamId"))`,
|
|
15
|
+
);
|
|
16
|
+
await queryRunner.query(
|
|
17
|
+
`CREATE INDEX "IDX_54f5c1c6cf385ffa6094430027" ON "ProjectUserAcceptedTeams" ("projectUserId") `,
|
|
18
|
+
);
|
|
19
|
+
await queryRunner.query(
|
|
20
|
+
`CREATE INDEX "IDX_e1731fb8a4540127d98fd28796" ON "ProjectUserAcceptedTeams" ("teamId") `,
|
|
21
|
+
);
|
|
22
|
+
await queryRunner.query(
|
|
23
|
+
`CREATE TABLE "ProjectUserInvitedTeams" ("projectUserId" uuid NOT NULL, "teamId" uuid NOT NULL, CONSTRAINT "PK_59cc028549a2c4e35005277a507" PRIMARY KEY ("projectUserId", "teamId"))`,
|
|
24
|
+
);
|
|
25
|
+
await queryRunner.query(
|
|
26
|
+
`CREATE INDEX "IDX_baa3a99d9c899e2e59c545e288" ON "ProjectUserInvitedTeams" ("projectUserId") `,
|
|
27
|
+
);
|
|
28
|
+
await queryRunner.query(
|
|
29
|
+
`CREATE INDEX "IDX_aa26c583621dab66eebfba67a4" ON "ProjectUserInvitedTeams" ("teamId") `,
|
|
30
|
+
);
|
|
31
|
+
await queryRunner.query(
|
|
32
|
+
`ALTER TABLE "ProjectUser" ADD CONSTRAINT "FK_770271904cf388001552bc47559" FOREIGN KEY ("projectId") REFERENCES "Project"("_id") ON DELETE CASCADE ON UPDATE NO ACTION`,
|
|
33
|
+
);
|
|
34
|
+
await queryRunner.query(
|
|
35
|
+
`ALTER TABLE "ProjectUser" ADD CONSTRAINT "FK_b2a608caefe7d8206517083d856" FOREIGN KEY ("userId") REFERENCES "User"("_id") ON DELETE CASCADE ON UPDATE NO ACTION`,
|
|
36
|
+
);
|
|
37
|
+
await queryRunner.query(
|
|
38
|
+
`ALTER TABLE "ProjectUser" ADD CONSTRAINT "FK_c4aa1af08370547825f1c76f70a" FOREIGN KEY ("createdByUserId") REFERENCES "User"("_id") ON DELETE SET NULL ON UPDATE NO ACTION`,
|
|
39
|
+
);
|
|
40
|
+
await queryRunner.query(
|
|
41
|
+
`ALTER TABLE "ProjectUser" ADD CONSTRAINT "FK_4a79e6f07a902e997f254c8c7eb" FOREIGN KEY ("deletedByUserId") REFERENCES "User"("_id") ON DELETE SET NULL ON UPDATE NO ACTION`,
|
|
42
|
+
);
|
|
43
|
+
await queryRunner.query(
|
|
44
|
+
`ALTER TABLE "ProjectUserAcceptedTeams" ADD CONSTRAINT "FK_54f5c1c6cf385ffa60944300270" FOREIGN KEY ("projectUserId") REFERENCES "ProjectUser"("_id") ON DELETE CASCADE ON UPDATE CASCADE`,
|
|
45
|
+
);
|
|
46
|
+
await queryRunner.query(
|
|
47
|
+
`ALTER TABLE "ProjectUserAcceptedTeams" ADD CONSTRAINT "FK_e1731fb8a4540127d98fd28796c" FOREIGN KEY ("teamId") REFERENCES "Team"("_id") ON DELETE CASCADE ON UPDATE CASCADE`,
|
|
48
|
+
);
|
|
49
|
+
await queryRunner.query(
|
|
50
|
+
`ALTER TABLE "ProjectUserInvitedTeams" ADD CONSTRAINT "FK_baa3a99d9c899e2e59c545e288b" FOREIGN KEY ("projectUserId") REFERENCES "ProjectUser"("_id") ON DELETE CASCADE ON UPDATE CASCADE`,
|
|
51
|
+
);
|
|
52
|
+
await queryRunner.query(
|
|
53
|
+
`ALTER TABLE "ProjectUserInvitedTeams" ADD CONSTRAINT "FK_aa26c583621dab66eebfba67a44" FOREIGN KEY ("teamId") REFERENCES "Team"("_id") ON DELETE CASCADE ON UPDATE CASCADE`,
|
|
54
|
+
);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
public async down(queryRunner: QueryRunner): Promise<void> {
|
|
58
|
+
await queryRunner.query(
|
|
59
|
+
`ALTER TABLE "ProjectUserInvitedTeams" DROP CONSTRAINT "FK_aa26c583621dab66eebfba67a44"`,
|
|
60
|
+
);
|
|
61
|
+
await queryRunner.query(
|
|
62
|
+
`ALTER TABLE "ProjectUserInvitedTeams" DROP CONSTRAINT "FK_baa3a99d9c899e2e59c545e288b"`,
|
|
63
|
+
);
|
|
64
|
+
await queryRunner.query(
|
|
65
|
+
`ALTER TABLE "ProjectUserAcceptedTeams" DROP CONSTRAINT "FK_e1731fb8a4540127d98fd28796c"`,
|
|
66
|
+
);
|
|
67
|
+
await queryRunner.query(
|
|
68
|
+
`ALTER TABLE "ProjectUserAcceptedTeams" DROP CONSTRAINT "FK_54f5c1c6cf385ffa60944300270"`,
|
|
69
|
+
);
|
|
70
|
+
await queryRunner.query(
|
|
71
|
+
`ALTER TABLE "ProjectUser" DROP CONSTRAINT "FK_4a79e6f07a902e997f254c8c7eb"`,
|
|
72
|
+
);
|
|
73
|
+
await queryRunner.query(
|
|
74
|
+
`ALTER TABLE "ProjectUser" DROP CONSTRAINT "FK_c4aa1af08370547825f1c76f70a"`,
|
|
75
|
+
);
|
|
76
|
+
await queryRunner.query(
|
|
77
|
+
`ALTER TABLE "ProjectUser" DROP CONSTRAINT "FK_b2a608caefe7d8206517083d856"`,
|
|
78
|
+
);
|
|
79
|
+
await queryRunner.query(
|
|
80
|
+
`ALTER TABLE "ProjectUser" DROP CONSTRAINT "FK_770271904cf388001552bc47559"`,
|
|
81
|
+
);
|
|
82
|
+
await queryRunner.query(
|
|
83
|
+
`DROP INDEX "public"."IDX_aa26c583621dab66eebfba67a4"`,
|
|
84
|
+
);
|
|
85
|
+
await queryRunner.query(
|
|
86
|
+
`DROP INDEX "public"."IDX_baa3a99d9c899e2e59c545e288"`,
|
|
87
|
+
);
|
|
88
|
+
await queryRunner.query(`DROP TABLE "ProjectUserInvitedTeams"`);
|
|
89
|
+
await queryRunner.query(
|
|
90
|
+
`DROP INDEX "public"."IDX_e1731fb8a4540127d98fd28796"`,
|
|
91
|
+
);
|
|
92
|
+
await queryRunner.query(
|
|
93
|
+
`DROP INDEX "public"."IDX_54f5c1c6cf385ffa6094430027"`,
|
|
94
|
+
);
|
|
95
|
+
await queryRunner.query(`DROP TABLE "ProjectUserAcceptedTeams"`);
|
|
96
|
+
await queryRunner.query(
|
|
97
|
+
`DROP INDEX "public"."IDX_770271904cf388001552bc4755"`,
|
|
98
|
+
);
|
|
99
|
+
await queryRunner.query(`DROP TABLE "ProjectUser"`);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
@@ -108,6 +108,10 @@ import { MigrationName1739569321582 } from "./1739569321582-MigrationName";
|
|
|
108
108
|
import { MigrationName1740164199817 } from "./1740164199817-MigrationName";
|
|
109
109
|
import { MigrationName1740419151825 } from "./1740419151825-MigrationName";
|
|
110
110
|
import { MigrationName1740430229844 } from "./1740430229844-MigrationName";
|
|
111
|
+
import { MigrationName1740597525803 } from "./1740597525803-MigrationName";
|
|
112
|
+
import { MigrationName1740598793630 } from "./1740598793630-MigrationName";
|
|
113
|
+
import { MigrationName1741031019972 } from "./1741031019972-MigrationName";
|
|
114
|
+
import { MigrationName1741209339971 } from "./1741209339971-MigrationName";
|
|
111
115
|
|
|
112
116
|
export default [
|
|
113
117
|
InitialMigration,
|
|
@@ -220,4 +224,8 @@ export default [
|
|
|
220
224
|
MigrationName1740164199817,
|
|
221
225
|
MigrationName1740419151825,
|
|
222
226
|
MigrationName1740430229844,
|
|
227
|
+
MigrationName1740597525803,
|
|
228
|
+
MigrationName1740598793630,
|
|
229
|
+
MigrationName1741031019972,
|
|
230
|
+
MigrationName1741209339971,
|
|
223
231
|
];
|
|
@@ -15,7 +15,10 @@ export default class SlackAuthorization {
|
|
|
15
15
|
res: ExpressResponse,
|
|
16
16
|
next: NextFunction,
|
|
17
17
|
): Promise<void> {
|
|
18
|
+
logger.debug("Starting Slack request authorization");
|
|
19
|
+
|
|
18
20
|
if (!SlackAppSigningSecret) {
|
|
21
|
+
logger.error("SLACK_APP_SIGNING_SECRET env variable not found.");
|
|
19
22
|
return Response.sendErrorResponse(
|
|
20
23
|
req,
|
|
21
24
|
res,
|
|
@@ -32,15 +35,19 @@ export default class SlackAuthorization {
|
|
|
32
35
|
const timestamp: string = req.headers[
|
|
33
36
|
"x-slack-request-timestamp"
|
|
34
37
|
] as string;
|
|
35
|
-
const requestBody: string =
|
|
38
|
+
const requestBody: string =
|
|
39
|
+
(req as OneUptimeRequest).rawFormUrlEncodedBody || "";
|
|
36
40
|
|
|
37
41
|
logger.debug(`slackSignature: ${slackSignature}`);
|
|
38
42
|
logger.debug(`timestamp: ${timestamp}`);
|
|
39
|
-
logger.debug(`requestBody:
|
|
43
|
+
logger.debug(`requestBody: `);
|
|
44
|
+
logger.debug(requestBody);
|
|
40
45
|
|
|
41
46
|
const baseString: string = `v0:${timestamp}:${requestBody}`;
|
|
42
47
|
const signature: string = `v0=${crypto.createHmac("sha256", slackSigningSecret).update(baseString).digest("hex")}`;
|
|
43
48
|
|
|
49
|
+
logger.debug(`Generated signature: ${signature}`);
|
|
50
|
+
|
|
44
51
|
// check if the signature is valid
|
|
45
52
|
if (
|
|
46
53
|
!crypto.timingSafeEqual(
|
|
@@ -48,6 +55,7 @@ export default class SlackAuthorization {
|
|
|
48
55
|
Buffer.from(slackSignature),
|
|
49
56
|
)
|
|
50
57
|
) {
|
|
58
|
+
logger.error("Slack Signature Verification Failed.");
|
|
51
59
|
return Response.sendErrorResponse(
|
|
52
60
|
req,
|
|
53
61
|
res,
|
|
@@ -55,6 +63,7 @@ export default class SlackAuthorization {
|
|
|
55
63
|
);
|
|
56
64
|
}
|
|
57
65
|
|
|
66
|
+
logger.debug("Slack request authorized successfully");
|
|
58
67
|
next();
|
|
59
68
|
}
|
|
60
69
|
}
|
|
@@ -15,6 +15,7 @@ import TeamMember from "Common/Models/DatabaseModels/TeamMember";
|
|
|
15
15
|
import TeamPermission from "Common/Models/DatabaseModels/TeamPermission";
|
|
16
16
|
import UserPermissionUtil from "../Utils/UserPermission/UserPermission";
|
|
17
17
|
import PermissionNamespace from "../Types/Permission/PermissionNamespace";
|
|
18
|
+
import DatabaseCommonInteractionProps from "../../Types/BaseDatabase/DatabaseCommonInteractionProps";
|
|
18
19
|
|
|
19
20
|
export class AccessTokenService extends BaseService {
|
|
20
21
|
public constructor() {
|
|
@@ -198,6 +199,26 @@ export class AccessTokenService extends BaseService {
|
|
|
198
199
|
return permission;
|
|
199
200
|
}
|
|
200
201
|
|
|
202
|
+
public async getDatabaseCommonInteractionPropsByUserAndProject(data: {
|
|
203
|
+
userId: ObjectID;
|
|
204
|
+
projectId: ObjectID;
|
|
205
|
+
}): Promise<DatabaseCommonInteractionProps> {
|
|
206
|
+
const { userId, projectId } = data;
|
|
207
|
+
|
|
208
|
+
return {
|
|
209
|
+
userId: userId,
|
|
210
|
+
userGlobalAccessPermission:
|
|
211
|
+
(await this.getUserGlobalAccessPermission(userId)) || undefined,
|
|
212
|
+
userTenantAccessPermission: {
|
|
213
|
+
[projectId.toString()]: (await this.getUserTenantAccessPermission(
|
|
214
|
+
userId,
|
|
215
|
+
projectId,
|
|
216
|
+
))!,
|
|
217
|
+
},
|
|
218
|
+
tenantId: projectId,
|
|
219
|
+
};
|
|
220
|
+
}
|
|
221
|
+
|
|
201
222
|
public async getUserTenantAccessPermission(
|
|
202
223
|
userId: ObjectID,
|
|
203
224
|
projectId: ObjectID,
|
|
@@ -3,12 +3,21 @@ import Color from "../../Types/Color";
|
|
|
3
3
|
import OneUptimeDate from "../../Types/Date";
|
|
4
4
|
import BadDataException from "../../Types/Exception/BadDataException";
|
|
5
5
|
import ObjectID from "../../Types/ObjectID";
|
|
6
|
+
import WorkspaceMessagePayload from "../../Types/Workspace/WorkspaceMessagePayload";
|
|
6
7
|
import { IsBillingEnabled } from "../EnvironmentConfig";
|
|
7
8
|
import logger from "../Utils/Logger";
|
|
9
|
+
import { WorkspaceChannel } from "../Utils/Workspace/WorkspaceBase";
|
|
10
|
+
import AlertService from "./AlertService";
|
|
8
11
|
import DatabaseService from "./DatabaseService";
|
|
9
12
|
import Model, {
|
|
10
13
|
AlertFeedEventType,
|
|
11
14
|
} from "Common/Models/DatabaseModels/AlertFeed";
|
|
15
|
+
import WorkspaceNotificationRuleService, {
|
|
16
|
+
MessageBlocksByWorkspaceType,
|
|
17
|
+
} from "./WorkspaceNotificationRuleService";
|
|
18
|
+
import NotificationRuleEventType from "../../Types/Workspace/NotificationRules/EventType";
|
|
19
|
+
import WorkspaceUtil from "../Utils/Workspace/Workspace";
|
|
20
|
+
import WorkspaceType from "../../Types/Workspace/WorkspaceType";
|
|
12
21
|
|
|
13
22
|
export class Service extends DatabaseService<Model> {
|
|
14
23
|
public constructor() {
|
|
@@ -19,7 +28,7 @@ export class Service extends DatabaseService<Model> {
|
|
|
19
28
|
}
|
|
20
29
|
}
|
|
21
30
|
|
|
22
|
-
public async
|
|
31
|
+
public async createAlertFeedItem(data: {
|
|
23
32
|
alertId: ObjectID;
|
|
24
33
|
feedInfoInMarkdown: string;
|
|
25
34
|
alertFeedEventType: AlertFeedEventType;
|
|
@@ -28,6 +37,13 @@ export class Service extends DatabaseService<Model> {
|
|
|
28
37
|
displayColor?: Color | undefined;
|
|
29
38
|
userId?: ObjectID | undefined;
|
|
30
39
|
postedAt?: Date | undefined;
|
|
40
|
+
workspaceNotification?:
|
|
41
|
+
| {
|
|
42
|
+
notifyUserId?: ObjectID | undefined; // this is oneuptime user id.
|
|
43
|
+
sendWorkspaceNotification: boolean;
|
|
44
|
+
appendMessageBlocks?: Array<MessageBlocksByWorkspaceType> | undefined;
|
|
45
|
+
}
|
|
46
|
+
| undefined;
|
|
31
47
|
}): Promise<void> {
|
|
32
48
|
try {
|
|
33
49
|
if (!data.alertId) {
|
|
@@ -77,8 +93,90 @@ export class Service extends DatabaseService<Model> {
|
|
|
77
93
|
isRoot: true,
|
|
78
94
|
},
|
|
79
95
|
});
|
|
96
|
+
|
|
97
|
+
try {
|
|
98
|
+
// send notification to slack and teams
|
|
99
|
+
if (data.workspaceNotification?.sendWorkspaceNotification) {
|
|
100
|
+
let messageBlocksByWorkspaceTypes: Array<MessageBlocksByWorkspaceType> =
|
|
101
|
+
[];
|
|
102
|
+
|
|
103
|
+
// use markdown to create blocks
|
|
104
|
+
messageBlocksByWorkspaceTypes =
|
|
105
|
+
await WorkspaceUtil.getMessageBlocksByMarkdown({
|
|
106
|
+
userId: data.workspaceNotification.notifyUserId,
|
|
107
|
+
markdown: data.feedInfoInMarkdown,
|
|
108
|
+
projectId: data.projectId,
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
if (data.workspaceNotification.appendMessageBlocks) {
|
|
112
|
+
for (const messageBlocksByWorkspaceType of data
|
|
113
|
+
.workspaceNotification.appendMessageBlocks) {
|
|
114
|
+
const workspaceType: WorkspaceType =
|
|
115
|
+
messageBlocksByWorkspaceType.workspaceType;
|
|
116
|
+
|
|
117
|
+
messageBlocksByWorkspaceTypes
|
|
118
|
+
.find(
|
|
119
|
+
(
|
|
120
|
+
messageBlocksByWorkspaceType: MessageBlocksByWorkspaceType,
|
|
121
|
+
) => {
|
|
122
|
+
return (
|
|
123
|
+
messageBlocksByWorkspaceType.workspaceType ===
|
|
124
|
+
workspaceType
|
|
125
|
+
);
|
|
126
|
+
},
|
|
127
|
+
)
|
|
128
|
+
?.messageBlocks.push(
|
|
129
|
+
...messageBlocksByWorkspaceType.messageBlocks,
|
|
130
|
+
);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
const workspaceNotificationPaylaods: Array<WorkspaceMessagePayload> =
|
|
135
|
+
[];
|
|
136
|
+
|
|
137
|
+
for (const messageBlocksByWorkspaceType of messageBlocksByWorkspaceTypes) {
|
|
138
|
+
const existingChannels: Array<string> =
|
|
139
|
+
await WorkspaceNotificationRuleService.getExistingChannelNamesBasedOnEventType(
|
|
140
|
+
{
|
|
141
|
+
projectId: data.projectId,
|
|
142
|
+
notificationRuleEventType: NotificationRuleEventType.Alert,
|
|
143
|
+
workspaceType: messageBlocksByWorkspaceType.workspaceType,
|
|
144
|
+
},
|
|
145
|
+
);
|
|
146
|
+
|
|
147
|
+
const alertChannels: Array<WorkspaceChannel> =
|
|
148
|
+
await AlertService.getWorkspaceChannelForAlert({
|
|
149
|
+
alertId: data.alertId,
|
|
150
|
+
workspaceType: messageBlocksByWorkspaceType.workspaceType,
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
const workspaceMessagePayload: WorkspaceMessagePayload = {
|
|
154
|
+
_type: "WorkspaceMessagePayload",
|
|
155
|
+
workspaceType: messageBlocksByWorkspaceType.workspaceType,
|
|
156
|
+
messageBlocks: messageBlocksByWorkspaceType.messageBlocks,
|
|
157
|
+
channelNames: existingChannels,
|
|
158
|
+
channelIds:
|
|
159
|
+
alertChannels.map((channel: WorkspaceChannel) => {
|
|
160
|
+
return channel.id;
|
|
161
|
+
}) || [],
|
|
162
|
+
};
|
|
163
|
+
|
|
164
|
+
workspaceNotificationPaylaods.push(workspaceMessagePayload);
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
await WorkspaceUtil.postMessageToAllWorkspaceChannelsAsBot({
|
|
168
|
+
projectId: data.projectId,
|
|
169
|
+
messagePayloadsByWorkspace: workspaceNotificationPaylaods,
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
} catch (e) {
|
|
173
|
+
logger.error("Error in sending notification to slack and teams");
|
|
174
|
+
logger.error(e);
|
|
175
|
+
|
|
176
|
+
// we dont throw this error as it is not a critical error
|
|
177
|
+
}
|
|
80
178
|
} catch (error) {
|
|
81
|
-
logger.error("AlertFeedService.
|
|
179
|
+
logger.error("AlertFeedService.createAlertFeedItem");
|
|
82
180
|
logger.error(error);
|
|
83
181
|
// we dont want to throw the error here, as this is a non-critical operation
|
|
84
182
|
}
|
|
@@ -6,12 +6,34 @@ import AlertFeedService from "./AlertFeedService";
|
|
|
6
6
|
import { AlertFeedEventType } from "../../Models/DatabaseModels/AlertFeed";
|
|
7
7
|
import { Blue500 } from "../../Types/BrandColors";
|
|
8
8
|
import { LIMIT_PER_PROJECT } from "../../Types/Database/LimitMax";
|
|
9
|
+
import Alert from "../../Models/DatabaseModels/Alert";
|
|
10
|
+
import AlertService from "./AlertService";
|
|
9
11
|
|
|
10
12
|
export class Service extends DatabaseService<Model> {
|
|
11
13
|
public constructor() {
|
|
12
14
|
super(Model);
|
|
13
15
|
}
|
|
14
16
|
|
|
17
|
+
public async addNote(data: {
|
|
18
|
+
userId: ObjectID;
|
|
19
|
+
alertId: ObjectID;
|
|
20
|
+
projectId: ObjectID;
|
|
21
|
+
note: string;
|
|
22
|
+
}): Promise<Model> {
|
|
23
|
+
const internalNote: Model = new Model();
|
|
24
|
+
internalNote.createdByUserId = data.userId;
|
|
25
|
+
internalNote.alertId = data.alertId;
|
|
26
|
+
internalNote.projectId = data.projectId;
|
|
27
|
+
internalNote.note = data.note;
|
|
28
|
+
|
|
29
|
+
return this.create({
|
|
30
|
+
data: internalNote,
|
|
31
|
+
props: {
|
|
32
|
+
isRoot: true,
|
|
33
|
+
},
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
|
|
15
37
|
public override async onCreateSuccess(
|
|
16
38
|
_onCreate: OnCreate<Model>,
|
|
17
39
|
createdItem: Model,
|
|
@@ -19,17 +41,27 @@ export class Service extends DatabaseService<Model> {
|
|
|
19
41
|
const userId: ObjectID | null | undefined =
|
|
20
42
|
createdItem.createdByUserId || createdItem.createdByUser?.id;
|
|
21
43
|
|
|
22
|
-
|
|
44
|
+
const alertId: ObjectID = createdItem.alertId!;
|
|
45
|
+
|
|
46
|
+
const alertNumber: number | null = await AlertService.getAlertNumber({
|
|
47
|
+
alertId: alertId,
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
await AlertFeedService.createAlertFeedItem({
|
|
23
51
|
alertId: createdItem.alertId!,
|
|
24
52
|
projectId: createdItem.projectId!,
|
|
25
53
|
alertFeedEventType: AlertFeedEventType.PrivateNote,
|
|
26
54
|
displayColor: Blue500,
|
|
27
55
|
userId: userId || undefined,
|
|
28
56
|
|
|
29
|
-
feedInfoInMarkdown:
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
57
|
+
feedInfoInMarkdown: `📄 posted **private note** for this [Alert ${alertNumber}](${(await AlertService.getAlertLinkInDashboard(createdItem.projectId!, alertId)).toString()}):
|
|
58
|
+
|
|
59
|
+
${createdItem.note}
|
|
60
|
+
`,
|
|
61
|
+
workspaceNotification: {
|
|
62
|
+
sendWorkspaceNotification: true,
|
|
63
|
+
notifyUserId: userId || undefined,
|
|
64
|
+
},
|
|
33
65
|
});
|
|
34
66
|
|
|
35
67
|
return createdItem;
|
|
@@ -52,6 +84,10 @@ export class Service extends DatabaseService<Model> {
|
|
|
52
84
|
projectId: true,
|
|
53
85
|
note: true,
|
|
54
86
|
createdByUserId: true,
|
|
87
|
+
alert: {
|
|
88
|
+
projectId: true,
|
|
89
|
+
alertNumber: true,
|
|
90
|
+
},
|
|
55
91
|
createdByUser: {
|
|
56
92
|
_id: true,
|
|
57
93
|
},
|
|
@@ -62,17 +98,22 @@ export class Service extends DatabaseService<Model> {
|
|
|
62
98
|
onUpdate.updateBy.props.userId;
|
|
63
99
|
|
|
64
100
|
for (const updatedItem of updatedItems) {
|
|
65
|
-
|
|
101
|
+
const alert: Alert = updatedItem.alert!;
|
|
102
|
+
await AlertFeedService.createAlertFeedItem({
|
|
66
103
|
alertId: updatedItem.alertId!,
|
|
67
104
|
projectId: updatedItem.projectId!,
|
|
68
105
|
alertFeedEventType: AlertFeedEventType.PrivateNote,
|
|
69
106
|
displayColor: Blue500,
|
|
70
107
|
userId: userId || undefined,
|
|
71
108
|
|
|
72
|
-
feedInfoInMarkdown:
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
109
|
+
feedInfoInMarkdown: `📄 updated **Private Note** for this [Alert ${alert.alertNumber}](${(await AlertService.getAlertLinkInDashboard(alert.projectId!, alert.id!)).toString()})
|
|
110
|
+
|
|
111
|
+
${updatedItem.note}
|
|
112
|
+
`,
|
|
113
|
+
workspaceNotification: {
|
|
114
|
+
sendWorkspaceNotification: true,
|
|
115
|
+
notifyUserId: userId || undefined,
|
|
116
|
+
},
|
|
76
117
|
});
|
|
77
118
|
}
|
|
78
119
|
}
|
|
@@ -8,6 +8,11 @@ import TeamService from "./TeamService";
|
|
|
8
8
|
import AlertFeedService from "./AlertFeedService";
|
|
9
9
|
import { AlertFeedEventType } from "../../Models/DatabaseModels/AlertFeed";
|
|
10
10
|
import { Gray500, Red500 } from "../../Types/BrandColors";
|
|
11
|
+
import AlertService from "./AlertService";
|
|
12
|
+
import WorkspaceNotificationRule from "../../Models/DatabaseModels/WorkspaceNotificationRule";
|
|
13
|
+
import WorkspaceNotificationRuleService from "./WorkspaceNotificationRuleService";
|
|
14
|
+
import NotificationRuleEventType from "../../Types/Workspace/NotificationRules/EventType";
|
|
15
|
+
import logger from "../Utils/Logger";
|
|
11
16
|
|
|
12
17
|
export class Service extends DatabaseService<Model> {
|
|
13
18
|
public constructor() {
|
|
@@ -65,13 +70,20 @@ export class Service extends DatabaseService<Model> {
|
|
|
65
70
|
});
|
|
66
71
|
|
|
67
72
|
if (team && team.name) {
|
|
68
|
-
await
|
|
73
|
+
const alertNumber: number | null = await AlertService.getAlertNumber({
|
|
74
|
+
alertId: alertId,
|
|
75
|
+
});
|
|
76
|
+
await AlertFeedService.createAlertFeedItem({
|
|
69
77
|
alertId: alertId,
|
|
70
78
|
projectId: projectId,
|
|
71
79
|
alertFeedEventType: AlertFeedEventType.OwnerTeamRemoved,
|
|
72
80
|
displayColor: Red500,
|
|
73
|
-
feedInfoInMarkdown:
|
|
81
|
+
feedInfoInMarkdown: `👨🏻👩🏻👦🏻 Removed team **${team.name}** from the [Alert ${alertNumber}](${(await AlertService.getAlertLinkInDashboard(projectId!, alertId!)).toString()}) as the owner.`,
|
|
74
82
|
userId: deleteByUserId || undefined,
|
|
83
|
+
workspaceNotification: {
|
|
84
|
+
sendWorkspaceNotification: true,
|
|
85
|
+
notifyUserId: deleteByUserId || undefined,
|
|
86
|
+
},
|
|
75
87
|
});
|
|
76
88
|
}
|
|
77
89
|
}
|
|
@@ -104,17 +116,53 @@ export class Service extends DatabaseService<Model> {
|
|
|
104
116
|
});
|
|
105
117
|
|
|
106
118
|
if (team && team.name) {
|
|
107
|
-
await
|
|
119
|
+
const alertNumber: number | null = await AlertService.getAlertNumber({
|
|
120
|
+
alertId: alertId,
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
await AlertFeedService.createAlertFeedItem({
|
|
108
124
|
alertId: alertId,
|
|
109
125
|
projectId: projectId,
|
|
110
126
|
alertFeedEventType: AlertFeedEventType.OwnerTeamAdded,
|
|
111
127
|
displayColor: Gray500,
|
|
112
|
-
feedInfoInMarkdown:
|
|
128
|
+
feedInfoInMarkdown: `👨🏻👩🏻👦🏻 Added team **${team.name}** to the [Alert ${alertNumber}](${(await AlertService.getAlertLinkInDashboard(projectId!, alertId!)).toString()}) as the owner.`,
|
|
113
129
|
userId: createdByUserId || undefined,
|
|
130
|
+
workspaceNotification: {
|
|
131
|
+
sendWorkspaceNotification: true,
|
|
132
|
+
notifyUserId: createdByUserId || undefined,
|
|
133
|
+
},
|
|
114
134
|
});
|
|
115
135
|
}
|
|
116
136
|
}
|
|
117
137
|
|
|
138
|
+
// get notification rule where inviteOwners is true.
|
|
139
|
+
const notificationRules: Array<WorkspaceNotificationRule> =
|
|
140
|
+
await WorkspaceNotificationRuleService.getNotificationRulesWhereInviteOwnersIsTrue(
|
|
141
|
+
{
|
|
142
|
+
projectId: projectId!,
|
|
143
|
+
notificationFor: {
|
|
144
|
+
alertId: alertId,
|
|
145
|
+
},
|
|
146
|
+
notificationRuleEventType: NotificationRuleEventType.Alert,
|
|
147
|
+
},
|
|
148
|
+
);
|
|
149
|
+
|
|
150
|
+
logger.debug(`Notification Rules for Alert Owner Teams`);
|
|
151
|
+
logger.debug(notificationRules);
|
|
152
|
+
|
|
153
|
+
WorkspaceNotificationRuleService.inviteTeamsBasedOnRulesAndWorkspaceChannels(
|
|
154
|
+
{
|
|
155
|
+
notificationRules: notificationRules,
|
|
156
|
+
projectId: projectId!,
|
|
157
|
+
workspaceChannels: await AlertService.getWorkspaceChannelForAlert({
|
|
158
|
+
alertId: alertId!,
|
|
159
|
+
}),
|
|
160
|
+
teamIds: [teamId!],
|
|
161
|
+
},
|
|
162
|
+
).catch((error: Error) => {
|
|
163
|
+
logger.error(error);
|
|
164
|
+
});
|
|
165
|
+
|
|
118
166
|
return createdItem;
|
|
119
167
|
}
|
|
120
168
|
}
|
|
@@ -8,6 +8,11 @@ import UserService from "./UserService";
|
|
|
8
8
|
import AlertFeedService from "./AlertFeedService";
|
|
9
9
|
import { AlertFeedEventType } from "../../Models/DatabaseModels/AlertFeed";
|
|
10
10
|
import { Gray500, Red500 } from "../../Types/BrandColors";
|
|
11
|
+
import AlertService from "./AlertService";
|
|
12
|
+
import WorkspaceNotificationRule from "../../Models/DatabaseModels/WorkspaceNotificationRule";
|
|
13
|
+
import WorkspaceNotificationRuleService from "./WorkspaceNotificationRuleService";
|
|
14
|
+
import NotificationRuleEventType from "../../Types/Workspace/NotificationRules/EventType";
|
|
15
|
+
import logger from "../Utils/Logger";
|
|
11
16
|
|
|
12
17
|
export class Service extends DatabaseService<Model> {
|
|
13
18
|
public constructor() {
|
|
@@ -66,13 +71,21 @@ export class Service extends DatabaseService<Model> {
|
|
|
66
71
|
});
|
|
67
72
|
|
|
68
73
|
if (user && user.name) {
|
|
69
|
-
await
|
|
74
|
+
const alertNumber: number | null = await AlertService.getAlertNumber({
|
|
75
|
+
alertId: alertId,
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
await AlertFeedService.createAlertFeedItem({
|
|
70
79
|
alertId: alertId,
|
|
71
80
|
projectId: projectId,
|
|
72
81
|
alertFeedEventType: AlertFeedEventType.OwnerUserRemoved,
|
|
73
82
|
displayColor: Red500,
|
|
74
|
-
feedInfoInMarkdown:
|
|
83
|
+
feedInfoInMarkdown: `👨🏻💻 Removed **${user.name.toString()}** (${user.email?.toString()}) from the [Alert ${alertNumber}](${(await AlertService.getAlertLinkInDashboard(projectId!, alertId!)).toString()}) as the owner.`,
|
|
75
84
|
userId: deleteByUserId || undefined,
|
|
85
|
+
workspaceNotification: {
|
|
86
|
+
sendWorkspaceNotification: true,
|
|
87
|
+
notifyUserId: userId || undefined,
|
|
88
|
+
},
|
|
76
89
|
});
|
|
77
90
|
}
|
|
78
91
|
}
|
|
@@ -106,17 +119,54 @@ export class Service extends DatabaseService<Model> {
|
|
|
106
119
|
});
|
|
107
120
|
|
|
108
121
|
if (user && user.name) {
|
|
109
|
-
await
|
|
122
|
+
const alertNumber: number | null = await AlertService.getAlertNumber({
|
|
123
|
+
alertId: alertId,
|
|
124
|
+
});
|
|
125
|
+
await AlertFeedService.createAlertFeedItem({
|
|
110
126
|
alertId: alertId,
|
|
111
127
|
projectId: projectId,
|
|
112
128
|
alertFeedEventType: AlertFeedEventType.OwnerUserAdded,
|
|
113
129
|
displayColor: Gray500,
|
|
114
|
-
feedInfoInMarkdown:
|
|
130
|
+
feedInfoInMarkdown: `👨🏻💻 Added **${await UserService.getUserMarkdownString(
|
|
131
|
+
{
|
|
132
|
+
userId: userId,
|
|
133
|
+
projectId: projectId,
|
|
134
|
+
},
|
|
135
|
+
)}** to the [Alert ${alertNumber}](${(await AlertService.getAlertLinkInDashboard(projectId!, alertId!)).toString()}) as the owner.`,
|
|
115
136
|
userId: createdByUserId || undefined,
|
|
137
|
+
workspaceNotification: {
|
|
138
|
+
sendWorkspaceNotification: true,
|
|
139
|
+
notifyUserId: userId || undefined,
|
|
140
|
+
},
|
|
116
141
|
});
|
|
117
142
|
}
|
|
118
143
|
}
|
|
119
144
|
|
|
145
|
+
// get notification rule where inviteOwners is true.
|
|
146
|
+
const notificationRules: Array<WorkspaceNotificationRule> =
|
|
147
|
+
await WorkspaceNotificationRuleService.getNotificationRulesWhereInviteOwnersIsTrue(
|
|
148
|
+
{
|
|
149
|
+
projectId: projectId!,
|
|
150
|
+
notificationFor: {
|
|
151
|
+
alertId: alertId,
|
|
152
|
+
},
|
|
153
|
+
notificationRuleEventType: NotificationRuleEventType.Alert,
|
|
154
|
+
},
|
|
155
|
+
);
|
|
156
|
+
|
|
157
|
+
WorkspaceNotificationRuleService.inviteUsersBasedOnRulesAndWorkspaceChannels(
|
|
158
|
+
{
|
|
159
|
+
notificationRules: notificationRules,
|
|
160
|
+
projectId: projectId!,
|
|
161
|
+
workspaceChannels: await AlertService.getWorkspaceChannelForAlert({
|
|
162
|
+
alertId: alertId!,
|
|
163
|
+
}),
|
|
164
|
+
userIds: [userId!],
|
|
165
|
+
},
|
|
166
|
+
).catch((error: Error) => {
|
|
167
|
+
logger.error(error);
|
|
168
|
+
});
|
|
169
|
+
|
|
120
170
|
return createdItem;
|
|
121
171
|
}
|
|
122
172
|
}
|