Add extra logging for change phone number

This commit is contained in:
Fedor Indutny 2022-01-20 14:44:25 -08:00 committed by GitHub
parent bcd9f961ad
commit 8cd557ff91
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 59 additions and 14 deletions

View file

@ -279,7 +279,12 @@ export class ConversationController {
getOurConversationId(): string | undefined {
const e164 = window.textsecure.storage.user.getNumber();
const uuid = window.textsecure.storage.user.getUuid()?.toString();
return this.ensureContactIds({ e164, uuid, highTrust: true });
return this.ensureContactIds({
e164,
uuid,
highTrust: true,
reason: 'getOurConversationId',
});
}
getOurConversationIdOrThrow(): string {
@ -325,11 +330,20 @@ export class ConversationController {
e164,
uuid,
highTrust,
}: {
e164?: string | null;
uuid?: string | null;
highTrust?: boolean;
}): string | undefined {
reason,
}:
| {
e164?: string | null;
uuid?: string | null;
highTrust?: false;
reason?: void;
}
| {
e164?: string | null;
uuid?: string | null;
highTrust: true;
reason: string;
}): string | undefined {
// Check for at least one parameter being provided. This is necessary
// because this path can be called on startup to resolve our own ID before
// our phone number or UUID are known. The existing behavior in these
@ -346,7 +360,10 @@ export class ConversationController {
// 1. Handle no match at all
if (!convoE164 && !convoUuid) {
log.info('ensureContactIds: Creating new contact, no matches found');
log.info(
'ensureContactIds: Creating new contact, no matches found',
highTrust ? reason : 'no reason'
);
const newConvo = this.getOrCreate(identifier, 'private');
if (highTrust && e164) {
newConvo.updateE164(e164);
@ -375,7 +392,10 @@ export class ConversationController {
// Fill in the UUID for an e164-only contact
if (normalizedUuid && !convoE164.get('uuid')) {
if (highTrust) {
log.info('ensureContactIds: Adding UUID to e164-only match');
log.info(
`ensureContactIds: Adding UUID (${uuid}) to e164-only match ` +
`(${e164}), reason: ${reason}`
);
convoE164.updateUuid(normalizedUuid);
updateConversation(convoE164.attributes);
}
@ -389,7 +409,10 @@ export class ConversationController {
const newConvo = this.getOrCreate(normalizedUuid, 'private');
if (highTrust) {
log.info('ensureContactIds: Moving e164 from old contact to new');
log.info(
`ensureContactIds: Moving e164 (${e164}) from old contact ` +
`(${convoE164.get('uuid')}) to new (${uuid}), reason: ${reason}`
);
// Remove the e164 from the old contact...
convoE164.set({ e164: undefined });
@ -406,7 +429,10 @@ export class ConversationController {
}
if (!convoE164 && convoUuid) {
if (e164 && highTrust) {
log.info('ensureContactIds: Adding e164 to UUID-only match');
log.info(
`ensureContactIds: Adding e164 (${e164}) to UUID-only match ` +
`(${uuid}), reason: ${reason}`
);
convoUuid.updateE164(e164);
updateConversation(convoUuid.attributes);
}
@ -429,7 +455,9 @@ export class ConversationController {
// Conflict: If e164 match already has a UUID, we remove its e164.
if (convoE164.get('uuid') && convoE164.get('uuid') !== normalizedUuid) {
log.info(
'ensureContactIds: e164 match had different UUID than incoming pair, removing its e164.'
`ensureContactIds: e164 match (${e164}) had different ` +
`UUID(${convoE164.get('uuid')}) than incoming pair (${uuid}), ` +
`removing its e164, reason: ${reason}`
);
// Remove the e164 from the old contact...