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> {
|
||||
return this.queueTask(async () => {
|
||||
const preKeyCount = await this.server.getMyKeys(uuidKind);
|
||||
log.info(`prekey count ${preKeyCount}`);
|
||||
log.info(
|
||||
`refreshPreKeys(${uuidKind}): Server prekey count is ${preKeyCount}`
|
||||
);
|
||||
if (preKeyCount >= 10) {
|
||||
return;
|
||||
}
|
||||
|
||||
const keys = await this.generateKeys(SIGNED_KEY_GEN_BATCH_SIZE, 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.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.setTimeoutForNextRun();
|
||||
} catch (error) {
|
||||
|
|
Loading…
Reference in a new issue