You've already forked matrix-js-sdk
mirror of
https://github.com/matrix-org/matrix-js-sdk.git
synced 2025-11-26 17:03:12 +03:00
Call scheduleAllGroupSessionsForBackup during resetKeyBackup (#3935)
since its equivalent is done automatically in Rust crypto when we call resetKeyBackup.
This commit is contained in:
@@ -2832,6 +2832,19 @@ describe.each(Object.entries(CRYPTO_BACKENDS))("crypto (%s)", (backend: string,
|
|||||||
|
|
||||||
const newBackupUploadPromise = awaitMegolmBackupKeyUpload();
|
const newBackupUploadPromise = awaitMegolmBackupKeyUpload();
|
||||||
|
|
||||||
|
// Track calls to scheduleAllGroupSessionsForBackup. This is
|
||||||
|
// only relevant on legacy encryption.
|
||||||
|
const scheduleAllGroupSessionsForBackup = jest.fn();
|
||||||
|
if (backend === "libolm") {
|
||||||
|
aliceClient.crypto!.backupManager.scheduleAllGroupSessionsForBackup =
|
||||||
|
scheduleAllGroupSessionsForBackup;
|
||||||
|
} else {
|
||||||
|
// With Rust crypto, we don't need to call this function, so
|
||||||
|
// we call the dummy value here so we pass our later
|
||||||
|
// expectation.
|
||||||
|
scheduleAllGroupSessionsForBackup();
|
||||||
|
}
|
||||||
|
|
||||||
await aliceClient.getCrypto()!.resetKeyBackup();
|
await aliceClient.getCrypto()!.resetKeyBackup();
|
||||||
await awaitDeleteCalled;
|
await awaitDeleteCalled;
|
||||||
await newBackupStatusUpdate;
|
await newBackupStatusUpdate;
|
||||||
@@ -2843,6 +2856,7 @@ describe.each(Object.entries(CRYPTO_BACKENDS))("crypto (%s)", (backend: string,
|
|||||||
expect(nextVersion).toBeDefined();
|
expect(nextVersion).toBeDefined();
|
||||||
expect(nextVersion).not.toEqual(currentVersion);
|
expect(nextVersion).not.toEqual(currentVersion);
|
||||||
expect(nextKey).not.toEqual(currentBackupKey);
|
expect(nextKey).not.toEqual(currentBackupKey);
|
||||||
|
expect(scheduleAllGroupSessionsForBackup).toHaveBeenCalled();
|
||||||
|
|
||||||
// The `deleteKeyBackupVersion` API is deprecated but has been modified to work with both crypto backend
|
// The `deleteKeyBackupVersion` API is deprecated but has been modified to work with both crypto backend
|
||||||
// ensure that it works anyhow
|
// ensure that it works anyhow
|
||||||
|
|||||||
@@ -3646,6 +3646,9 @@ export class MatrixClient extends TypedEventEmitter<EmittedEvents, ClientEventHa
|
|||||||
/**
|
/**
|
||||||
* Marks all group sessions as needing to be backed up and schedules them to
|
* Marks all group sessions as needing to be backed up and schedules them to
|
||||||
* upload in the background as soon as possible.
|
* upload in the background as soon as possible.
|
||||||
|
*
|
||||||
|
* (This is done automatically as part of {@link CryptoApi.resetKeyBackup},
|
||||||
|
* so there is probably no need to call this manually.)
|
||||||
*/
|
*/
|
||||||
public async scheduleAllGroupSessionsForBackup(): Promise<void> {
|
public async scheduleAllGroupSessionsForBackup(): Promise<void> {
|
||||||
if (!this.crypto) {
|
if (!this.crypto) {
|
||||||
@@ -3658,6 +3661,10 @@ export class MatrixClient extends TypedEventEmitter<EmittedEvents, ClientEventHa
|
|||||||
/**
|
/**
|
||||||
* Marks all group sessions as needing to be backed up without scheduling
|
* Marks all group sessions as needing to be backed up without scheduling
|
||||||
* them to upload in the background.
|
* them to upload in the background.
|
||||||
|
*
|
||||||
|
* (This is done automatically as part of {@link CryptoApi.resetKeyBackup},
|
||||||
|
* so there is probably no need to call this manually.)
|
||||||
|
*
|
||||||
* @returns Promise which resolves to the number of sessions requiring a backup.
|
* @returns Promise which resolves to the number of sessions requiring a backup.
|
||||||
*/
|
*/
|
||||||
public flagAllGroupSessionsForBackup(): Promise<number> {
|
public flagAllGroupSessionsForBackup(): Promise<number> {
|
||||||
|
|||||||
@@ -1211,6 +1211,7 @@ export class Crypto extends TypedEventEmitter<CryptoEvent, CryptoEventHandlerMap
|
|||||||
await this.storeSessionBackupPrivateKey(privateKey);
|
await this.storeSessionBackupPrivateKey(privateKey);
|
||||||
|
|
||||||
await this.backupManager.checkAndStart();
|
await this.backupManager.checkAndStart();
|
||||||
|
await this.backupManager.scheduleAllGroupSessionsForBackup();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user