Update to libsignal-client@0.9.0, handle new invalid registration error

This commit is contained in:
Scott Nonnenberg 2021-09-02 13:44:34 -07:00 committed by GitHub
parent 9ca9f743c3
commit 5bf3720d1d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 25 additions and 5 deletions

View file

@ -5,6 +5,7 @@ import { differenceWith, omit, partition } from 'lodash';
import PQueue from 'p-queue';
import {
ErrorCode,
groupEncrypt,
ProtocolAddress,
sealedSenderMultiRecipientEncrypt,
@ -513,6 +514,25 @@ export async function sendToGroupViaSenderKey(options: {
recursionCount: recursionCount + 1,
});
}
if (error.code === ErrorCode.InvalidRegistrationId && error.addr) {
const address = error.addr as ProtocolAddress;
const name = address.name();
const brokenAccount = window.ConversationController.get(name);
if (brokenAccount) {
window.log.warn(
`sendToGroupViaSenderKey/${logId}: Disabling sealed sender for ${brokenAccount.idForLogging()}`
);
brokenAccount.set({ sealedSender: SEALED_SENDER.DISABLED });
window.Signal.Data.updateConversation(brokenAccount.attributes);
// Now that we've eliminate this problematic account, we can try the send again.
return sendToGroupViaSenderKey({
...options,
recursionCount: recursionCount + 1,
});
}
}
throw new Error(
`sendToGroupViaSenderKey/${logId}: Returned unexpected error ${