Add notifications for document and collection access (#6460)
* Add notification for added to document * Add notifications for document and collection access * Add notification delay * fix: Collection notifications not appearing * Add notification settings
This commit is contained in:
@@ -1,9 +1,11 @@
|
||||
import { NotificationEventType } from "@shared/types";
|
||||
import CollectionCreatedEmail from "@server/emails/templates/CollectionCreatedEmail";
|
||||
import CollectionSharedEmail from "@server/emails/templates/CollectionSharedEmail";
|
||||
import CommentCreatedEmail from "@server/emails/templates/CommentCreatedEmail";
|
||||
import CommentMentionedEmail from "@server/emails/templates/CommentMentionedEmail";
|
||||
import DocumentMentionedEmail from "@server/emails/templates/DocumentMentionedEmail";
|
||||
import DocumentPublishedOrUpdatedEmail from "@server/emails/templates/DocumentPublishedOrUpdatedEmail";
|
||||
import DocumentSharedEmail from "@server/emails/templates/DocumentSharedEmail";
|
||||
import { Notification } from "@server/models";
|
||||
import { Event, NotificationEvent } from "@server/types";
|
||||
import BaseProcessor from "./BaseProcessor";
|
||||
@@ -23,6 +25,10 @@ export default class EmailsProcessor extends BaseProcessor {
|
||||
|
||||
const notificationId = notification.id;
|
||||
|
||||
if (notification.user.isSuspended) {
|
||||
return;
|
||||
}
|
||||
|
||||
switch (notification.event) {
|
||||
case NotificationEventType.UpdateDocument:
|
||||
case NotificationEventType.PublishDocument: {
|
||||
@@ -41,6 +47,34 @@ export default class EmailsProcessor extends BaseProcessor {
|
||||
return;
|
||||
}
|
||||
|
||||
case NotificationEventType.AddUserToDocument: {
|
||||
await new DocumentSharedEmail(
|
||||
{
|
||||
to: notification.user.email,
|
||||
userId: notification.userId,
|
||||
documentId: notification.documentId,
|
||||
teamUrl: notification.team.url,
|
||||
actorName: notification.actor.name,
|
||||
},
|
||||
{ notificationId }
|
||||
).schedule();
|
||||
return;
|
||||
}
|
||||
|
||||
case NotificationEventType.AddUserToCollection: {
|
||||
await new CollectionSharedEmail(
|
||||
{
|
||||
to: notification.user.email,
|
||||
userId: notification.userId,
|
||||
collectionId: notification.collectionId,
|
||||
teamUrl: notification.team.url,
|
||||
actorName: notification.actor.name,
|
||||
},
|
||||
{ notificationId }
|
||||
).schedule();
|
||||
return;
|
||||
}
|
||||
|
||||
case NotificationEventType.MentionedInDocument: {
|
||||
await new DocumentMentionedEmail(
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user