Skip to content

Commit

Permalink
getUntrustedConversations: Ensure we return conversationIds
Browse files Browse the repository at this point in the history
Co-authored-by: Scott Nonnenberg <scott@signal.org>
  • Loading branch information
automated-signal and scottnonnenberg-signal committed Mar 30, 2022
1 parent 3a0dc63 commit 80ee429
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
20 changes: 13 additions & 7 deletions ts/jobs/helpers/getUntrustedConversationIds.ts
Original file line number Diff line number Diff line change
@@ -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);
}
5 changes: 5 additions & 0 deletions ts/state/selectors/conversations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1022,6 +1022,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);
}
);

0 comments on commit 80ee429

Please sign in to comment.