mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-14 21:27:20 +00:00
chore(server): send comment notification to all repliers (#13063)
close AF-2714 #### PR Dependency Tree * **PR #13063** 👈 This tree was auto-generated by [Charcoal](https://github.com/danerwilliams/charcoal) <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Added the ability to list all replies for a specific comment. * **Bug Fixes** * Improved notification delivery for comment replies, ensuring all relevant users (comment author, document owner, and all repliers) are notified appropriately. * **Tests** * Added and updated tests to verify correct notification behavior and the new reply listing functionality. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
@@ -375,10 +375,7 @@ export class CommentResolver {
|
||||
reply?: Reply
|
||||
) {
|
||||
const mentionUserIds = new Set(mentions);
|
||||
// send comment mention notification to comment author on reply
|
||||
if (reply) {
|
||||
mentionUserIds.add(comment.userId);
|
||||
}
|
||||
const notifyUserIds = new Set<string>();
|
||||
|
||||
// send comment mention notification to mentioned users
|
||||
for (const mentionUserId of mentionUserIds) {
|
||||
@@ -420,26 +417,41 @@ export class CommentResolver {
|
||||
comment.workspaceId,
|
||||
comment.docId
|
||||
);
|
||||
// if the owner is not in the mention user ids, send comment notification to the owner
|
||||
if (
|
||||
owner &&
|
||||
owner.userId !== sender.id &&
|
||||
!mentionUserIds.has(owner.userId)
|
||||
) {
|
||||
await this.queue.add('notification.sendComment', {
|
||||
userId: owner.userId,
|
||||
body: {
|
||||
workspaceId: comment.workspaceId,
|
||||
createdByUserId: sender.id,
|
||||
commentId: comment.id,
|
||||
replyId: reply?.id,
|
||||
doc: {
|
||||
id: comment.docId,
|
||||
title: docTitle,
|
||||
mode: docMode,
|
||||
if (owner) {
|
||||
notifyUserIds.add(owner.userId);
|
||||
}
|
||||
|
||||
// send comment notification to all repliers and comment author
|
||||
if (reply) {
|
||||
notifyUserIds.add(comment.userId);
|
||||
const replies = await this.models.comment.listReplies(
|
||||
comment.workspaceId,
|
||||
comment.docId,
|
||||
comment.id
|
||||
);
|
||||
for (const reply of replies) {
|
||||
notifyUserIds.add(reply.userId);
|
||||
}
|
||||
}
|
||||
|
||||
for (const userId of notifyUserIds) {
|
||||
// skip if the user is the sender or mentioned
|
||||
if (userId !== sender.id && !mentionUserIds.has(userId)) {
|
||||
await this.queue.add('notification.sendComment', {
|
||||
userId,
|
||||
body: {
|
||||
workspaceId: comment.workspaceId,
|
||||
createdByUserId: sender.id,
|
||||
commentId: comment.id,
|
||||
replyId: reply?.id,
|
||||
doc: {
|
||||
id: comment.docId,
|
||||
title: docTitle,
|
||||
mode: docMode,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user