Correctly handle & warn about key-less devices
This commit is contained in:
parent
a15a101ce0
commit
d35173adc3
1
TODO.md
1
TODO.md
@ -1,5 +1,6 @@
|
|||||||
# TODO
|
# TODO
|
||||||
|
|
||||||
|
- verify & delete devices
|
||||||
- sessions page size
|
- sessions page size
|
||||||
- flickshortcuts
|
- flickshortcuts
|
||||||
- avatar upload/change component
|
- avatar upload/change component
|
||||||
|
@ -9,6 +9,7 @@ import logging as log
|
|||||||
import platform
|
import platform
|
||||||
import re
|
import re
|
||||||
import sys
|
import sys
|
||||||
|
import textwrap
|
||||||
import traceback
|
import traceback
|
||||||
from contextlib import suppress
|
from contextlib import suppress
|
||||||
from copy import deepcopy
|
from copy import deepcopy
|
||||||
@ -1261,17 +1262,28 @@ class MatrixClient(nio.AsyncClient):
|
|||||||
"""Get sorted list of devices and their info for our user."""
|
"""Get sorted list of devices and their info for our user."""
|
||||||
|
|
||||||
def get_type(device_id: str) -> str:
|
def get_type(device_id: str) -> str:
|
||||||
# Return "current", "verified", "blacklisted", "ignored" or "unset"
|
# Return "current", "no_keys", "verified", "blacklisted",
|
||||||
|
# "ignored" or "unset"
|
||||||
|
|
||||||
if device_id == self.device_id:
|
if device_id == self.device_id:
|
||||||
return "current"
|
return "current"
|
||||||
|
|
||||||
if device_id not in self.olm.device_store[self.user_id]:
|
if device_id not in self.olm.device_store[self.user_id]:
|
||||||
return "unset"
|
return "no_keys"
|
||||||
|
|
||||||
trust = self.olm.device_store[self.user_id][device_id].trust_state
|
trust = self.olm.device_store[self.user_id][device_id].trust_state
|
||||||
return trust.name
|
return trust.name
|
||||||
|
|
||||||
|
def get_ed25519(device_id: str) -> str:
|
||||||
|
key = ""
|
||||||
|
|
||||||
|
if device_id == self.device_id:
|
||||||
|
key = self.olm.account.identity_keys["ed25519"]
|
||||||
|
elif device_id in self.olm.device_store[self.user_id]:
|
||||||
|
key = self.olm.device_store[self.user_id][device_id].ed25519
|
||||||
|
|
||||||
|
return " ".join(textwrap.wrap(key, 4))
|
||||||
|
|
||||||
devices = [
|
devices = [
|
||||||
{
|
{
|
||||||
"id": device.id,
|
"id": device.id,
|
||||||
@ -1280,14 +1292,16 @@ class MatrixClient(nio.AsyncClient):
|
|||||||
"last_seen_date": device.last_seen_date or ZeroDate,
|
"last_seen_date": device.last_seen_date or ZeroDate,
|
||||||
"last_seen_country": "",
|
"last_seen_country": "",
|
||||||
"type": get_type(device.id),
|
"type": get_type(device.id),
|
||||||
|
"ed25519_key": get_ed25519(device.id),
|
||||||
}
|
}
|
||||||
for device in (await self.devices()).devices
|
for device in (await self.devices()).devices
|
||||||
]
|
]
|
||||||
|
|
||||||
# Reversed due to sorted(reverse=True) call below
|
# Reversed due to sorted(reverse=True) call below
|
||||||
types_order = {
|
types_order = {
|
||||||
"current": 4,
|
"current": 5,
|
||||||
"unset": 3,
|
"unset": 4,
|
||||||
|
"no_keys": 3,
|
||||||
"verified": 2,
|
"verified": 2,
|
||||||
"ignored": 1,
|
"ignored": 1,
|
||||||
"blacklisted": 0,
|
"blacklisted": 0,
|
||||||
|
@ -103,6 +103,27 @@ HTile {
|
|||||||
|
|
||||||
HMenuSeparator {}
|
HMenuSeparator {}
|
||||||
|
|
||||||
|
HLabel {
|
||||||
|
id: noKeysLabel
|
||||||
|
visible: model.type === "no_keys"
|
||||||
|
width: parent.width
|
||||||
|
height: visible ? implicitHeight : 0 // avoid empty space
|
||||||
|
|
||||||
|
wrapMode: HLabel.Wrap
|
||||||
|
horizontalAlignment: Qt.AlignHCenter
|
||||||
|
textFormat: HLabel.RichText
|
||||||
|
color: theme.colors.warningText
|
||||||
|
text: qsTr(
|
||||||
|
"This session doesn't support encryption or " +
|
||||||
|
"failed to upload a verification key"
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
HMenuSeparator {
|
||||||
|
visible: noKeysLabel.visible
|
||||||
|
height: visible ? implicitHeight : 0
|
||||||
|
}
|
||||||
|
|
||||||
HLabeledItem {
|
HLabeledItem {
|
||||||
width: parent.width
|
width: parent.width
|
||||||
label.text: qsTr("Actions:")
|
label.text: qsTr("Actions:")
|
||||||
@ -112,8 +133,10 @@ HTile {
|
|||||||
width: parent.width
|
width: parent.width
|
||||||
|
|
||||||
ApplyButton {
|
ApplyButton {
|
||||||
enabled:
|
enabled: [
|
||||||
model.type !== "current" && model.type !== "verified"
|
"unset", "ignored", "blacklisted",
|
||||||
|
].includes(model.type)
|
||||||
|
|
||||||
text: qsTr("Verify")
|
text: qsTr("Verify")
|
||||||
icon.name: "device-verify"
|
icon.name: "device-verify"
|
||||||
}
|
}
|
||||||
|
@ -22,10 +22,11 @@ HRowLayout {
|
|||||||
|
|
||||||
text:
|
text:
|
||||||
section === "current" ? qsTr("Current session") :
|
section === "current" ? qsTr("Current session") :
|
||||||
|
section === "unset" ? qsTr("Unverified") :
|
||||||
|
section === "no_keys" ? qsTr("Unverifiable") :
|
||||||
section === "verified" ? qsTr("Verified") :
|
section === "verified" ? qsTr("Verified") :
|
||||||
section === "ignored" ? qsTr("Ignored") :
|
section === "ignored" ? qsTr("Ignored") :
|
||||||
section === "blacklisted" ? qsTr("Blacklisted") :
|
qsTr("Blacklisted")
|
||||||
qsTr("Unverified")
|
|
||||||
|
|
||||||
tristate: true
|
tristate: true
|
||||||
|
|
||||||
@ -67,10 +68,10 @@ HRowLayout {
|
|||||||
verticalAlignment: Qt.AlignVCenter
|
verticalAlignment: Qt.AlignVCenter
|
||||||
|
|
||||||
color:
|
color:
|
||||||
section === "current" || section === "verified" ?
|
["current", "verified"].includes(section) ?
|
||||||
theme.colors.positiveText :
|
theme.colors.positiveText :
|
||||||
|
|
||||||
section === "unset" || section === "ignored" ?
|
["unset", "ignored", "no_keys"].includes(section) ?
|
||||||
theme.colors.warningText :
|
theme.colors.warningText :
|
||||||
|
|
||||||
theme.colors.errorText
|
theme.colors.errorText
|
||||||
|
Loading…
x
Reference in New Issue
Block a user