Skip to content

Commit

Permalink
Merge pull request #4154 from thematters/fix/moment-notice
Browse files Browse the repository at this point in the history
fix(notice): avoid sending two notices to target author
  • Loading branch information
gary02 authored Aug 27, 2024
2 parents eb0e1ce + b0333b4 commit c87d453
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions src/mutations/comment/putComment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -527,16 +527,19 @@ const resolver: GQLMutationResolvers['putComment'] = async (
}

if (isMoment) {
notificationService.trigger({
event: NOTICE_TYPE.moment_new_comment,
actorId: viewer.id,
recipientId: targetAuthor,
entities: [
{ type: 'target', entityTable: 'moment', entity: moment },
{ type: 'comment', entityTable: 'comment', entity: newComment },
],
tag: `put-comment:${newComment.id}`,
})
const isMentioned = !!data.mentionedUserIds?.includes(targetAuthor)
if (!isMentioned) {
notificationService.trigger({
event: NOTICE_TYPE.moment_new_comment,
actorId: viewer.id,
recipientId: targetAuthor,
entities: [
{ type: 'target', entityTable: 'moment', entity: moment },
{ type: 'comment', entityTable: 'comment', entity: newComment },
],
tag: `put-comment:${newComment.id}`,
})
}
}

// article & circle & moment: notify mentioned users
Expand Down

0 comments on commit c87d453

Please sign in to comment.