Support phone number sharing flag on profile

This commit is contained in:
Fedor Indutny 2024-01-02 20:36:49 +01:00 committed by GitHub
parent 23f39a0dc7
commit d71da5c486
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
16 changed files with 155 additions and 33 deletions

View file

@ -12,6 +12,7 @@ import {
} from '../Crypto';
import type { AvatarUpdateType } from '../types/Avatar';
import { deriveProfileKeyCommitment, deriveProfileKeyVersion } from './zkgroup';
import { isSharingPhoneNumberWithEverybody } from './phoneNumberSharingMode';
export async function encryptProfileData(
conversation: ConversationType,
@ -56,6 +57,11 @@ export async function encryptProfileData(
)
: null;
const encryptedPhoneNumberSharing = encryptProfile(
new Uint8Array([isSharingPhoneNumberWithEverybody() ? 1 : 0]),
keyBuffer
);
const encryptedAvatarData = newAvatar
? encryptProfile(newAvatar, keyBuffer)
: undefined;
@ -72,6 +78,7 @@ export async function encryptProfileData(
avatar: Boolean(newAvatar),
sameAvatar,
commitment: deriveProfileKeyCommitment(profileKey, serviceId),
phoneNumberSharing: Bytes.toBase64(encryptedPhoneNumberSharing),
};
return [profileData, encryptedAvatarData];