diff --git a/ts/messageModifiers/MessageReceipts.ts b/ts/messageModifiers/MessageReceipts.ts index f3ca3fb0857..f495e0d8fa1 100644 --- a/ts/messageModifiers/MessageReceipts.ts +++ b/ts/messageModifiers/MessageReceipts.ts @@ -83,6 +83,7 @@ function remove(receipt: MessageReceiptAttributesType): void { generateCacheKey({ sender: receipt.sourceServiceId, timestamp: receipt.messageSentAt, + type: receipt.type, }) ); receipt.removeFromMessageReceiverCache(); @@ -351,6 +352,7 @@ export async function onReceipt( generateCacheKey({ sender: receipt.sourceServiceId, timestamp: receipt.messageSentAt, + type: receipt.type, }), receipt ); diff --git a/ts/messageModifiers/ReadSyncs.ts b/ts/messageModifiers/ReadSyncs.ts index 39e75411b50..71db8c548cc 100644 --- a/ts/messageModifiers/ReadSyncs.ts +++ b/ts/messageModifiers/ReadSyncs.ts @@ -33,6 +33,7 @@ function remove(sync: ReadSyncAttributesType): void { generateCacheKey({ sender: sync.senderId, timestamp: sync.timestamp, + type: 'readsync', }) ); sync.removeFromMessageReceiverCache(); @@ -109,6 +110,7 @@ export async function onSync(sync: ReadSyncAttributesType): Promise { generateCacheKey({ sender: sync.senderId, timestamp: sync.timestamp, + type: 'readsync', }), sync ); diff --git a/ts/messageModifiers/ViewSyncs.ts b/ts/messageModifiers/ViewSyncs.ts index f1fe53fe0fe..35c9bf1df2c 100644 --- a/ts/messageModifiers/ViewSyncs.ts +++ b/ts/messageModifiers/ViewSyncs.ts @@ -34,6 +34,7 @@ function remove(sync: ViewSyncAttributesType): void { generateCacheKey({ sender: sync.senderId, timestamp: sync.timestamp, + type: 'viewsync', }) ); sync.removeFromMessageReceiverCache(); @@ -78,6 +79,7 @@ export async function onSync(sync: ViewSyncAttributesType): Promise { generateCacheKey({ sender: sync.senderId, timestamp: sync.timestamp, + type: 'viewsync', }), sync ); diff --git a/ts/messageModifiers/generateCacheKey.ts b/ts/messageModifiers/generateCacheKey.ts index 87b0f0e4d18..246732e6bdb 100644 --- a/ts/messageModifiers/generateCacheKey.ts +++ b/ts/messageModifiers/generateCacheKey.ts @@ -1,16 +1,24 @@ // Copyright 2016 Signal Messenger, LLC // SPDX-License-Identifier: AGPL-3.0-only +import type { MessageReceiptType } from './MessageReceipts'; + // This function is necessary because the only thing we can guarantee will be unique is // three pieces of data: sender, deviceId, and timestamp. // Because we don't care which device interacted with our message, we collapse this down // to: sender + timestamp. +// In some cases, modifiers are stored in the same map, so we also add the modifier type + +type ModifierType = MessageReceiptType | 'readsync' | 'viewsync'; + export function generateCacheKey({ sender, timestamp, + type, }: { sender: string; timestamp: number; + type: ModifierType; }): string { - return `cacheKey-${sender}-${timestamp}`; + return `cacheKey-${sender}-${timestamp}-${type}`; }