From 759c61d06e89a00b74ebe00ac8f9a8abfad6a2f7 Mon Sep 17 00:00:00 2001 From: Fedor Indutny <79877362+indutny-signal@users.noreply.github.com> Date: Mon, 22 May 2023 18:37:58 +0200 Subject: [PATCH] Use e164 from PniChangeNumber sync message --- protos/SignalService.proto | 1 + ts/services/storageRecordOps.ts | 4 +++- ts/textsecure/MessageReceiver.ts | 7 +++++-- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/protos/SignalService.proto b/protos/SignalService.proto index d762d155a5f1..8c2119eae44c 100644 --- a/protos/SignalService.proto +++ b/protos/SignalService.proto @@ -580,6 +580,7 @@ message SyncMessage { optional bytes identityKeyPair = 1; // Serialized libsignal-client IdentityKeyPair optional bytes signedPreKey = 2; // Serialized libsignal-client SignedPreKeyRecord optional uint32 registrationId = 3; + optional string newE164 = 4; // The e164 we have changed our number to } message CallEvent { diff --git a/ts/services/storageRecordOps.ts b/ts/services/storageRecordOps.ts index 49e22f5b7c39..8bcdbd25dec7 100644 --- a/ts/services/storageRecordOps.ts +++ b/ts/services/storageRecordOps.ts @@ -1199,7 +1199,9 @@ export async function mergeAccountRecord( if (typeof accountE164 === 'string' && accountE164) { await window.storage.put('accountE164', accountE164); - await window.storage.user.setNumber(accountE164); + if (!RemoteConfig.isEnabled('desktop.pnp')) { + await window.storage.user.setNumber(accountE164); + } } if (preferredReactionEmoji.canBeSynced(rawPreferredReactionEmoji)) { diff --git a/ts/textsecure/MessageReceiver.ts b/ts/textsecure/MessageReceiver.ts index 05273e0dda58..49abecefd413 100644 --- a/ts/textsecure/MessageReceiver.ts +++ b/ts/textsecure/MessageReceiver.ts @@ -3,7 +3,7 @@ /* eslint-disable no-bitwise */ -import { isBoolean, isNumber, omit } from 'lodash'; +import { isBoolean, isNumber, isString, omit } from 'lodash'; import PQueue from 'p-queue'; import { v4 as getGuid } from 'uuid'; @@ -3197,6 +3197,7 @@ export default class MessageReceiver identityKeyPair, signedPreKey, registrationId, + newE164, }: Proto.SyncMessage.IPniChangeNumber ): Promise { log.info('MessageReceiver: got pni change number sync message'); @@ -3212,7 +3213,8 @@ export default class MessageReceiver if ( !Bytes.isNotEmpty(identityKeyPair) || !Bytes.isNotEmpty(signedPreKey) || - !isNumber(registrationId) + !isNumber(registrationId) || + !isString(newE164) ) { log.warn('MessageReceiver: empty pni change number sync message'); return; @@ -3224,6 +3226,7 @@ export default class MessageReceiver signedPreKey, registrationId, }); + await window.storage.user.setNumber(newE164); } private async handleStickerPackOperation(