mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-25 06:18:45 +08:00
feat(server): send invitation review notification (#10418)
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user