Request and handle PniIdentity sync message
This commit is contained in:
parent
5a107e1bc3
commit
a0ae7c1aa2
7 changed files with 245 additions and 74 deletions
|
@ -68,6 +68,7 @@ import type {
|
|||
FetchLatestEvent,
|
||||
GroupEvent,
|
||||
KeysEvent,
|
||||
PNIIdentityEvent,
|
||||
MessageEvent,
|
||||
MessageEventData,
|
||||
MessageRequestResponseEvent,
|
||||
|
@ -369,6 +370,10 @@ export async function startApp(): Promise<void> {
|
|||
queuedEventListener(onFetchLatestSync)
|
||||
);
|
||||
messageReceiver.addEventListener('keys', queuedEventListener(onKeysSync));
|
||||
messageReceiver.addEventListener(
|
||||
'pniIdentity',
|
||||
queuedEventListener(onPNIIdentitySync)
|
||||
);
|
||||
});
|
||||
|
||||
ourProfileKeyService.initialize(window.storage);
|
||||
|
@ -2259,6 +2264,8 @@ export async function startApp(): Promise<void> {
|
|||
window.waitForEmptyEventQueue = waitForEmptyEventQueue;
|
||||
|
||||
async function onEmpty() {
|
||||
const { storage, messaging } = window.textsecure;
|
||||
|
||||
await Promise.all([
|
||||
window.waitForAllBatchers(),
|
||||
window.flushAllWaitBatchers(),
|
||||
|
@ -2332,7 +2339,7 @@ export async function startApp(): Promise<void> {
|
|||
}
|
||||
});
|
||||
await window.Signal.Data.saveMessages(messagesToSave, {
|
||||
ourUuid: window.textsecure.storage.user.getCheckedUuid().toString(),
|
||||
ourUuid: storage.user.getCheckedUuid().toString(),
|
||||
});
|
||||
|
||||
// Process crash reports if any
|
||||
|
@ -2348,7 +2355,7 @@ export async function startApp(): Promise<void> {
|
|||
routineProfileRefresh({
|
||||
allConversations: window.ConversationController.getAll(),
|
||||
ourConversationId,
|
||||
storage: window.storage,
|
||||
storage,
|
||||
});
|
||||
} else {
|
||||
assert(
|
||||
|
@ -2356,6 +2363,17 @@ export async function startApp(): Promise<void> {
|
|||
'Failed to fetch our conversation ID. Skipping routine profile refresh'
|
||||
);
|
||||
}
|
||||
|
||||
// Make sure we have the PNI identity
|
||||
|
||||
const pni = storage.user.getCheckedUuid(UUIDKind.PNI);
|
||||
const pniIdentity = await storage.protocol.getIdentityKeyPair(pni);
|
||||
if (!pniIdentity) {
|
||||
log.info('Requesting PNI identity sync');
|
||||
await singleProtoJobQueue.add(
|
||||
messaging.getRequestPniIdentitySyncMessage()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
let initialStartupCount = 0;
|
||||
|
@ -3486,6 +3504,15 @@ export async function startApp(): Promise<void> {
|
|||
}
|
||||
}
|
||||
|
||||
async function onPNIIdentitySync(ev: PNIIdentityEvent) {
|
||||
ev.confirm();
|
||||
|
||||
log.info('onPNIIdentitySync: updating PNI keys');
|
||||
const manager = window.getAccountManager();
|
||||
const { privateKey: privKey, publicKey: pubKey } = ev.data;
|
||||
await manager.updatePNIIdentity({ privKey, pubKey });
|
||||
}
|
||||
|
||||
async function onMessageRequestResponse(ev: MessageRequestResponseEvent) {
|
||||
ev.confirm();
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue