diff --git a/keyserver/src/creators/message-creator.js b/keyserver/src/creators/message-creator.js --- a/keyserver/src/creators/message-creator.js +++ b/keyserver/src/creators/message-creator.js @@ -27,7 +27,10 @@ appendSQLArray, mergeOrConditions, } from '../database/database'; -import { fetchMessageInfoForLocalID } from '../fetchers/message-fetchers'; +import { + fetchMessageInfoForLocalID, + fetchMessageInfoByID, +} from '../fetchers/message-fetchers'; import { fetchOtherSessionsForViewer } from '../fetchers/session-fetchers'; import { fetchServerThreadInfos } from '../fetchers/thread-fetchers'; import { sendPushNotifs } from '../push/send'; @@ -388,7 +391,10 @@ } const { generatesNotifs } = messageSpecs[type]; const doesGenerateNotif = await generatesNotifs(messageInfo, { + notifTargetUserID: userID, userNotMemberOfSubthreads, + fetchMessageInfoByID: (messageID: string) => + fetchMessageInfoByID(viewer, messageID), }); return doesGenerateNotif ? messageInfo : undefined; }), diff --git a/lib/shared/messages/message-spec.js b/lib/shared/messages/message-spec.js --- a/lib/shared/messages/message-spec.js +++ b/lib/shared/messages/message-spec.js @@ -68,7 +68,9 @@ }; export type GeneratesNotifsParams = { + +notifTargetUserID: string, +userNotMemberOfSubthreads: Set, + +fetchMessageInfoByID: (messageID: string) => Promise, }; export type MessageSpec = { diff --git a/lib/shared/messages/reaction-message-spec.js b/lib/shared/messages/reaction-message-spec.js --- a/lib/shared/messages/reaction-message-spec.js +++ b/lib/shared/messages/reaction-message-spec.js @@ -26,6 +26,7 @@ MessageSpec, MessageTitleParam, NotificationTextsParams, + GeneratesNotifsParams, } from './message-spec'; import { assertSingleMessageInfo, joinResult } from './utils'; @@ -208,5 +209,14 @@ ); }, - generatesNotifs: async () => true, + generatesNotifs: async ( + rawMessageInfo: RawReactionMessageInfo, + params: GeneratesNotifsParams, + ) => { + const { notifTargetUserID, fetchMessageInfoByID } = params; + const targetMessageInfo = await fetchMessageInfoByID( + rawMessageInfo.targetMessageID, + ); + return targetMessageInfo?.creatorID === notifTargetUserID; + }, });