Disambiguate between types of receipts when stored in the same map
This commit is contained in:
parent
be5ac3a1e0
commit
3c12a0aad0
4 changed files with 15 additions and 1 deletions
|
@ -83,6 +83,7 @@ function remove(receipt: MessageReceiptAttributesType): void {
|
||||||
generateCacheKey({
|
generateCacheKey({
|
||||||
sender: receipt.sourceServiceId,
|
sender: receipt.sourceServiceId,
|
||||||
timestamp: receipt.messageSentAt,
|
timestamp: receipt.messageSentAt,
|
||||||
|
type: receipt.type,
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
receipt.removeFromMessageReceiverCache();
|
receipt.removeFromMessageReceiverCache();
|
||||||
|
@ -351,6 +352,7 @@ export async function onReceipt(
|
||||||
generateCacheKey({
|
generateCacheKey({
|
||||||
sender: receipt.sourceServiceId,
|
sender: receipt.sourceServiceId,
|
||||||
timestamp: receipt.messageSentAt,
|
timestamp: receipt.messageSentAt,
|
||||||
|
type: receipt.type,
|
||||||
}),
|
}),
|
||||||
receipt
|
receipt
|
||||||
);
|
);
|
||||||
|
|
|
@ -33,6 +33,7 @@ function remove(sync: ReadSyncAttributesType): void {
|
||||||
generateCacheKey({
|
generateCacheKey({
|
||||||
sender: sync.senderId,
|
sender: sync.senderId,
|
||||||
timestamp: sync.timestamp,
|
timestamp: sync.timestamp,
|
||||||
|
type: 'readsync',
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
sync.removeFromMessageReceiverCache();
|
sync.removeFromMessageReceiverCache();
|
||||||
|
@ -109,6 +110,7 @@ export async function onSync(sync: ReadSyncAttributesType): Promise<void> {
|
||||||
generateCacheKey({
|
generateCacheKey({
|
||||||
sender: sync.senderId,
|
sender: sync.senderId,
|
||||||
timestamp: sync.timestamp,
|
timestamp: sync.timestamp,
|
||||||
|
type: 'readsync',
|
||||||
}),
|
}),
|
||||||
sync
|
sync
|
||||||
);
|
);
|
||||||
|
|
|
@ -34,6 +34,7 @@ function remove(sync: ViewSyncAttributesType): void {
|
||||||
generateCacheKey({
|
generateCacheKey({
|
||||||
sender: sync.senderId,
|
sender: sync.senderId,
|
||||||
timestamp: sync.timestamp,
|
timestamp: sync.timestamp,
|
||||||
|
type: 'viewsync',
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
sync.removeFromMessageReceiverCache();
|
sync.removeFromMessageReceiverCache();
|
||||||
|
@ -78,6 +79,7 @@ export async function onSync(sync: ViewSyncAttributesType): Promise<void> {
|
||||||
generateCacheKey({
|
generateCacheKey({
|
||||||
sender: sync.senderId,
|
sender: sync.senderId,
|
||||||
timestamp: sync.timestamp,
|
timestamp: sync.timestamp,
|
||||||
|
type: 'viewsync',
|
||||||
}),
|
}),
|
||||||
sync
|
sync
|
||||||
);
|
);
|
||||||
|
|
|
@ -1,16 +1,24 @@
|
||||||
// Copyright 2016 Signal Messenger, LLC
|
// Copyright 2016 Signal Messenger, LLC
|
||||||
// SPDX-License-Identifier: AGPL-3.0-only
|
// 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
|
// This function is necessary because the only thing we can guarantee will be unique is
|
||||||
// three pieces of data: sender, deviceId, and timestamp.
|
// three pieces of data: sender, deviceId, and timestamp.
|
||||||
// Because we don't care which device interacted with our message, we collapse this down
|
// Because we don't care which device interacted with our message, we collapse this down
|
||||||
// to: sender + timestamp.
|
// 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({
|
export function generateCacheKey({
|
||||||
sender,
|
sender,
|
||||||
timestamp,
|
timestamp,
|
||||||
|
type,
|
||||||
}: {
|
}: {
|
||||||
sender: string;
|
sender: string;
|
||||||
timestamp: number;
|
timestamp: number;
|
||||||
|
type: ModifierType;
|
||||||
}): string {
|
}): string {
|
||||||
return `cacheKey-${sender}-${timestamp}`;
|
return `cacheKey-${sender}-${timestamp}-${type}`;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue