Skip to content

Commit

Permalink
Ensure consistent member filtering in sendToGroup
Browse files Browse the repository at this point in the history
  • Loading branch information
indutny-signal committed Jan 20, 2023
1 parent fe20071 commit 99c9579
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 7 deletions.
6 changes: 6 additions & 0 deletions ts/jobs/helpers/sendDeleteForEveryone.ts
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,12 @@ function getRecipients(
if (!recipient) {
return null;
}
if (recipient.isUnregistered()) {
return null;
}
if (recipient.isBlocked()) {
return null;
}
return recipient.get('uuid');
})
.filter(isNotNil);
Expand Down
34 changes: 27 additions & 7 deletions ts/jobs/helpers/sendGroupUpdate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,23 +35,44 @@ export async function sendGroupUpdate(
}: ConversationQueueJobBundle,
data: GroupUpdateJobData
): Promise<void> {
const logId = `sendGroupUpdate/${conversation.idForLogging()}`;

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;
}

if (!isGroupV2(conversation.attributes)) {
log.error(
`Conversation ${conversation.idForLogging()} is not GroupV2, cannot send group update!`
`${logId}: Conversation is not GroupV2, cannot send group update!`
);
return;
}

log.info(
`Starting group update for ${conversation.idForLogging()} with timestamp ${timestamp}`
);
log.info(`${logId}: starting with timestamp ${timestamp}`);

const { groupChangeBase64, recipients: jobRecipients, revision } = data;

const { groupChangeBase64, recipients, 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);
if (untrustedUuids.length) {
Expand All @@ -69,7 +90,6 @@ export async function sendGroupUpdate(
const { ContentHint } = Proto.UnidentifiedSenderMessage.Message;
const contentHint = ContentHint.RESENDABLE;
const sendType = 'groupChange';
const logId = `sendGroupUpdate/${conversation.idForLogging()}`;

const groupChange = groupChangeBase64
? Bytes.fromBase64(groupChangeBase64)
Expand Down
3 changes: 3 additions & 0 deletions ts/jobs/helpers/sendNormalMessage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,9 @@ function getMessageRecipients({
if (recipient.isUnregistered()) {
return;
}
if (recipient.isBlocked()) {
return;
}

const recipientIdentifier = recipient.getSendTarget();
if (!recipientIdentifier) {
Expand Down
3 changes: 3 additions & 0 deletions ts/jobs/helpers/sendReaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,9 @@ function getRecipients(
if (recipient.isUnregistered()) {
continue;
}
if (recipient.isBlocked()) {
continue;
}

allRecipientIdentifiers.push(recipientIdentifier);
if (!isRecipientMe) {
Expand Down

0 comments on commit 99c9579

Please sign in to comment.