2022-05-31 19:46:56 +00:00
|
|
|
// Copyright 2022 Signal Messenger, LLC
|
|
|
|
// SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
|
|
|
import { isNotNil } from '../../util/isNotNil';
|
|
|
|
import * as log from '../../logging/log';
|
2022-11-11 04:10:30 +00:00
|
|
|
import type { UUIDStringType } from '../../types/UUID';
|
2022-05-31 19:46:56 +00:00
|
|
|
|
|
|
|
export function getUntrustedConversationUuids(
|
|
|
|
recipients: ReadonlyArray<string>
|
2022-11-11 04:10:30 +00:00
|
|
|
): Array<UUIDStringType> {
|
2022-05-31 19:46:56 +00:00
|
|
|
return recipients
|
|
|
|
.map(recipient => {
|
|
|
|
const recipientConversation = window.ConversationController.getOrCreate(
|
|
|
|
recipient,
|
|
|
|
'private'
|
|
|
|
);
|
|
|
|
|
|
|
|
if (!recipientConversation.isUntrusted()) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
const uuid = recipientConversation.get('uuid');
|
|
|
|
if (!uuid) {
|
|
|
|
log.warn(
|
|
|
|
`getUntrustedConversationUuids: Conversation ${recipientConversation.idForLogging()} had no UUID`
|
|
|
|
);
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
return uuid;
|
|
|
|
})
|
|
|
|
.filter(isNotNil);
|
|
|
|
}
|