diff --git a/src/ui/UserProfile.cpp b/src/ui/UserProfile.cpp
index 6ef82123..08219a38 100644
--- a/src/ui/UserProfile.cpp
+++ b/src/ui/UserProfile.cpp
@@ -112,6 +112,17 @@ UserProfile::getUserStatus()
return isUserVerified;
}
+bool
+UserProfile::userVerificationEnabled() const
+{
+ return hasMasterKey;
+}
+bool
+UserProfile::isSelf() const
+{
+ return this->userid_ == utils::localUser();
+}
+
void
UserProfile::fetchDeviceList(const QString &userID)
{
@@ -128,10 +139,10 @@ UserProfile::fetchDeviceList(const QString &userID)
return;
}
- // Finding if the User is Verified or not based on the Signatures
+ // Ensure local key cache is up to date
cache::client()->query_keys(
utils::localUser().toStdString(),
- [other_user_id, other_user_keys, this](const UserKeyCache &res,
+ [other_user_id, other_user_keys, this](const UserKeyCache &,
mtx::http::RequestErr err) {
using namespace mtx;
std::string local_user_id = utils::localUser().toStdString();
@@ -143,10 +154,7 @@ UserProfile::fetchDeviceList(const QString &userID)
return;
}
- if (res.device_keys.empty()) {
- nhlog::net()->warn("no devices retrieved {}", local_user_id);
- return;
- }
+ this->hasMasterKey = !other_user_keys.master_keys.keys.empty();
std::vector<DeviceInfo> deviceInfo;
auto devices = other_user_keys.device_keys;
diff --git a/src/ui/UserProfile.h b/src/ui/UserProfile.h
index 62151266..19527310 100644
--- a/src/ui/UserProfile.h
+++ b/src/ui/UserProfile.h
@@ -84,6 +84,9 @@ class UserProfile : public QObject
Q_PROPERTY(QString avatarUrl READ avatarUrl CONSTANT)
Q_PROPERTY(DeviceInfoModel *deviceList READ deviceList CONSTANT)
Q_PROPERTY(bool isUserVerified READ getUserStatus NOTIFY userStatusChanged)
+ Q_PROPERTY(
+ bool userVerificationEnabled READ userVerificationEnabled NOTIFY userStatusChanged)
+ Q_PROPERTY(bool isSelf READ isSelf CONSTANT)
public:
UserProfile(QString roomid,
QString userid,
@@ -96,6 +99,8 @@ public:
QString displayName();
QString avatarUrl();
bool getUserStatus();
+ bool userVerificationEnabled() const;
+ bool isSelf() const;
Q_INVOKABLE void verify(QString device = "");
Q_INVOKABLE void unverify(QString device = "");
@@ -112,6 +117,7 @@ private:
QString roomid_, userid_;
DeviceInfoModel deviceList_;
bool isUserVerified = false;
+ bool hasMasterKey = false;
TimelineViewManager *manager;
TimelineModel *model;
};
|