2023-11-02 13:28:49 +00:00
|
|
|
// Copyright 2016 Signal Messenger, LLC
|
|
|
|
// SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
2023-11-20 21:25:49 +00:00
|
|
|
import type { MessageReceiptType } from './MessageReceipts';
|
|
|
|
|
2023-11-02 13:28:49 +00:00
|
|
|
// 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.
|
2023-11-20 21:25:49 +00:00
|
|
|
// In some cases, modifiers are stored in the same map, so we also add the modifier type
|
|
|
|
|
|
|
|
type ModifierType = MessageReceiptType | 'readsync' | 'viewsync';
|
|
|
|
|
2023-11-02 13:28:49 +00:00
|
|
|
export function generateCacheKey({
|
|
|
|
sender,
|
|
|
|
timestamp,
|
2023-11-20 21:25:49 +00:00
|
|
|
type,
|
2023-11-02 13:28:49 +00:00
|
|
|
}: {
|
|
|
|
sender: string;
|
|
|
|
timestamp: number;
|
2023-11-20 21:25:49 +00:00
|
|
|
type: ModifierType;
|
2023-11-02 13:28:49 +00:00
|
|
|
}): string {
|
2023-11-20 21:25:49 +00:00
|
|
|
return `cacheKey-${sender}-${timestamp}-${type}`;
|
2023-11-02 13:28:49 +00:00
|
|
|
}
|