mirror of
https://github.com/signalapp/Signal-Desktop.git
synced 2025-12-24 20:26:24 +00:00
onUnregistered: Split contact even if we don't have pni
This commit is contained in:
@@ -851,9 +851,9 @@ export class ConversationModel extends window.Backbone
|
||||
}
|
||||
|
||||
const e164 = this.get('e164');
|
||||
const aci = this.getAci();
|
||||
const pni = this.getPni();
|
||||
const aci = this.getServiceId();
|
||||
if (e164 && pni && aci && pni !== aci) {
|
||||
if (e164 && aci) {
|
||||
this.updateE164(undefined);
|
||||
this.updatePni(undefined, false);
|
||||
|
||||
|
||||
@@ -340,7 +340,7 @@ describe('pnp/merge', function (this: Mocha.Suite) {
|
||||
});
|
||||
}
|
||||
|
||||
it('splits contact when ACI becomes unregistered', async () => {
|
||||
it('splits ACI/PNI/e164 contact when it becomes unregistered', async () => {
|
||||
const { phone, server } = bootstrap;
|
||||
|
||||
debug(
|
||||
@@ -445,7 +445,7 @@ describe('pnp/merge', function (this: Mocha.Suite) {
|
||||
|
||||
debug('Wait for ACI conversation to go away');
|
||||
await window
|
||||
.locator(`.module-conversation-hero >> ${pniContact.profileName}`)
|
||||
.locator(`.module-conversation-hero >> "${pniContact.profileName}"`)
|
||||
.waitFor({
|
||||
state: 'hidden',
|
||||
});
|
||||
@@ -457,6 +457,99 @@ describe('pnp/merge', function (this: Mocha.Suite) {
|
||||
}
|
||||
});
|
||||
|
||||
it('splits ACI/e164 contact when it becomes unregistered', async () => {
|
||||
const { phone, desktop, server } = bootstrap;
|
||||
const aciContact = pniContact;
|
||||
|
||||
debug('clearing storage service, starting over with ACI/e164 contact');
|
||||
{
|
||||
let state = await phone.expectStorageState('consistency check');
|
||||
state = state.removeContact(pniContact, ServiceIdKind.PNI);
|
||||
state = state.addContact(
|
||||
aciContact,
|
||||
{
|
||||
identityState: Proto.ContactRecord.IdentityState.DEFAULT,
|
||||
whitelisted: true,
|
||||
|
||||
identityKey: aciIdentityKey,
|
||||
|
||||
serviceE164: aciContact.device.number,
|
||||
givenName: 'ACI Contact',
|
||||
},
|
||||
ServiceIdKind.ACI
|
||||
);
|
||||
state = state.pin(aciContact, ServiceIdKind.ACI);
|
||||
|
||||
await phone.setStorageState(state);
|
||||
await phone.sendFetchStorage({
|
||||
timestamp: bootstrap.getTimestamp(),
|
||||
});
|
||||
await app.waitForManifestVersion(state.version);
|
||||
}
|
||||
|
||||
debug('Receive message from contact');
|
||||
|
||||
const desktopKey = await desktop.popSingleUseKey();
|
||||
await aciContact.addSingleUseKey(desktop, desktopKey);
|
||||
|
||||
await aciContact.sendText(desktop, 'Hello from ACI');
|
||||
|
||||
debug('Unregistering ACI');
|
||||
server.unregister(aciContact);
|
||||
|
||||
debug('opening conversation with the contact');
|
||||
const window = await app.getWindow();
|
||||
const leftPane = window.locator('#LeftPane');
|
||||
await leftPane
|
||||
.locator(
|
||||
`[data-testid="${aciContact.device.aci}"] >> ` +
|
||||
`"${aciContact.profileName}"`
|
||||
)
|
||||
.click();
|
||||
|
||||
await window.locator('.module-conversation-hero').waitFor();
|
||||
|
||||
debug('Verify that the message is in the ACI conversation');
|
||||
{
|
||||
await window
|
||||
.locator('.module-message__text >> "Hello from ACI"')
|
||||
.waitFor();
|
||||
|
||||
const messages = window.locator('.module-message__text');
|
||||
assert.strictEqual(await messages.count(), 1, 'message count');
|
||||
}
|
||||
|
||||
debug('Find and open e164 conversation');
|
||||
const searchBox = window.locator(
|
||||
'.module-SearchInput__input.LeftPaneSearchInput__input'
|
||||
);
|
||||
|
||||
await typeIntoInput(searchBox, aciContact.device.number, '');
|
||||
const firstSearchResult = await window.locator(
|
||||
'.module-contact-name.module-conversation-list__item--contact-or-conversation__content__header__name__contact-name'
|
||||
);
|
||||
const firstSearchResultText = await firstSearchResult.innerText();
|
||||
assert.equal(
|
||||
firstSearchResultText.slice(-4),
|
||||
aciContact.device.number.slice(-4),
|
||||
'no profile, just phone number'
|
||||
);
|
||||
await firstSearchResult.click();
|
||||
|
||||
debug('Wait for ACI conversation to go away');
|
||||
await window
|
||||
.locator(`.module-conversation-hero >> "${pniContact.profileName}"`)
|
||||
.waitFor({
|
||||
state: 'hidden',
|
||||
});
|
||||
|
||||
debug('Verify absence of messages in the e164 conversation');
|
||||
{
|
||||
const messages = window.locator('.module-message__text');
|
||||
assert.strictEqual(await messages.count(), 0, 'message count');
|
||||
}
|
||||
});
|
||||
|
||||
it('preserves expireTimerVersion after merge', async () => {
|
||||
const { phone, desktop } = bootstrap;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user