feat(notifications): project invite notification

This commit is contained in:
x032205
2025-09-16 02:10:50 -04:00
parent f9ca58c8b9
commit 747248b7a4
3 changed files with 19 additions and 3 deletions
+2 -1
View File
@@ -928,7 +928,8 @@ export const registerRoutes = async (
projectRoleDAL, projectRoleDAL,
groupProjectDAL, groupProjectDAL,
secretReminderRecipientsDAL, secretReminderRecipientsDAL,
licenseService licenseService,
notificationService
}); });
const projectUserAdditionalPrivilegeService = projectUserAdditionalPrivilegeServiceFactory({ const projectUserAdditionalPrivilegeService = projectUserAdditionalPrivilegeServiceFactory({
permissionService, permissionService,
@@ -13,7 +13,8 @@ export enum NotificationType {
IMPORT_SUCCESSFUL = "import-successful", IMPORT_SUCCESSFUL = "import-successful",
IMPORT_FAILED = "import-failed", IMPORT_FAILED = "import-failed",
DIRECT_PROJECT_ACCESS_ISSUED_TO_ADMIN = "direct-project-access-issued-to-admin", DIRECT_PROJECT_ACCESS_ISSUED_TO_ADMIN = "direct-project-access-issued-to-admin",
PROJECT_ACCESS_REQUEST = "project-access-request" PROJECT_ACCESS_REQUEST = "project-access-request",
PROJECT_INVITATION = "project-invitation"
} }
export interface TCreateUserNotificationDTO { export interface TCreateUserNotificationDTO {
@@ -18,6 +18,8 @@ import { ms } from "@app/lib/ms";
import { TUserGroupMembershipDALFactory } from "../../ee/services/group/user-group-membership-dal"; import { TUserGroupMembershipDALFactory } from "../../ee/services/group/user-group-membership-dal";
import { ActorType } from "../auth/auth-type"; import { ActorType } from "../auth/auth-type";
import { TGroupProjectDALFactory } from "../group-project/group-project-dal"; import { TGroupProjectDALFactory } from "../group-project/group-project-dal";
import { TNotificationServiceFactory } from "../notification/notification-service";
import { NotificationType } from "../notification/notification-types";
import { TOrgDALFactory } from "../org/org-dal"; import { TOrgDALFactory } from "../org/org-dal";
import { TProjectDALFactory } from "../project/project-dal"; import { TProjectDALFactory } from "../project/project-dal";
import { TProjectBotDALFactory } from "../project-bot/project-bot-dal"; import { TProjectBotDALFactory } from "../project-bot/project-bot-dal";
@@ -56,6 +58,7 @@ type TProjectMembershipServiceFactoryDep = {
projectUserAdditionalPrivilegeDAL: Pick<TProjectUserAdditionalPrivilegeDALFactory, "delete">; projectUserAdditionalPrivilegeDAL: Pick<TProjectUserAdditionalPrivilegeDALFactory, "delete">;
secretReminderRecipientsDAL: Pick<TSecretReminderRecipientsDALFactory, "delete">; secretReminderRecipientsDAL: Pick<TSecretReminderRecipientsDALFactory, "delete">;
groupProjectDAL: TGroupProjectDALFactory; groupProjectDAL: TGroupProjectDALFactory;
notificationService: Pick<TNotificationServiceFactory, "createUserNotifications">;
}; };
export type TProjectMembershipServiceFactory = ReturnType<typeof projectMembershipServiceFactory>; export type TProjectMembershipServiceFactory = ReturnType<typeof projectMembershipServiceFactory>;
@@ -74,7 +77,8 @@ export const projectMembershipServiceFactory = ({
projectDAL, projectDAL,
projectKeyDAL, projectKeyDAL,
secretReminderRecipientsDAL, secretReminderRecipientsDAL,
licenseService licenseService,
notificationService
}: TProjectMembershipServiceFactoryDep) => { }: TProjectMembershipServiceFactoryDep) => {
const getProjectMemberships = async ({ const getProjectMemberships = async ({
actorId, actorId,
@@ -236,6 +240,16 @@ export const projectMembershipServiceFactory = ({
}); });
if (sendEmails) { if (sendEmails) {
await notificationService.createUserNotifications(
orgMembers.map((member) => ({
userId: member.userId,
orgId: project.orgId,
type: NotificationType.PROJECT_INVITATION,
title: "Project Invitation",
body: `You've been invited to join the project **${project.name}**.`
}))
);
const appCfg = getConfig(); const appCfg = getConfig();
await smtpService.sendMail({ await smtpService.sendMail({
template: SmtpTemplates.WorkspaceInvite, template: SmtpTemplates.WorkspaceInvite,