fix: Email notifications not sent when mention added to edited comment (#5145
* WIP: Need new email template * New emails
This commit is contained in:
@@ -6,8 +6,8 @@ import { Minute } from "@shared/utils/time";
|
||||
import subscriptionCreator from "@server/commands/subscriptionCreator";
|
||||
import { sequelize } from "@server/database/sequelize";
|
||||
import CollectionCreatedEmail from "@server/emails/templates/CollectionCreatedEmail";
|
||||
import DocumentNotificationEmail from "@server/emails/templates/DocumentNotificationEmail";
|
||||
import MentionNotificationEmail from "@server/emails/templates/MentionNotificationEmail";
|
||||
import DocumentMentionedEmail from "@server/emails/templates/DocumentMentionedEmail";
|
||||
import DocumentPublishedOrUpdatedEmail from "@server/emails/templates/DocumentPublishedOrUpdatedEmail";
|
||||
import env from "@server/env";
|
||||
import Logger from "@server/logging/Logger";
|
||||
import {
|
||||
@@ -29,6 +29,7 @@ import {
|
||||
CommentEvent,
|
||||
} from "@server/types";
|
||||
import CommentCreatedNotificationTask from "../tasks/CommentCreatedNotificationTask";
|
||||
import CommentUpdatedNotificationTask from "../tasks/CommentUpdatedNotificationTask";
|
||||
import BaseProcessor from "./BaseProcessor";
|
||||
|
||||
export default class NotificationsProcessor extends BaseProcessor {
|
||||
@@ -37,6 +38,7 @@ export default class NotificationsProcessor extends BaseProcessor {
|
||||
"revisions.create",
|
||||
"collections.create",
|
||||
"comments.create",
|
||||
"comments.update",
|
||||
];
|
||||
|
||||
async perform(event: Event) {
|
||||
@@ -49,6 +51,8 @@ export default class NotificationsProcessor extends BaseProcessor {
|
||||
return this.collectionCreated(event);
|
||||
case "comments.create":
|
||||
return this.commentCreated(event);
|
||||
case "comments.update":
|
||||
return this.commentUpdated(event);
|
||||
default:
|
||||
}
|
||||
}
|
||||
@@ -59,6 +63,12 @@ export default class NotificationsProcessor extends BaseProcessor {
|
||||
});
|
||||
}
|
||||
|
||||
async commentUpdated(event: CommentEvent) {
|
||||
await CommentUpdatedNotificationTask.schedule(event, {
|
||||
delay: Minute,
|
||||
});
|
||||
}
|
||||
|
||||
async documentPublished(event: DocumentEvent) {
|
||||
// never send notifications when batch importing documents
|
||||
if (
|
||||
@@ -104,7 +114,7 @@ export default class NotificationsProcessor extends BaseProcessor {
|
||||
documentId: document.id,
|
||||
});
|
||||
userIdsSentNotifications.push(recipient.id);
|
||||
await new MentionNotificationEmail(
|
||||
await new DocumentMentionedEmail(
|
||||
{
|
||||
to: recipient.email,
|
||||
documentId: event.documentId,
|
||||
@@ -137,7 +147,7 @@ export default class NotificationsProcessor extends BaseProcessor {
|
||||
teamId: team.id,
|
||||
documentId: document.id,
|
||||
});
|
||||
await new DocumentNotificationEmail(
|
||||
await new DocumentPublishedOrUpdatedEmail(
|
||||
{
|
||||
to: recipient.email,
|
||||
userId: recipient.id,
|
||||
@@ -193,7 +203,7 @@ export default class NotificationsProcessor extends BaseProcessor {
|
||||
documentId: document.id,
|
||||
});
|
||||
userIdsSentNotifications.push(recipient.id);
|
||||
await new MentionNotificationEmail(
|
||||
await new DocumentMentionedEmail(
|
||||
{
|
||||
to: recipient.email,
|
||||
documentId: event.documentId,
|
||||
@@ -241,7 +251,7 @@ export default class NotificationsProcessor extends BaseProcessor {
|
||||
documentId: document.id,
|
||||
});
|
||||
|
||||
await new DocumentNotificationEmail(
|
||||
await new DocumentPublishedOrUpdatedEmail(
|
||||
{
|
||||
to: recipient.email,
|
||||
userId: recipient.id,
|
||||
|
||||
Reference in New Issue
Block a user