Ensure consistent member filtering in sendToGroup

This commit is contained in:
Fedor Indutny 2023-01-20 11:42:55 -08:00 committed by GitHub
parent fe2007195b
commit 99c95794af
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 39 additions and 7 deletions

View file

@ -277,6 +277,12 @@ function getRecipients(
if (!recipient) { if (!recipient) {
return null; return null;
} }
if (recipient.isUnregistered()) {
return null;
}
if (recipient.isBlocked()) {
return null;
}
return recipient.get('uuid'); return recipient.get('uuid');
}) })
.filter(isNotNil); .filter(isNotNil);

View file

@ -35,23 +35,44 @@ export async function sendGroupUpdate(
}: ConversationQueueJobBundle, }: ConversationQueueJobBundle,
data: GroupUpdateJobData data: GroupUpdateJobData
): Promise<void> { ): Promise<void> {
const logId = `sendGroupUpdate/${conversation.idForLogging()}`;
if (!shouldContinue) { if (!shouldContinue) {
log.info('Ran out of time. Giving up on sending group update'); log.info(`${logId}: Ran out of time. Giving up on sending group update`);
return; return;
} }
if (!isGroupV2(conversation.attributes)) { if (!isGroupV2(conversation.attributes)) {
log.error( log.error(
`Conversation ${conversation.idForLogging()} is not GroupV2, cannot send group update!` `${logId}: Conversation is not GroupV2, cannot send group update!`
); );
return; return;
} }
log.info( log.info(`${logId}: starting with timestamp ${timestamp}`);
`Starting group update for ${conversation.idForLogging()} with timestamp ${timestamp}`
);
const { groupChangeBase64, recipients, revision } = data; const { groupChangeBase64, recipients: jobRecipients, revision } = data;
const recipients = jobRecipients.filter(id => {
const recipient = window.ConversationController.get(id);
if (!recipient) {
return false;
}
if (recipient.isUnregistered()) {
log.warn(
`${logId}: dropping unregistered recipient ${recipient.idForLogging()}`
);
return false;
}
if (recipient.isBlocked()) {
log.warn(
`${logId}: dropping blocked recipient ${recipient.idForLogging()}`
);
return false;
}
return true;
});
const untrustedUuids = getUntrustedConversationUuids(recipients); const untrustedUuids = getUntrustedConversationUuids(recipients);
if (untrustedUuids.length) { if (untrustedUuids.length) {
@ -69,7 +90,6 @@ export async function sendGroupUpdate(
const { ContentHint } = Proto.UnidentifiedSenderMessage.Message; const { ContentHint } = Proto.UnidentifiedSenderMessage.Message;
const contentHint = ContentHint.RESENDABLE; const contentHint = ContentHint.RESENDABLE;
const sendType = 'groupChange'; const sendType = 'groupChange';
const logId = `sendGroupUpdate/${conversation.idForLogging()}`;
const groupChange = groupChangeBase64 const groupChange = groupChangeBase64
? Bytes.fromBase64(groupChangeBase64) ? Bytes.fromBase64(groupChangeBase64)

View file

@ -430,6 +430,9 @@ function getMessageRecipients({
if (recipient.isUnregistered()) { if (recipient.isUnregistered()) {
return; return;
} }
if (recipient.isBlocked()) {
return;
}
const recipientIdentifier = recipient.getSendTarget(); const recipientIdentifier = recipient.getSendTarget();
if (!recipientIdentifier) { if (!recipientIdentifier) {

View file

@ -416,6 +416,9 @@ function getRecipients(
if (recipient.isUnregistered()) { if (recipient.isUnregistered()) {
continue; continue;
} }
if (recipient.isBlocked()) {
continue;
}
allRecipientIdentifiers.push(recipientIdentifier); allRecipientIdentifiers.push(recipientIdentifier);
if (!isRecipientMe) { if (!isRecipientMe) {