Add config option to autorageshake when key backup is not enabled (#7741)

* report on not enabled

Signed-off-by: Kerry Archibald <kerrya@element.io>

* add setting

Signed-off-by: Kerry Archibald <kerrya@element.io>

* check key backup status after crypto init

Signed-off-by: Kerry Archibald <kerrya@element.io>

* remove log

Signed-off-by: Kerry Archibald <kerrya@element.io>

* test encryption setup in DeviceListener

Signed-off-by: Kerry Archibald <kerrya@element.io>

* i18n

Signed-off-by: Kerry Archibald <kerrya@element.io>

* sendLogs for key backup auto-report event

Signed-off-by: Kerry Archibald <kerrya@element.io>

* remove reloadOnChagneController

Signed-off-by: Kerry Archibald <kerrya@element.io>
This commit is contained in:
Kerry 2022-02-11 14:00:37 +01:00 committed by GitHub
parent d06ec845ee
commit b5e7d12f76
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 290 additions and 1 deletions

View file

@ -36,6 +36,7 @@ import { isSecretStorageBeingAccessed, accessSecretStorage } from "./SecurityMan
import { isSecureBackupRequired } from './utils/WellKnownUtils';
import { isLoggedIn } from './components/structures/MatrixChat';
import { ActionPayload } from "./dispatcher/payloads";
import { Action } from "./dispatcher/actions";
const KEY_BACKUP_POLL_INTERVAL = 5 * 60 * 1000;
@ -48,6 +49,7 @@ export default class DeviceListener {
// cache of the key backup info
private keyBackupInfo: object = null;
private keyBackupFetchedAt: number = null;
private keyBackupStatusChecked = false;
// We keep a list of our own device IDs so we can batch ones that were already
// there the last time the app launched into a single toast, but display new
// ones in their own toasts.
@ -92,6 +94,7 @@ export default class DeviceListener {
this.dismissedThisDeviceToast = false;
this.keyBackupInfo = null;
this.keyBackupFetchedAt = null;
this.keyBackupStatusChecked = false;
this.ourDeviceIdsAtStart = null;
this.displayingToastsForDeviceIds = new Set();
}
@ -227,6 +230,8 @@ export default class DeviceListener {
if (this.dismissedThisDeviceToast || allSystemsReady) {
hideSetupEncryptionToast();
this.checkKeyBackupStatus();
} else if (this.shouldShowSetupEncryptionToast()) {
// make sure our keys are finished downloading
await cli.downloadKeys([cli.getUserId()]);
@ -238,6 +243,7 @@ export default class DeviceListener {
) {
// Cross-signing on account but this device doesn't trust the master key (verify this session)
showSetupEncryptionToast(SetupKind.VERIFY_THIS_SESSION);
this.checkKeyBackupStatus();
} else {
const backupInfo = await this.getKeyBackupInfo();
if (backupInfo) {
@ -312,4 +318,17 @@ export default class DeviceListener {
this.displayingToastsForDeviceIds = newUnverifiedDeviceIds;
}
private checkKeyBackupStatus = async () => {
if (this.keyBackupStatusChecked) {
return;
}
// returns null when key backup status hasn't finished being checked
const isKeyBackupEnabled = MatrixClientPeg.get().getKeyBackupEnabled();
this.keyBackupStatusChecked = isKeyBackupEnabled !== null;
if (isKeyBackupEnabled === false) {
dis.dispatch({ action: Action.ReportKeyBackupNotEnabled });
}
};
}