Show Session Switchover Events
Co-authored-by: Scott Nonnenberg <scott@signal.org>
This commit is contained in:
parent
70cd073a72
commit
dd2493a353
13 changed files with 455 additions and 17 deletions
|
@ -471,7 +471,7 @@ export class ConversationController {
|
|||
e164,
|
||||
pni: providedPni,
|
||||
reason,
|
||||
fromPniSignature,
|
||||
fromPniSignature = false,
|
||||
mergeOldAndNew = safeCombineConversations,
|
||||
}: {
|
||||
aci?: AciString;
|
||||
|
@ -526,6 +526,12 @@ export class ConversationController {
|
|||
let unusedMatches: Array<ConvoMatchType> = [];
|
||||
|
||||
let targetConversation: ConversationModel | undefined;
|
||||
let targetOldServiceIds:
|
||||
| {
|
||||
aci?: AciString;
|
||||
pni?: PniString;
|
||||
}
|
||||
| undefined;
|
||||
let matchCount = 0;
|
||||
matches.forEach(item => {
|
||||
const { key, value, match } = item;
|
||||
|
@ -597,6 +603,11 @@ export class ConversationController {
|
|||
);
|
||||
}
|
||||
|
||||
targetOldServiceIds = {
|
||||
aci: targetConversation.getAci(),
|
||||
pni: targetConversation.getPni(),
|
||||
};
|
||||
|
||||
log.info(
|
||||
`${logId}: Applying new value for ${unused.key} to target conversation`
|
||||
);
|
||||
|
@ -686,9 +697,32 @@ export class ConversationController {
|
|||
// `${logId}: Match on ${key} is target conversation - ${match.idForLogging()}`
|
||||
// );
|
||||
targetConversation = match;
|
||||
targetOldServiceIds = {
|
||||
aci: targetConversation.getAci(),
|
||||
pni: targetConversation.getPni(),
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
// If the change is not coming from PNI Signature, and target conversation
|
||||
// had PNI and has acquired new ACI and/or PNI we should check if it had
|
||||
// a PNI session on the original PNI. If yes - add a PhoneNumberDiscovery notification
|
||||
if (
|
||||
e164 &&
|
||||
pni &&
|
||||
targetConversation &&
|
||||
targetOldServiceIds?.pni &&
|
||||
!fromPniSignature &&
|
||||
(targetOldServiceIds.pni !== pni ||
|
||||
(aci && targetOldServiceIds.aci !== aci))
|
||||
) {
|
||||
mergePromises.push(
|
||||
targetConversation.addPhoneNumberDiscoveryIfNeeded(
|
||||
targetOldServiceIds.pni
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
if (targetConversation) {
|
||||
return { conversation: targetConversation, mergePromises };
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue