Refresh PNI on startup

This commit is contained in:
Fedor Indutny 2022-07-18 15:32:00 -07:00 committed by GitHub
parent a4cf2e0948
commit 5c2016ec40
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 90 additions and 75 deletions

View file

@ -0,0 +1,28 @@
// Copyright 2021-2022 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
import { strictAssert } from './assert';
import { dropNull } from './dropNull';
export async function updateOurUsernameAndPni(): Promise<void> {
const { server } = window.textsecure;
strictAssert(
server,
'updateOurUsernameAndPni: window.textsecure.server not available'
);
const me = window.ConversationController.getOurConversationOrThrow();
const { username, pni } = await server.whoami();
me.set({ username: dropNull(username) });
window.Signal.Data.updateConversation(me.attributes);
const manager = window.getAccountManager();
strictAssert(
manager,
'updateOurUsernameAndPni: AccountManager not available'
);
await manager.setPni(pni);
}