From edc73c695282517a9f270b8f2da61d9fef16666f Mon Sep 17 00:00:00 2001 From: miruka Date: Fri, 26 Jun 2020 02:16:00 -0400 Subject: [PATCH] Implement blacklisting from verification key popup --- src/backend/matrix_client.py | 5 +++++ src/gui/Pages/AccountSettings/DeviceDelegate.qml | 2 ++ src/gui/Pages/AccountSettings/Sessions.qml | 1 + src/gui/Popups/KeyVerificationPopup.qml | 14 ++++++++++++-- 4 files changed, 20 insertions(+), 2 deletions(-) diff --git a/src/backend/matrix_client.py b/src/backend/matrix_client.py index 0d73eb89..b9c21044 100644 --- a/src/backend/matrix_client.py +++ b/src/backend/matrix_client.py @@ -1331,6 +1331,11 @@ class MatrixClient(nio.AsyncClient): self.verify_device(self.olm.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.olm.device_store[user_id][device_id]) + # Functions to register/modify data into models diff --git a/src/gui/Pages/AccountSettings/DeviceDelegate.qml b/src/gui/Pages/AccountSettings/DeviceDelegate.qml index df1b5d19..ff68f37d 100644 --- a/src/gui/Pages/AccountSettings/DeviceDelegate.qml +++ b/src/gui/Pages/AccountSettings/DeviceDelegate.qml @@ -14,6 +14,7 @@ HTile { property string userId signal verified() + signal blacklisted() signal renameRequest(string name) @@ -157,6 +158,7 @@ HTile { ed25519Key: model.ed25519_key, deviceIsCurrent: model.type === "current", verifiedCallback: deviceTile.verified, + blacklistedCallback: deviceTile.blacklisted, }, ) } diff --git a/src/gui/Pages/AccountSettings/Sessions.qml b/src/gui/Pages/AccountSettings/Sessions.qml index 43f623da..bb0501dd 100644 --- a/src/gui/Pages/AccountSettings/Sessions.qml +++ b/src/gui/Pages/AccountSettings/Sessions.qml @@ -80,6 +80,7 @@ HColumnPage { view: deviceList userId: page.userId onVerified: page.loadDevices() + onBlacklisted: page.loadDevices() onRenameRequest: name => renameDevice(model.index, name) } diff --git a/src/gui/Popups/KeyVerificationPopup.qml b/src/gui/Popups/KeyVerificationPopup.qml index 1812b00a..0d67ac9a 100644 --- a/src/gui/Popups/KeyVerificationPopup.qml +++ b/src/gui/Popups/KeyVerificationPopup.qml @@ -16,6 +16,7 @@ HFlickableColumnPopup { property string ed25519Key property bool deviceIsCurrent: false property var verifiedCallback: null + property var blacklistedCallback: null page.footer: ButtonLayout { @@ -43,8 +44,17 @@ HFlickableColumnPopup { text: qsTr("They differ") icon.name: "device-blacklisted" onClicked: { - // XXX - popup.close() + loading = true + + py.callClientCoro( + userId, + "blacklist_device_id", + [deviceOwner, deviceId], + () => { + if (blacklistedCallback) blacklistedCallback() + popup.close() + } + ) } }