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';
|
2023-08-10 16:43:33 +00:00
|
|
|
import type { ServiceIdString } from '../../types/ServiceId';
|
2022-05-31 19:46:56 +00:00
|
|
|
|
2023-08-10 16:43:33 +00:00
|
|
|
export function getUntrustedConversationServiceIds(
|
2022-05-31 19:46:56 +00:00
|
|
|
recipients: ReadonlyArray<string>
|
2023-08-10 16:43:33 +00:00
|
|
|
): Array<ServiceIdString> {
|
2022-05-31 19:46:56 +00:00
|
|
|
return recipients
|
|
|
|
.map(recipient => {
|
|
|
|
const recipientConversation = window.ConversationController.getOrCreate(
|
|
|
|
recipient,
|
|
|
|
'private'
|
|
|
|
);
|
|
|
|
|
|
|
|
if (!recipientConversation.isUntrusted()) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2023-08-10 16:43:33 +00:00
|
|
|
const serviceId = recipientConversation.getServiceId();
|
|
|
|
if (!serviceId) {
|
2022-05-31 19:46:56 +00:00
|
|
|
log.warn(
|
2023-08-10 16:43:33 +00:00
|
|
|
`getUntrustedConversationServiceIds: Conversation ${recipientConversation.idForLogging()} had no serviceId`
|
2022-05-31 19:46:56 +00:00
|
|
|
);
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2023-08-10 16:43:33 +00:00
|
|
|
return serviceId;
|
2022-05-31 19:46:56 +00:00
|
|
|
})
|
|
|
|
.filter(isNotNil);
|
|
|
|
}
|