Split ACI contact when it is unregistered

This commit is contained in:
Fedor Indutny 2023-02-01 13:32:46 -08:00 committed by GitHub
parent a5a6b74f98
commit 63d6b14516
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 317 additions and 81 deletions

View file

@ -795,8 +795,8 @@ export class ConversationModel extends window.Backbone
shouldSave?: boolean;
} = {}): void {
log.info(
`Conversation ${this.idForLogging()} is now unregistered, ` +
`timestamp=${timestamp}`
`setUnregistered(${this.idForLogging()}): conversation is now ` +
`unregistered, timestamp=${timestamp}`
);
const oldFirstUnregisteredAt = this.get('firstUnregisteredAt');
@ -821,6 +821,26 @@ export class ConversationModel extends window.Backbone
window.Signal.Data.updateConversation(this.attributes);
}
const e164 = this.get('e164');
const pni = this.get('pni');
const aci = this.get('uuid');
if (e164 && pni && aci && pni !== aci) {
this.updateE164(undefined);
this.updatePni(undefined);
const { conversation: split } =
window.ConversationController.maybeMergeContacts({
pni,
e164,
reason: `ConversationModel.setUnregistered(${aci})`,
});
log.info(
`setUnregistered(${this.idForLogging()}): splitting pni ${pni} and ` +
`e164 ${e164} into a separate conversation ${split.idForLogging()}`
);
}
if (
!fromStorageService &&
oldFirstUnregisteredAt !== this.get('firstUnregisteredAt')