Call refreshPreKeys on same cadence as rotateSignedPreKey
This commit is contained in:
parent
6e1916030d
commit
22fb69bbb7
2 changed files with 16 additions and 2 deletions
|
@ -326,13 +326,20 @@ export default class AccountManager extends EventTarget {
|
||||||
async refreshPreKeys(uuidKind: UUIDKind): Promise<void> {
|
async refreshPreKeys(uuidKind: UUIDKind): Promise<void> {
|
||||||
return this.queueTask(async () => {
|
return this.queueTask(async () => {
|
||||||
const preKeyCount = await this.server.getMyKeys(uuidKind);
|
const preKeyCount = await this.server.getMyKeys(uuidKind);
|
||||||
log.info(`prekey count ${preKeyCount}`);
|
log.info(
|
||||||
|
`refreshPreKeys(${uuidKind}): Server prekey count is ${preKeyCount}`
|
||||||
|
);
|
||||||
if (preKeyCount >= 10) {
|
if (preKeyCount >= 10) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const keys = await this.generateKeys(SIGNED_KEY_GEN_BATCH_SIZE, uuidKind);
|
const keys = await this.generateKeys(SIGNED_KEY_GEN_BATCH_SIZE, uuidKind);
|
||||||
await this.server.registerKeys(keys, uuidKind);
|
await this.server.registerKeys(keys, uuidKind);
|
||||||
await this.confirmKeys(keys, uuidKind);
|
|
||||||
|
const updatedCount = await this.server.getMyKeys(uuidKind);
|
||||||
|
log.info(
|
||||||
|
`refreshPreKeys(${uuidKind}): Successfully updated; server count is now ${updatedCount}`
|
||||||
|
);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -58,6 +58,13 @@ export class RotateSignedPreKeyListener {
|
||||||
accountManager.rotateSignedPreKey(UUIDKind.ACI),
|
accountManager.rotateSignedPreKey(UUIDKind.ACI),
|
||||||
accountManager.rotateSignedPreKey(UUIDKind.PNI),
|
accountManager.rotateSignedPreKey(UUIDKind.PNI),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
// We try to update this whenever we remove a preKey; this is a fail-safe to ensure
|
||||||
|
// we're always in good shape
|
||||||
|
await Promise.all([
|
||||||
|
accountManager.refreshPreKeys(UUIDKind.ACI),
|
||||||
|
accountManager.refreshPreKeys(UUIDKind.PNI),
|
||||||
|
]);
|
||||||
this.scheduleNextRotation();
|
this.scheduleNextRotation();
|
||||||
this.setTimeoutForNextRun();
|
this.setTimeoutForNextRun();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue