Unlink on PNI identity key mismatch
This commit is contained in:
parent
ef0a3de636
commit
58aec8b1a3
3 changed files with 191 additions and 0 deletions
|
@ -139,6 +139,7 @@ import { inspectUnknownFieldTags } from '../util/inspectProtobufs';
|
|||
import { incrementMessageCounter } from '../util/incrementMessageCounter';
|
||||
import { filterAndClean } from '../types/BodyRange';
|
||||
import { getCallEventForProto } from '../util/callDisposition';
|
||||
import { checkOurPniIdentityKey } from '../util/checkOurPniIdentityKey';
|
||||
import { CallLogEvent } from '../types/CallDisposition';
|
||||
|
||||
const GROUPV2_ID_LENGTH = 32;
|
||||
|
@ -298,6 +299,8 @@ export default class MessageReceiver
|
|||
|
||||
private stoppingProcessing?: boolean;
|
||||
|
||||
private pniIdentityKeyCheckRequired?: boolean;
|
||||
|
||||
constructor({ server, storage, serverTrustRoot }: MessageReceiverOptions) {
|
||||
super();
|
||||
|
||||
|
@ -739,6 +742,15 @@ export default class MessageReceiver
|
|||
this.cacheRemoveBatcher.flushAndWait(),
|
||||
]);
|
||||
|
||||
if (this.pniIdentityKeyCheckRequired) {
|
||||
log.warn(
|
||||
"MessageReceiver: got 'empty' event, " +
|
||||
'running scheduled pni identity key check'
|
||||
);
|
||||
drop(checkOurPniIdentityKey());
|
||||
}
|
||||
this.pniIdentityKeyCheckRequired = false;
|
||||
|
||||
log.info("MessageReceiver: emitting 'empty' event");
|
||||
this.dispatchEvent(new EmptyEvent());
|
||||
this.isEmptied = true;
|
||||
|
@ -2033,6 +2045,16 @@ export default class MessageReceiver
|
|||
throw error;
|
||||
}
|
||||
|
||||
if (serviceIdKind === ServiceIdKind.PNI) {
|
||||
log.info(
|
||||
'MessageReceiver.decrypt: Error on PNI; no further processing; ' +
|
||||
'queueing pni identity check'
|
||||
);
|
||||
this.pniIdentityKeyCheckRequired = true;
|
||||
this.removeFromCache(envelope);
|
||||
throw error;
|
||||
}
|
||||
|
||||
const { cipherTextBytes, cipherTextType } = envelope;
|
||||
const event = new DecryptionErrorEvent(
|
||||
{
|
||||
|
@ -3319,6 +3341,11 @@ export default class MessageReceiver
|
|||
return;
|
||||
}
|
||||
|
||||
if (this.pniIdentityKeyCheckRequired) {
|
||||
log.warn('MessageReceiver: canceling pni identity key check');
|
||||
}
|
||||
this.pniIdentityKeyCheckRequired = false;
|
||||
|
||||
const manager = window.getAccountManager();
|
||||
await manager.setPni(updatedPni, {
|
||||
identityKeyPair,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue