diff --git a/src/backend/backend.py b/src/backend/backend.py index 565c2828..4b497340 100644 --- a/src/backend/backend.py +++ b/src/backend/backend.py @@ -360,3 +360,34 @@ class Backend: This should only be called from QML. """ self.models["all_rooms"].set_account_collapse(user_id, collapse) + + + async def verify_device( + self, user_id: str, device_id: str, ed25519_key: str, + ) -> None: + """Mark a device as verified on all our accounts.""" + + for client in self.clients.values(): + try: + device = client.device_store[user_id][device_id] + except KeyError: + continue + + if device.ed25519 == ed25519_key: + client.verify_device(device) + + + async def blacklist_device( + self, user_id: str, device_id: str, ed25519_key: str, + ) -> None: + """Mark a device as blacklisted on all our accounts.""" + + for client in self.clients.values(): + try: + # This won't include the client's current device, as expected + device = client.device_store[user_id][device_id] + except KeyError: + continue + + if device.ed25519 == ed25519_key: + client.blacklist_device(device) diff --git a/src/backend/matrix_client.py b/src/backend/matrix_client.py index 9ccf5f8a..96f2d45a 100644 --- a/src/backend/matrix_client.py +++ b/src/backend/matrix_client.py @@ -1371,18 +1371,6 @@ class MatrixClient(nio.AsyncClient): return False - async def verify_device_id(self, user_id: str, device_id: str) -> None: - """Mark a device as verified.""" - - self.verify_device(self.device_store[user_id][device_id]) - - - async def blacklist_device_id(self, user_id: str, device_id: str) -> None: - """Mark a device as blacklisted.""" - - self.blacklist_device(self.device_store[user_id][device_id]) - - async def auto_verify_all_other_accounts(self) -> None: """Automatically verify/blacklist our other accounts's devices.""" diff --git a/src/gui/Pages/AccountSettings/DeviceDelegate.qml b/src/gui/Pages/AccountSettings/DeviceDelegate.qml index 22984129..1f409d72 100644 --- a/src/gui/Pages/AccountSettings/DeviceDelegate.qml +++ b/src/gui/Pages/AccountSettings/DeviceDelegate.qml @@ -151,7 +151,6 @@ HTile { "Popups/KeyVerificationPopup.qml", { focusOnClosed: nameField, - userId: deviceTile.userId, deviceOwner: deviceTile.userId, deviceId: model.id, deviceName: model.display_name, diff --git a/src/gui/Pages/Chat/RoomPane/MemberView/DeviceVerification.qml b/src/gui/Pages/Chat/RoomPane/MemberView/DeviceVerification.qml index edfbeabc..2e1ee545 100644 --- a/src/gui/Pages/Chat/RoomPane/MemberView/DeviceVerification.qml +++ b/src/gui/Pages/Chat/RoomPane/MemberView/DeviceVerification.qml @@ -9,7 +9,6 @@ HFlickableColumnPage { id: page - property string userId property string deviceOwner property string deviceOwnerDisplayName property string deviceId @@ -27,10 +26,9 @@ HFlickableColumnPage { onClicked: { loading = true - py.callClientCoro( - userId, - "verify_device_id", - [deviceOwner, deviceId], + py.callCoro( + "verify_device", + [deviceOwner, deviceId, ed25519Key.replace(/ /g, "")], () => { loading = false page.trustSet(true) @@ -46,10 +44,9 @@ HFlickableColumnPage { onClicked: { loading = true - py.callClientCoro( - userId, - "blacklist_device_id", - [deviceOwner, deviceId], + py.callCoro( + "blacklist_device", + [deviceOwner, deviceId, ed25519Key.replace(/ /g, "")], () => { loading = false page.trustSet(false) diff --git a/src/gui/Pages/Chat/RoomPane/MemberView/MemberDeviceDelegate.qml b/src/gui/Pages/Chat/RoomPane/MemberView/MemberDeviceDelegate.qml index 4122a8e4..c34e6748 100644 --- a/src/gui/Pages/Chat/RoomPane/MemberView/MemberDeviceDelegate.qml +++ b/src/gui/Pages/Chat/RoomPane/MemberView/MemberDeviceDelegate.qml @@ -53,7 +53,6 @@ HTile { const item = stackView.push( "DeviceVerification.qml", { - userId: deviceTile.userId, deviceOwner: deviceTile.deviceOwner, deviceOwnerDisplayName: deviceTile.deviceOwnerDisplayName, deviceId: model.id, diff --git a/src/gui/Popups/KeyVerificationPopup.qml b/src/gui/Popups/KeyVerificationPopup.qml index 0d67ac9a..4e377a6e 100644 --- a/src/gui/Popups/KeyVerificationPopup.qml +++ b/src/gui/Popups/KeyVerificationPopup.qml @@ -9,7 +9,6 @@ HFlickableColumnPopup { id: popup - property string userId property string deviceOwner property string deviceId property string deviceName @@ -27,10 +26,9 @@ HFlickableColumnPopup { onClicked: { loading = true - py.callClientCoro( - userId, - "verify_device_id", - [deviceOwner, deviceId], + py.callCoro( + "verify_device", + [deviceOwner, deviceId, ed25519Key.replace(/ /g, "")], () => { if (verifiedCallback) verifiedCallback() popup.close() @@ -46,10 +44,9 @@ HFlickableColumnPopup { onClicked: { loading = true - py.callClientCoro( - userId, - "blacklist_device_id", - [deviceOwner, deviceId], + py.callCoro( + "blacklist_device", + [deviceOwner, deviceId, ed25519Key.replace(/ /g, "")], () => { if (blacklistedCallback) blacklistedCallback() popup.close()