summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorNicolas Werner <nicolas.werner@hotmail.de>2021-11-01 22:20:15 +0100
committerNicolas Werner <nicolas.werner@hotmail.de>2021-11-01 22:20:15 +0100
commit2aabe9dcacbef4f753761f6df840da4292561d11 (patch)
tree283b6ee93d7f3c9d4d670e4de08ccfad0bfb0160 /src
parentSome people consider Nheko not an AAAAA title (diff)
downloadnheko-2aabe9dcacbef4f753761f6df840da4292561d11.tar.xz
Prompt user when there are unverified devices
Diffstat (limited to 'src')
-rw-r--r--src/Cache.cpp10
-rw-r--r--src/Cache_p.h2
-rw-r--r--src/encryption/DeviceVerificationFlow.h2
-rw-r--r--src/encryption/SelfVerificationStatus.cpp20
-rw-r--r--src/ui/Theme.cpp3
-rw-r--r--src/ui/Theme.h4
6 files changed, 32 insertions, 9 deletions
diff --git a/src/Cache.cpp b/src/Cache.cpp

index 5b77a9d4..45cc642d 100644 --- a/src/Cache.cpp +++ b/src/Cache.cpp
@@ -208,8 +208,7 @@ Cache::Cache(const QString &userId, QObject *parent) [this](const std::string &u) { if (u == localUserId_.toStdString()) { auto status = verificationStatus(u); - if (status.unverified_device_count || !status.user_verified) - emit selfUnverified(); + emit selfVerificationStatusChanged(); } }, Qt::QueuedConnection); @@ -4265,6 +4264,7 @@ Cache::markDeviceVerified(const std::string &user_id, const std::string &key) std::unique_lock<std::mutex> lock(verification_storage.verification_storage_mtx); if (user_id == local_user) { std::swap(tmp, verification_storage.status); + verification_storage.status.clear(); } else { verification_storage.status.erase(user_id); } @@ -4274,9 +4274,8 @@ Cache::markDeviceVerified(const std::string &user_id, const std::string &key) (void)status; emit verificationStatusChanged(user); } - } else { - emit verificationStatusChanged(user_id); } + emit verificationStatusChanged(user_id); } void @@ -4316,9 +4315,8 @@ Cache::markDeviceUnverified(const std::string &user_id, const std::string &key) (void)status; emit verificationStatusChanged(user); } - } else { - emit verificationStatusChanged(user_id); } + emit verificationStatusChanged(user_id); } VerificationStatus diff --git a/src/Cache_p.h b/src/Cache_p.h
index f7db77d4..651d73d7 100644 --- a/src/Cache_p.h +++ b/src/Cache_p.h
@@ -310,7 +310,7 @@ signals: void removeNotification(const QString &room_id, const QString &event_id); void userKeysUpdate(const std::string &sync_token, const mtx::responses::QueryKeys &keyQuery); void verificationStatusChanged(const std::string &userid); - void selfUnverified(); + void selfVerificationStatusChanged(); void secretChanged(const std::string name); private: diff --git a/src/encryption/DeviceVerificationFlow.h b/src/encryption/DeviceVerificationFlow.h
index 55713def..537adf31 100644 --- a/src/encryption/DeviceVerificationFlow.h +++ b/src/encryption/DeviceVerificationFlow.h
@@ -69,6 +69,7 @@ class DeviceVerificationFlow : public QObject Q_PROPERTY(std::vector<int> sasList READ getSasList CONSTANT) Q_PROPERTY(bool isDeviceVerification READ isDeviceVerification CONSTANT) Q_PROPERTY(bool isSelfVerification READ isSelfVerification CONSTANT) + Q_PROPERTY(bool isMultiDeviceVerification READ isMultiDeviceVerification CONSTANT) public: enum State @@ -139,6 +140,7 @@ public: return this->type == DeviceVerificationFlow::Type::ToDevice; } bool isSelfVerification() const; + bool isMultiDeviceVerification() const { return deviceIds.size() > 1; } void callback_fn(const UserKeyCache &res, mtx::http::RequestErr err, std::string user_id); diff --git a/src/encryption/SelfVerificationStatus.cpp b/src/encryption/SelfVerificationStatus.cpp
index d4be4442..ebb6b548 100644 --- a/src/encryption/SelfVerificationStatus.cpp +++ b/src/encryption/SelfVerificationStatus.cpp
@@ -20,7 +20,7 @@ SelfVerificationStatus::SelfVerificationStatus(QObject *o) { connect(MainWindow::instance(), &MainWindow::reload, this, [this] { connect(cache::client(), - &Cache::selfUnverified, + &Cache::selfVerificationStatusChanged, this, &SelfVerificationStatus::invalidate, Qt::UniqueConnection); @@ -233,6 +233,24 @@ void SelfVerificationStatus::verifyUnverifiedDevices() { nhlog::db()->info("Clicked verify unverified devices"); + const auto this_user = http::client()->user_id().to_string(); + + auto keys = cache::client()->userKeys(this_user); + auto verif = cache::client()->verificationStatus(this_user); + + if (!keys) + return; + + std::vector<QString> devices; + for (const auto &[device, keys] : keys->device_keys) { + (void)keys; + if (!verif.verified_devices.count(device)) + devices.push_back(QString::fromStdString(device)); + } + + if (!devices.empty()) + ChatPage::instance()->timelineManager()->verificationManager()->verifyOneOfDevices( + QString::fromStdString(this_user), std::move(devices)); } void diff --git a/src/ui/Theme.cpp b/src/ui/Theme.cpp
index d6f0b72f..d7c92fb8 100644 --- a/src/ui/Theme.cpp +++ b/src/ui/Theme.cpp
@@ -62,13 +62,16 @@ Theme::Theme(std::string_view theme) sidebarBackground_ = QColor("#233649"); alternateButton_ = QColor("#ccc"); red_ = QColor("#a82353"); + orange_ = QColor("#fcbe05"); } else if (theme == "dark") { sidebarBackground_ = QColor("#2d3139"); alternateButton_ = QColor("#414A59"); red_ = QColor("#a82353"); + orange_ = QColor("#fcc53a"); } else { sidebarBackground_ = p.window().color(); alternateButton_ = p.dark().color(); red_ = QColor("red"); + orange_ = QColor("orange"); } } diff --git a/src/ui/Theme.h b/src/ui/Theme.h
index f3e7c287..4fef897d 100644 --- a/src/ui/Theme.h +++ b/src/ui/Theme.h
@@ -62,6 +62,7 @@ class Theme : public QPalette Q_PROPERTY(QColor alternateButton READ alternateButton CONSTANT) Q_PROPERTY(QColor separator READ separator CONSTANT) Q_PROPERTY(QColor red READ red CONSTANT) + Q_PROPERTY(QColor orange READ orange CONSTANT) public: Theme() {} explicit Theme(std::string_view theme); @@ -71,7 +72,8 @@ public: QColor alternateButton() const { return alternateButton_; } QColor separator() const { return separator_; } QColor red() const { return red_; } + QColor orange() const { return orange_; } private: - QColor sidebarBackground_, separator_, red_, alternateButton_; + QColor sidebarBackground_, separator_, red_, orange_, alternateButton_; };