Sort sender key devices for future optimization

This commit is contained in:
Fedor Indutny 2021-08-17 08:45:57 -07:00 committed by GitHub
parent 75f0cd50be
commit 784e5d5eee
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 14 additions and 3 deletions

View File

@ -841,9 +841,20 @@ async function encryptForSenderKey({
groupIdBuffer
);
const recipients = devices.map(device =>
ProtocolAddress.new(device.identifier, device.id)
);
const recipients = devices
.slice()
.sort((a, b): number => {
if (a.identifier === b.identifier) {
return 0;
}
if (a.identifier < b.identifier) {
return -1;
}
return 1;
})
.map(device => ProtocolAddress.new(device.identifier, device.id));
const identityKeyStore = new IdentityKeys();
const sessionStore = new Sessions();
return sealedSenderMultiRecipientEncrypt(