diff --git a/backend/src/server/routes/index.ts b/backend/src/server/routes/index.ts index 45054e0ec..019310e1e 100644 --- a/backend/src/server/routes/index.ts +++ b/backend/src/server/routes/index.ts @@ -1148,7 +1148,8 @@ export const registerRoutes = async ( appConnectionDAL, licenseService, gatewayService, - gatewayV2Service + gatewayV2Service, + notificationService }); const secretQueueService = secretQueueFactory({ diff --git a/backend/src/services/notification/notification-types.ts b/backend/src/services/notification/notification-types.ts index 82ea1f553..a3657c680 100644 --- a/backend/src/services/notification/notification-types.ts +++ b/backend/src/services/notification/notification-types.ts @@ -14,7 +14,8 @@ export enum NotificationType { IMPORT_FAILED = "import-failed", DIRECT_PROJECT_ACCESS_ISSUED_TO_ADMIN = "direct-project-access-issued-to-admin", PROJECT_ACCESS_REQUEST = "project-access-request", - PROJECT_INVITATION = "project-invitation" + PROJECT_INVITATION = "project-invitation", + SECRET_SYNC_FAILED = "secret-sync-failed" } export interface TCreateUserNotificationDTO { diff --git a/backend/src/services/secret-sync/secret-sync-queue.ts b/backend/src/services/secret-sync/secret-sync-queue.ts index a31bb202d..63faf3b03 100644 --- a/backend/src/services/secret-sync/secret-sync-queue.ts +++ b/backend/src/services/secret-sync/secret-sync-queue.ts @@ -61,6 +61,8 @@ import { SmtpTemplates, TSmtpService } from "@app/services/smtp/smtp-service"; import { TAppConnectionDALFactory } from "../app-connection/app-connection-dal"; import { TFolderCommitServiceFactory } from "../folder-commit/folder-commit-service"; +import { TNotificationServiceFactory } from "../notification/notification-service"; +import { NotificationType } from "../notification/notification-types"; export type TSecretSyncQueueFactory = ReturnType; @@ -100,6 +102,7 @@ type TSecretSyncQueueFactoryDep = { licenseService: Pick; gatewayService: Pick; gatewayV2Service: Pick; + notificationService: Pick; }; type SecretSyncActionJob = Job< @@ -142,7 +145,8 @@ export const secretSyncQueueFactory = ({ folderCommitService, licenseService, gatewayService, - gatewayV2Service + gatewayV2Service, + notificationService }: TSecretSyncQueueFactoryDep) => { const appCfg = getConfig(); @@ -898,6 +902,19 @@ export const secretSyncQueueFactory = ({ break; } + const syncPath = `/projects/secret-management/${projectId}/integrations/secret-syncs/${destination}/${secretSync.id}`; + + await notificationService.createUserNotifications( + projectAdmins.map((admin) => ({ + userId: admin.userId, + orgId: project.orgId, + type: NotificationType.SECRET_SYNC_FAILED, + title: `Secret Sync Failed to ${actionLabel} Secrets`, + body: `Your **${syncDestination}** sync **${name}** failed to complete${failureMessage ? `: \`${failureMessage}\`` : ""}`, + link: syncPath + })) + ); + await smtpService.sendMail({ recipients: projectAdmins.map((member) => member.user.email!).filter(Boolean), template: SmtpTemplates.SecretSyncFailed, @@ -910,7 +927,7 @@ export const secretSyncQueueFactory = ({ secretPath: folder?.path, environment: environment?.name, projectName: project.name, - syncUrl: `${appCfg.SITE_URL}/projects/secret-management/${projectId}/integrations/secret-syncs/${destination}/${secretSync.id}` + syncUrl: `${appCfg.SITE_URL}${syncPath}` } }); }; diff --git a/frontend/src/layouts/OrganizationLayout/components/NavBar/Notification.tsx b/frontend/src/layouts/OrganizationLayout/components/NavBar/Notification.tsx index 59e6861fc..29fd25415 100644 --- a/frontend/src/layouts/OrganizationLayout/components/NavBar/Notification.tsx +++ b/frontend/src/layouts/OrganizationLayout/components/NavBar/Notification.tsx @@ -26,7 +26,11 @@ export const Notification = ({ notification, onDelete }: Props) => { {!notification.isRead && ( )} - {notification.title}} delayDuration={300}> + {notification.title}} + delayDuration={300} + className="z-[1000]" + > {notification.title} diff --git a/frontend/src/layouts/OrganizationLayout/components/NavBar/NotificationDropdown.tsx b/frontend/src/layouts/OrganizationLayout/components/NavBar/NotificationDropdown.tsx index 6b6381ac1..69a56d5a8 100644 --- a/frontend/src/layouts/OrganizationLayout/components/NavBar/NotificationDropdown.tsx +++ b/frontend/src/layouts/OrganizationLayout/components/NavBar/NotificationDropdown.tsx @@ -46,7 +46,7 @@ export const NotificationDropdown = () => {