Speed-up senderKey membership check
This commit is contained in:
parent
aecb11247f
commit
65f0f87bad
1 changed files with 11 additions and 9 deletions
|
@ -317,10 +317,12 @@ export async function sendToGroupViaSenderKey(options: {
|
|||
createdAtDate,
|
||||
} = attributes.senderKeyInfo;
|
||||
|
||||
const memberSet = new Set(conversation.getMembers());
|
||||
|
||||
// 4. Partition devices into sender key and non-sender key groups
|
||||
const [devicesForSenderKey, devicesForNormalSend] = partition(
|
||||
currentDevices,
|
||||
device => isValidSenderKeyRecipient(conversation, device.identifier)
|
||||
device => isValidSenderKeyRecipient(memberSet, device.identifier)
|
||||
);
|
||||
|
||||
const senderKeyRecipients = getUuidsFromDevices(devicesForSenderKey);
|
||||
|
@ -864,16 +866,9 @@ async function encryptForSenderKey({
|
|||
}
|
||||
|
||||
function isValidSenderKeyRecipient(
|
||||
conversation: ConversationModel,
|
||||
members: Set<ConversationModel>,
|
||||
uuid: string
|
||||
): boolean {
|
||||
if (!conversation.hasMember(uuid)) {
|
||||
window.log.info(
|
||||
`isValidSenderKeyRecipient: Sending to ${uuid}, not a group member`
|
||||
);
|
||||
return false;
|
||||
}
|
||||
|
||||
const memberConversation = window.ConversationController.get(uuid);
|
||||
if (!memberConversation) {
|
||||
window.log.warn(
|
||||
|
@ -882,6 +877,13 @@ function isValidSenderKeyRecipient(
|
|||
return false;
|
||||
}
|
||||
|
||||
if (!members.has(memberConversation)) {
|
||||
window.log.info(
|
||||
`isValidSenderKeyRecipient: Sending to ${uuid}, not a group member`
|
||||
);
|
||||
return false;
|
||||
}
|
||||
|
||||
const capabilities = memberConversation.get('capabilities');
|
||||
if (!capabilities?.senderKey) {
|
||||
return false;
|
||||
|
|
Loading…
Add table
Reference in a new issue