You've already forked matrix-react-sdk
							
							
				mirror of
				https://github.com/matrix-org/matrix-react-sdk.git
				synced 2025-11-04 11:51:45 +03:00 
			
		
		
		
	Recheck security status on room encryption change
This ensures we are alerted when you first interact with an encrypted room. Part of https://github.com/vector-im/element-web/issues/13895
This commit is contained in:
		@@ -33,7 +33,7 @@ import { privateShouldBeEncrypted } from "./createRoom";
 | 
			
		||||
import { isSecretStorageBeingAccessed, accessSecretStorage } from "./SecurityManager";
 | 
			
		||||
import { isSecureBackupRequired } from './utils/WellKnownUtils';
 | 
			
		||||
import { isLoggedIn } from './components/structures/MatrixChat';
 | 
			
		||||
 | 
			
		||||
import { MatrixEvent } from "matrix-js-sdk/src/models/event";
 | 
			
		||||
 | 
			
		||||
const KEY_BACKUP_POLL_INTERVAL = 5 * 60 * 1000;
 | 
			
		||||
 | 
			
		||||
@@ -66,6 +66,7 @@ export default class DeviceListener {
 | 
			
		||||
        MatrixClientPeg.get().on('crossSigning.keysChanged', this._onCrossSingingKeysChanged);
 | 
			
		||||
        MatrixClientPeg.get().on('accountData', this._onAccountData);
 | 
			
		||||
        MatrixClientPeg.get().on('sync', this._onSync);
 | 
			
		||||
        MatrixClientPeg.get().on('RoomState.events', this._onRoomStateEvents);
 | 
			
		||||
        this.dispatcherRef = dis.register(this._onAction);
 | 
			
		||||
        this._recheck();
 | 
			
		||||
    }
 | 
			
		||||
@@ -79,6 +80,7 @@ export default class DeviceListener {
 | 
			
		||||
            MatrixClientPeg.get().removeListener('crossSigning.keysChanged', this._onCrossSingingKeysChanged);
 | 
			
		||||
            MatrixClientPeg.get().removeListener('accountData', this._onAccountData);
 | 
			
		||||
            MatrixClientPeg.get().removeListener('sync', this._onSync);
 | 
			
		||||
            MatrixClientPeg.get().removeListener('RoomState.events', this._onRoomStateEvents);
 | 
			
		||||
        }
 | 
			
		||||
        if (this.dispatcherRef) {
 | 
			
		||||
            dis.unregister(this.dispatcherRef);
 | 
			
		||||
@@ -169,6 +171,16 @@ export default class DeviceListener {
 | 
			
		||||
        if (state === 'PREPARED' && prevState === null) this._recheck();
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
    _onRoomStateEvents = (ev: MatrixEvent) => {
 | 
			
		||||
        if (ev.getType() !== "m.room.encryption") {
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        // If a room changes to encrypted, re-check as it may be our first
 | 
			
		||||
        // encrypted room. This also catches encrypted room creation as well.
 | 
			
		||||
        this._recheck();
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
    _onAction = ({ action }) => {
 | 
			
		||||
        if (action !== "on_logged_in") return;
 | 
			
		||||
        this._recheck();
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user