Deprecate phone number discovery notification
This commit is contained in:
parent
63509b8965
commit
d7b09b9703
21 changed files with 196 additions and 517 deletions
|
@ -49,8 +49,7 @@ function applyChangeToConversation(
|
|||
conversation: ConversationModel,
|
||||
suggestedChange: Partial<
|
||||
Pick<ConversationAttributesType, 'uuid' | 'e164' | 'pni'>
|
||||
>,
|
||||
disableDiscoveryNotification?: boolean
|
||||
>
|
||||
) {
|
||||
const change = { ...suggestedChange };
|
||||
|
||||
|
@ -84,9 +83,7 @@ function applyChangeToConversation(
|
|||
conversation.updateUuid(change.uuid);
|
||||
}
|
||||
if (hasOwnProperty.call(change, 'e164')) {
|
||||
conversation.updateE164(change.e164, {
|
||||
disableDiscoveryNotification,
|
||||
});
|
||||
conversation.updateE164(change.e164);
|
||||
}
|
||||
if (hasOwnProperty.call(change, 'pni')) {
|
||||
conversation.updatePni(change.pni);
|
||||
|
@ -485,7 +482,6 @@ export class ConversationController {
|
|||
|
||||
const aci = providedAci ? UUID.cast(providedAci) : undefined;
|
||||
const pni = providedPni ? UUID.cast(providedPni) : undefined;
|
||||
let targetConversationWasCreated = false;
|
||||
const mergePromises: Array<Promise<void>> = [];
|
||||
|
||||
if (!aci && !e164 && !pni) {
|
||||
|
@ -524,13 +520,9 @@ export class ConversationController {
|
|||
`${logId}: No match for ${key}, applying to target conversation`
|
||||
);
|
||||
// Note: This line might erase a known e164 or PNI
|
||||
applyChangeToConversation(
|
||||
targetConversation,
|
||||
{
|
||||
[key]: value,
|
||||
},
|
||||
targetConversationWasCreated
|
||||
);
|
||||
applyChangeToConversation(targetConversation, {
|
||||
[key]: value,
|
||||
});
|
||||
} else {
|
||||
unusedMatches.push(item);
|
||||
}
|
||||
|
@ -578,7 +570,6 @@ export class ConversationController {
|
|||
// If PNI match already has an ACI, then we need to create a new one
|
||||
if (!targetConversation) {
|
||||
targetConversation = this.getOrCreate(unused.value, 'private');
|
||||
targetConversationWasCreated = true;
|
||||
log.info(
|
||||
`${logId}: Match on ${key} already had ${unused.key}, ` +
|
||||
`so created new target conversation - ${targetConversation.idForLogging()}`
|
||||
|
@ -588,13 +579,9 @@ export class ConversationController {
|
|||
log.info(
|
||||
`${logId}: Applying new value for ${unused.key} to target conversation`
|
||||
);
|
||||
applyChangeToConversation(
|
||||
targetConversation,
|
||||
{
|
||||
[unused.key]: unused.value,
|
||||
},
|
||||
targetConversationWasCreated
|
||||
);
|
||||
applyChangeToConversation(targetConversation, {
|
||||
[unused.key]: unused.value,
|
||||
});
|
||||
});
|
||||
|
||||
unusedMatches = [];
|
||||
|
@ -633,20 +620,16 @@ export class ConversationController {
|
|||
if ((key === 'pni' || key === 'e164') && match.get('uuid') === pni) {
|
||||
change.uuid = undefined;
|
||||
}
|
||||
applyChangeToConversation(match, change, targetConversationWasCreated);
|
||||
applyChangeToConversation(match, change);
|
||||
|
||||
// Note: The PNI check here is just to be bulletproof; if we know a UUID is a PNI,
|
||||
// then that should be put in the UUID field as well!
|
||||
const willMerge =
|
||||
!match.get('uuid') && !match.get('e164') && !match.get('pni');
|
||||
|
||||
applyChangeToConversation(
|
||||
targetConversation,
|
||||
{
|
||||
[key]: value,
|
||||
},
|
||||
willMerge || targetConversationWasCreated
|
||||
);
|
||||
applyChangeToConversation(targetConversation, {
|
||||
[key]: value,
|
||||
});
|
||||
|
||||
if (willMerge) {
|
||||
log.warn(
|
||||
|
@ -666,13 +649,9 @@ export class ConversationController {
|
|||
} else if (targetConversation && !targetConversation?.get(key)) {
|
||||
// This is mostly for the situation where PNI was erased when updating e164
|
||||
log.debug(`${logId}: Re-adding ${key} on target conversation`);
|
||||
applyChangeToConversation(
|
||||
targetConversation,
|
||||
{
|
||||
[key]: value,
|
||||
},
|
||||
targetConversationWasCreated
|
||||
);
|
||||
applyChangeToConversation(targetConversation, {
|
||||
[key]: value,
|
||||
});
|
||||
}
|
||||
|
||||
if (!targetConversation) {
|
||||
|
@ -739,7 +718,7 @@ export class ConversationController {
|
|||
|
||||
// `identifier` would resolve to uuid if we had both, so fix up e164
|
||||
if (normalizedUuid && e164) {
|
||||
newConvo.updateE164(e164, { disableDiscoveryNotification: true });
|
||||
newConvo.updateE164(e164);
|
||||
}
|
||||
|
||||
return newConvo;
|
||||
|
@ -1131,7 +1110,7 @@ export class ConversationController {
|
|||
const titleIsUseful = Boolean(
|
||||
obsoleteTitleInfo && getTitleNoDefault(obsoleteTitleInfo)
|
||||
);
|
||||
if (!fromPniSignature && obsoleteTitleInfo && titleIsUseful) {
|
||||
if (obsoleteTitleInfo && titleIsUseful && !fromPniSignature) {
|
||||
drop(current.addConversationMerge(obsoleteTitleInfo));
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue