diff --git a/keyserver/src/fetchers/message-fetchers.js b/keyserver/src/fetchers/message-fetchers.js --- a/keyserver/src/fetchers/message-fetchers.js +++ b/keyserver/src/fetchers/message-fetchers.js @@ -7,7 +7,7 @@ shimUnsupportedRawMessageInfos, } from 'lib/shared/message-utils.js'; import { messageSpecs } from 'lib/shared/messages/message-specs.js'; -import { notifCollapseKeyForRawMessageInfo } from 'lib/shared/notif-utils.js'; +import { getNotifCollapseKey } from 'lib/shared/notif-utils.js'; import { hasMinCodeVersion } from 'lib/shared/version-utils.js'; import { type RawMessageInfo, @@ -66,8 +66,10 @@ for (const userID in pushInfo) { usersToCollapseKeysToInfo[userID] = {}; usersToCollapsableNotifInfo[userID] = []; - for (const rawMessageInfo of pushInfo[userID].messageInfos) { - const collapseKey = notifCollapseKeyForRawMessageInfo(rawMessageInfo); + for (let i = 0; i < pushInfo[userID].messageInfos.length; i++) { + const rawMessageInfo = pushInfo[userID].messageInfos[i]; + const messageData = pushInfo[userID].messageDatas[i]; + const collapseKey = getNotifCollapseKey(rawMessageInfo, messageData); if (!collapseKey) { const collapsableNotifInfo = { collapseKey, 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 @@ -100,7 +100,10 @@ threadInfo: ThreadInfo, params: NotificationTextsParams, ) => Promise, - +notificationCollapseKey?: (rawMessageInfo: RawInfo) => string, + +notificationCollapseKey?: ( + rawMessageInfo: RawInfo, + messageData: Data, + ) => string, +generatesNotifs: ( rawMessageInfo: RawInfo, messageData: Data, diff --git a/lib/shared/notif-utils.js b/lib/shared/notif-utils.js --- a/lib/shared/notif-utils.js +++ b/lib/shared/notif-utils.js @@ -10,6 +10,7 @@ type RawMessageInfo, type RobotextMessageInfo, type MessageType, + type MessageData, messageTypes, } from '../types/message-types.js'; import type { NotifTexts, ResolvedNotifTexts } from '../types/notif-types.js'; @@ -219,11 +220,14 @@ }); } -function notifCollapseKeyForRawMessageInfo( +function getNotifCollapseKey( rawMessageInfo: RawMessageInfo, + messageData: MessageData, ): ?string { const messageSpec = messageSpecs[rawMessageInfo.type]; - return messageSpec.notificationCollapseKey?.(rawMessageInfo) ?? null; + return ( + messageSpec.notificationCollapseKey?.(rawMessageInfo, messageData) ?? null + ); } type Unmerged = $ReadOnly<{ @@ -247,6 +251,6 @@ notifTextsForMessageInfo, notifTextsForEntryCreationOrEdit, notifTextsForSubthreadCreation, - notifCollapseKeyForRawMessageInfo, + getNotifCollapseKey, mergePrefixIntoBody, };