Group name spoofing warning

This commit is contained in:
Evan Hahn 2021-06-01 18:30:25 -05:00 committed by GitHub
parent 51b45ab275
commit 36c15fead4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
20 changed files with 1312 additions and 215 deletions

View file

@ -0,0 +1,22 @@
// Copyright 2021 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
import { ConversationType } from '../state/ducks/conversations';
import { missingCaseError } from './missingCaseError';
export function isConversationNameKnown(
conversation: Readonly<
Pick<ConversationType, 'e164' | 'name' | 'profileName' | 'type'>
>
): boolean {
switch (conversation.type) {
case 'direct':
return Boolean(
conversation.name || conversation.profileName || conversation.e164
);
case 'group':
return Boolean(conversation.name);
default:
throw missingCaseError(conversation.type);
}
}