signal-desktop/ts/util/getE164.ts
2024-02-07 13:38:43 -08:00

27 lines
725 B
TypeScript

// 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'
| 'sharingPhoneNumber'
| 'profileKey'
>
): string | undefined {
const { e164, profileKey, sharingPhoneNumber } = attributes;
if (!sharingPhoneNumber && profileKey && !isInSystemContacts(attributes)) {
return undefined;
}
return e164;
}