Fix group updates for blocked users
This commit is contained in:
parent
47c9598283
commit
581594ae9a
2 changed files with 39 additions and 39 deletions
68
ts/groups.ts
68
ts/groups.ts
|
@ -3133,38 +3133,6 @@ async function updateGroup(
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (changeMessagesToSave.length > 0) {
|
|
||||||
try {
|
|
||||||
if (contactsWithoutProfileKey && contactsWithoutProfileKey.length > 0) {
|
|
||||||
await Promise.race([profileFetches, sleep(30 * SECOND)]);
|
|
||||||
log.info(
|
|
||||||
`updateGroup/${logId}: timed out or finished fetching ${contactsWithoutProfileKey.length} profiles`
|
|
||||||
);
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
log.error(
|
|
||||||
`updateGroup/${logId}: failed to fetch missing profiles`,
|
|
||||||
Errors.toLogFormat(error)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
await appendChangeMessages(conversation, changeMessagesToSave);
|
|
||||||
}
|
|
||||||
|
|
||||||
// We update group membership last to ensure that all notifications are in place before
|
|
||||||
// the group updates happen on the model.
|
|
||||||
|
|
||||||
conversation.set({
|
|
||||||
...newAttributes,
|
|
||||||
active_at: activeAt,
|
|
||||||
});
|
|
||||||
|
|
||||||
if (idChanged) {
|
|
||||||
conversation.trigger('idUpdated', conversation, 'groupId', previousId);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Save these most recent updates to conversation
|
|
||||||
await updateConversation(conversation.attributes);
|
|
||||||
|
|
||||||
// If we've been added by a blocked contact, then schedule a task to leave group
|
// If we've been added by a blocked contact, then schedule a task to leave group
|
||||||
const justAdded = !wasMemberOrPending && isMemberOrPending;
|
const justAdded = !wasMemberOrPending && isMemberOrPending;
|
||||||
const addedBy =
|
const addedBy =
|
||||||
|
@ -3193,9 +3161,43 @@ async function updateGroup(
|
||||||
};
|
};
|
||||||
|
|
||||||
// Cannot await here, would infinitely block queue
|
// Cannot await here, would infinitely block queue
|
||||||
void waitThenLeave();
|
drop(waitThenLeave());
|
||||||
|
|
||||||
|
// Return early to discard group changes resulting from the blocked user's action.
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// We update group membership last to ensure that all notifications are in place before
|
||||||
|
// the group updates happen on the model.
|
||||||
|
if (changeMessagesToSave.length > 0) {
|
||||||
|
try {
|
||||||
|
if (contactsWithoutProfileKey && contactsWithoutProfileKey.length > 0) {
|
||||||
|
await Promise.race([profileFetches, sleep(30 * SECOND)]);
|
||||||
|
log.info(
|
||||||
|
`updateGroup/${logId}: timed out or finished fetching ${contactsWithoutProfileKey.length} profiles`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
log.error(
|
||||||
|
`updateGroup/${logId}: failed to fetch missing profiles`,
|
||||||
|
Errors.toLogFormat(error)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
await appendChangeMessages(conversation, changeMessagesToSave);
|
||||||
|
}
|
||||||
|
|
||||||
|
conversation.set({
|
||||||
|
...newAttributes,
|
||||||
|
active_at: activeAt,
|
||||||
|
});
|
||||||
|
|
||||||
|
if (idChanged) {
|
||||||
|
conversation.trigger('idUpdated', conversation, 'groupId', previousId);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Save these most recent updates to conversation
|
||||||
|
await updateConversation(conversation.attributes);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Exported for testing
|
// Exported for testing
|
||||||
|
|
|
@ -1602,14 +1602,12 @@ export default class MessageReceiver
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// We want to process GroupV2 updates, even from blocked users. We'll drop them later.
|
|
||||||
if (
|
if (
|
||||||
!isGroupV2 &&
|
(envelope.source && this.isBlocked(envelope.source)) ||
|
||||||
((envelope.source && this.isBlocked(envelope.source)) ||
|
(envelope.sourceServiceId &&
|
||||||
(envelope.sourceServiceId &&
|
this.isServiceIdBlocked(envelope.sourceServiceId))
|
||||||
this.isServiceIdBlocked(envelope.sourceServiceId)))
|
|
||||||
) {
|
) {
|
||||||
log.info(`${logId}: Dropping non-GV2 message from blocked sender`);
|
log.info(`${logId}: Dropping message from blocked sender`);
|
||||||
this.removeFromCache(envelope);
|
this.removeFromCache(envelope);
|
||||||
return { plaintext: undefined, envelope };
|
return { plaintext: undefined, envelope };
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue