From edd6ed5fab1ddd73f0a49cee5efb8dd94fdacbc2 Mon Sep 17 00:00:00 2001 From: Fedor Indutny <79877362+indutny-signal@users.noreply.github.com> Date: Tue, 31 Oct 2023 00:25:55 +0100 Subject: [PATCH] Clear PNI signature flag on PNI change --- ts/ConversationController.ts | 20 ++++++++++++++++++++ ts/textsecure/AccountManager.ts | 1 + 2 files changed, 21 insertions(+) diff --git a/ts/ConversationController.ts b/ts/ConversationController.ts index 0d40772c3..4c932fe35 100644 --- a/ts/ConversationController.ts +++ b/ts/ConversationController.ts @@ -1329,6 +1329,26 @@ export class ConversationController { } } + async clearShareMyPhoneNumber(): Promise { + const sharedWith = this.getAll().filter(c => c.get('shareMyPhoneNumber')); + + if (sharedWith.length === 0) { + return; + } + + log.info( + 'ConversationController.clearShareMyPhoneNumber: ' + + `updating ${sharedWith.length} conversations` + ); + + await window.Signal.Data.updateConversations( + sharedWith.map(c => { + c.unset('shareMyPhoneNumber'); + return c.attributes; + }) + ); + } + // For testing async _forgetE164(e164: string): Promise { const { server } = window.textsecure; diff --git a/ts/textsecure/AccountManager.ts b/ts/textsecure/AccountManager.ts index 8f3db2a4f..3ba20875c 100644 --- a/ts/textsecure/AccountManager.ts +++ b/ts/textsecure/AccountManager.ts @@ -1369,6 +1369,7 @@ export default class AccountManager extends EventTarget { if (oldPni) { await storage.protocol.removeOurOldPni(oldPni); + await window.ConversationController.clearShareMyPhoneNumber(); } await storage.user.setPni(pni);