feat: Add @mention support to comments (#5001)

* Refactor, remove confusing 'packages' language

* Basic notifications when mentioned in comment

* fix: Incorrect trimming of comments

* test
This commit is contained in:
Tom Moor
2023-03-06 22:19:49 -05:00
committed by GitHub
parent 28c4854985
commit d3b099819d
18 changed files with 301 additions and 220 deletions

View File

@@ -27,7 +27,6 @@ import {
DocumentEvent,
CommentEvent,
} from "@server/types";
import parseMentions from "@server/utils/parseMentions";
import CommentCreatedNotificationTask from "../tasks/CommentCreatedNotificationTask";
import BaseProcessor from "./BaseProcessor";
@@ -82,7 +81,7 @@ export default class NotificationsProcessor extends BaseProcessor {
await this.createDocumentSubscriptions(document, event);
// Send notifications to mentioned users first
const mentions = parseMentions(document);
const mentions = DocumentHelper.parseMentions(document);
const userIdsSentNotifications: string[] = [];
for (const mention of mentions) {
@@ -166,8 +165,8 @@ export default class NotificationsProcessor extends BaseProcessor {
// Send notifications to mentioned users first
const prev = await revision.previous();
const oldMentions = prev ? parseMentions(prev) : [];
const newMentions = parseMentions(document);
const oldMentions = prev ? DocumentHelper.parseMentions(prev) : [];
const newMentions = DocumentHelper.parseMentions(document);
const mentions = differenceBy(newMentions, oldMentions, "id");
const userIdsSentNotifications: string[] = [];