diff --git a/keyserver/src/push/send.js b/keyserver/src/push/send.js --- a/keyserver/src/push/send.js +++ b/keyserver/src/push/send.js @@ -922,15 +922,20 @@ platformDetails: { codeVersion }, dbID, } = convertedData; + const canDecryptNonCollapsibleTextNotifs = codeVersion && codeVersion > 228; - const isTextNotification = newRawMessageInfos.every( - newRawMessageInfo => newRawMessageInfo.type === messageTypes.TEXT, - ); + const isNonCollapsibleTextNotif = + newRawMessageInfos.every( + newRawMessageInfo => newRawMessageInfo.type === messageTypes.TEXT, + ) && !collapseKey; + + const canDecryptAllNotifTypes = + codeVersion && codeVersion >= NEXT_CODE_VERSION; const shouldBeEncrypted = - isTextNotification && !collapseKey && codeVersion && codeVersion > 228; + canDecryptAllNotifTypes || + (canDecryptNonCollapsibleTextNotifs && isNonCollapsibleTextNotif); - const notifID = collapseKey ? collapseKey : dbID; const { merged, ...rest } = notifTexts; const notification = { data: { @@ -940,6 +945,19 @@ }, }; + let notifID; + if (collapseKey && canDecryptAllNotifTypes) { + notifID = dbID; + notification.data = { + ...notification.data, + collapseKey, + }; + } else if (collapseKey) { + notifID = collapseKey; + } else { + notifID = dbID; + } + // The reason we only include `badgeOnly` for newer clients is because older // clients don't know how to parse it. The reason we only include `id` for // newer clients is that if the older clients see that field, they assume diff --git a/keyserver/src/push/types.js b/keyserver/src/push/types.js --- a/keyserver/src/push/types.js +++ b/keyserver/src/push/types.js @@ -14,6 +14,7 @@ +title?: string, +prefix?: string, +threadID?: string, + +collapseKey?: string, +encryptionFailed?: '1', };