getUntrustedConversations: Ensure we return conversationIds

This commit is contained in:
Scott Nonnenberg 2022-03-29 17:14:01 -07:00 committed by GitHub
parent 13f4948d4b
commit 42bd8cb4ce
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 7 deletions

View file

@ -1,14 +1,20 @@
// Copyright 2022 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
import { isNotNil } from '../../util/isNotNil';
export function getUntrustedConversationIds(
recipients: ReadonlyArray<string>
): Array<string> {
return recipients.filter(recipient => {
const recipientConversation = window.ConversationController.getOrCreate(
recipient,
'private'
);
return recipientConversation.isUntrusted();
});
return recipients
.map(recipient => {
const recipientConversation = window.ConversationController.getOrCreate(
recipient,
'private'
);
return recipientConversation.isUntrusted()
? recipientConversation.id
: null;
})
.filter(isNotNil);
}

View file

@ -1023,6 +1023,11 @@ export const getConversationsStoppingSend = createSelector(
const conversations = conversationIds
.map(conversationId => conversationSelector(conversationId))
.filter(isNotNil);
if (conversationIds.length !== conversations.length) {
log.warn(
`getConversationsStoppingSend: Started with ${conversationIds.length} items, ended up with ${conversations.length}.`
);
}
return sortByTitle(conversations);
}
);