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

26
ts/util/getE164.ts Normal file
View file

@ -0,0 +1,26 @@
// Copyright 2023 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
import type { ConversationAttributesType } from '../model-types.d';
import type { ConversationType } from '../state/ducks/conversations';
import { isInSystemContacts } from './isInSystemContacts';
export function getE164(
attributes: Pick<
ConversationAttributesType | ConversationType,
| 'type'
| 'name'
| 'systemGivenName'
| 'systemFamilyName'
| 'e164'
| 'notSharingPhoneNumber'
>
): string | undefined {
const { e164, notSharingPhoneNumber = false } = attributes;
if (notSharingPhoneNumber && !isInSystemContacts(attributes)) {
return undefined;
}
return e164;
}