summary refs log tree commit diff
path: root/src/encryption/SelfVerificationStatus.cpp
diff options
context:
space:
mode:
authorNicolas Werner <nicolas.werner@hotmail.de>2021-11-08 16:26:16 +0100
committerNicolas Werner <nicolas.werner@hotmail.de>2021-11-08 17:01:22 +0100
commitff560a09f57964ac97efffe9ee2a6be8dea527b7 (patch)
tree176345b64e0e672bd5d2d6e5612446054f9a7207 /src/encryption/SelfVerificationStatus.cpp
parentTranslated using Weblate (French) (diff)
downloadnheko-ff560a09f57964ac97efffe9ee2a6be8dea527b7.tar.xz
Improve fetching of device keys after login
Diffstat (limited to 'src/encryption/SelfVerificationStatus.cpp')
-rw-r--r--src/encryption/SelfVerificationStatus.cpp17
1 files changed, 14 insertions, 3 deletions
diff --git a/src/encryption/SelfVerificationStatus.cpp b/src/encryption/SelfVerificationStatus.cpp

index 3ddbc7e6..c4f4f196 100644 --- a/src/encryption/SelfVerificationStatus.cpp +++ b/src/encryption/SelfVerificationStatus.cpp
@@ -4,6 +4,8 @@ #include "SelfVerificationStatus.h" +#include <QApplication> + #include "Cache_p.h" #include "ChatPage.h" #include "Logging.h" @@ -18,12 +20,13 @@ SelfVerificationStatus::SelfVerificationStatus(QObject *o) : QObject(o) { - connect(MainWindow::instance(), &MainWindow::reload, this, [this] { + connect(ChatPage::instance(), &ChatPage::contentLoaded, this, [this] { connect(cache::client(), &Cache::selfVerificationStatusChanged, this, &SelfVerificationStatus::invalidate, Qt::UniqueConnection); + cache::client()->markUserKeysOutOfDate({http::client()->user_id().to_string()}); }); } @@ -268,8 +271,16 @@ SelfVerificationStatus::invalidate() auto keys = cache::client()->userKeys(http::client()->user_id().to_string()); if (!keys || keys->device_keys.find(http::client()->device_id()) == keys->device_keys.end()) { - QTimer::singleShot(500, [] { - cache::client()->markUserKeysOutOfDate({http::client()->user_id().to_string()}); + if (keys && (keys->seen_device_ids.count(http::client()->device_id()) || + keys->seen_device_keys.count(olm::client()->identity_keys().curve25519))) { + emit ChatPage::instance()->dropToLoginPageCb( + tr("Identity key changed. This breaks E2EE, so logging out.")); + return; + } + + cache::client()->markUserKeysOutOfDate({http::client()->user_id().to_string()}); + + QTimer::singleShot(1'000, [] { cache::client()->query_keys(http::client()->user_id().to_string(), [](const UserKeyCache &, mtx::http::RequestErr) {}); });