Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Disambiguate between types of receipts when stored in the same map
- Loading branch information
1 parent
be5ac3a
commit 3c12a0a
Showing
4 changed files
with
15 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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}`; | ||
} |