Send and receive PniSignatureMessage
This commit is contained in:
parent
95be24e8f7
commit
00cfd92dd0
43 changed files with 1082 additions and 164 deletions
|
@ -1,7 +1,12 @@
|
|||
// Copyright 2021 Signal Messenger, LLC
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
import type { ConversationAttributesType } from '../model-types.d';
|
||||
|
||||
import { makeEnumParser } from './enum';
|
||||
import { isInSystemContacts } from './isInSystemContacts';
|
||||
import { missingCaseError } from './missingCaseError';
|
||||
import { isDirectConversation, isMe } from './whatTypeOfConversation';
|
||||
|
||||
// These strings are saved to disk, so be careful when changing them.
|
||||
export enum PhoneNumberSharingMode {
|
||||
|
@ -14,3 +19,26 @@ export const parsePhoneNumberSharingMode = makeEnumParser(
|
|||
PhoneNumberSharingMode,
|
||||
PhoneNumberSharingMode.Everybody
|
||||
);
|
||||
|
||||
export const shouldSharePhoneNumberWith = (
|
||||
conversation: ConversationAttributesType
|
||||
): boolean => {
|
||||
if (!isDirectConversation(conversation) || isMe(conversation)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const phoneNumberSharingMode = parsePhoneNumberSharingMode(
|
||||
window.storage.get('phoneNumberSharingMode')
|
||||
);
|
||||
|
||||
switch (phoneNumberSharingMode) {
|
||||
case PhoneNumberSharingMode.Everybody:
|
||||
return true;
|
||||
case PhoneNumberSharingMode.ContactsOnly:
|
||||
return isInSystemContacts(conversation);
|
||||
case PhoneNumberSharingMode.Nobody:
|
||||
return false;
|
||||
default:
|
||||
throw missingCaseError(phoneNumberSharingMode);
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue