Merge branch 'feat/inda-383-daily-stat' into 'main'
[ProtonMail-WebClient.git] / packages / docs-core / lib / UseCase / GetAdditionalEncryptionData.ts
blobda28155f53fda0f5d7232f68f3128b908ddceaae
1 const AnonymousUser = 'anonymous'
3 export function GetAssociatedEncryptionDataForRealtimeMessage(metadata: {
4   version: number
5   authorAddress: string | undefined
6   timestamp: number
7 }): string {
8   if (metadata.authorAddress) {
9     return `${metadata.version}.${metadata.authorAddress}.${metadata.timestamp}`
10   }
12   return `${metadata.version}.${AnonymousUser}.${metadata.timestamp}`
15 export function GetAssociatedEncryptionDataForComment(metadata: {
16   authorAddress: string | undefined
17   markId: string
18 }): string {
19   if (metadata.authorAddress) {
20     return `${metadata.authorAddress}.${metadata.markId}`
21   }
23   return `${AnonymousUser}.${metadata.markId}`
26 export function isAnonymousComment(aad: string): boolean {
27   const components = aad.split('.')
28   return components[0] === AnonymousUser