feat(server): send invitation review notification (#10418)

This commit is contained in:
fengmk2
2025-03-24 03:32:24 +00:00
parent dfd633b8b0
commit 28f8639aff
16 changed files with 629 additions and 137 deletions
@@ -78,9 +78,28 @@ export type InvitationNotificationCreate = z.input<
typeof InvitationNotificationCreateSchema
>;
const InvitationReviewDeclinedNotificationBodySchema = z.object({
workspaceId: IdSchema,
createdByUserId: IdSchema,
});
export type InvitationReviewDeclinedNotificationBody = z.infer<
typeof InvitationReviewDeclinedNotificationBodySchema
>;
export const InvitationReviewDeclinedNotificationCreateSchema =
BaseNotificationCreateSchema.extend({
body: InvitationReviewDeclinedNotificationBodySchema,
});
export type InvitationReviewDeclinedNotificationCreate = z.input<
typeof InvitationReviewDeclinedNotificationCreateSchema
>;
export type UnionNotificationBody =
| MentionNotificationBody
| InvitationNotificationBody;
| InvitationNotificationBody
| InvitationReviewDeclinedNotificationBody;
// #endregion
@@ -92,7 +111,13 @@ export type MentionNotification = Notification &
export type InvitationNotification = Notification &
z.infer<typeof InvitationNotificationCreateSchema>;
export type UnionNotification = MentionNotification | InvitationNotification;
export type InvitationReviewDeclinedNotification = Notification &
z.infer<typeof InvitationReviewDeclinedNotificationCreateSchema>;
export type UnionNotification =
| MentionNotification
| InvitationNotification
| InvitationReviewDeclinedNotification;
// #endregion
@@ -135,6 +160,23 @@ export class NotificationModel extends BaseModel {
return row as InvitationNotification;
}
async createInvitationReviewDeclined(
input: InvitationReviewDeclinedNotificationCreate
) {
const data = InvitationReviewDeclinedNotificationCreateSchema.parse(input);
const type = NotificationType.InvitationReviewDeclined;
const row = await this.create({
userId: data.userId,
level: data.level,
type,
body: data.body,
});
this.logger.log(
`Created ${type} notification ${row.id} to user ${data.userId} in workspace ${data.body.workspaceId}`
);
return row as InvitationReviewDeclinedNotification;
}
// #endregion
// #region common
@@ -26,16 +26,6 @@ declare global {
workspaceId: string;
count: number;
};
'workspace.members.reviewRequested': {
inviteId: string;
};
'workspace.members.requestApproved': {
inviteId: string;
};
'workspace.members.requestDeclined': {
userId: string;
workspaceId: string;
};
'workspace.members.removed': {
userId: string;
workspaceId: string;