Small Fixes

This commit is contained in:
CH Chethan Reddy 2020-08-29 13:37:51 +05:30
parent 19cfd08a55
commit 0d1dd29b19
5 changed files with 27 additions and 9 deletions

View file

@ -579,7 +579,6 @@ ApplicationWindow {
onClicked: {
dialog.close();
deviceVerificationList.remove(flow.tranId);
delete flow;
}
}
}

View file

@ -52,8 +52,6 @@
#include "blurhash.hpp"
#include <iostream> // only for debugging
// TODO: Needs to be updated with an actual secret.
static const std::string STORAGE_SECRET_KEY("secret");
@ -1471,7 +1469,6 @@ ChatPage::query_keys(
static_cast<int>(err->status_code));
return;
}
std::cout << "Over here " << user_id << std::endl;
cache::setUserCache(std::move(user_id),
std::move(UserCache{res, true}));
cb(res, err);

View file

@ -7,6 +7,7 @@
#include <QDateTime>
#include <QTimer>
#include <iostream>
static constexpr int TIMEOUT = 2 * 60 * 1000; // 2 minutes
@ -75,7 +76,14 @@ DeviceVerificationFlow::DeviceVerificationFlow(QObject *,
DeviceVerificationFlow::Error::UnknownMethod);
return;
}
if (!sender)
this->canonical_json = nlohmann::json(msg);
else {
if (utils::localUser().toStdString() <
this->toClient.to_string()) {
this->canonical_json = nlohmann::json(msg);
}
}
this->acceptVerificationRequest();
} else {
this->cancelVerification(DeviceVerificationFlow::Error::UnknownMethod);
@ -124,6 +132,7 @@ DeviceVerificationFlow::DeviceVerificationFlow(QObject *,
if (msg.relates_to.value().event_id != this->relation.event_id)
return;
}
this->deleteLater();
emit verificationCanceled();
});
@ -226,6 +235,11 @@ DeviceVerificationFlow::DeviceVerificationFlow(QObject *,
&ChatPage::recievedDeviceVerificationReady,
this,
[this](const mtx::events::msg::KeyVerificationReady &msg) {
if (!sender) {
this->deleteLater();
emit verificationCanceled();
return;
}
if (msg.transaction_id.has_value()) {
if (msg.transaction_id.value() != this->transaction_id)
return;

View file

@ -298,6 +298,13 @@ EventStore::handleSync(const mtx::responses::Timeline &events)
msg->content, msg->sender);
}
}
// only the key.verification.ready sent by localuser's other device is of
// significance as it is used for detecting accepted request
if (auto msg = std::get_if<
mtx::events::RoomEvent<mtx::events::msg::KeyVerificationReady>>(
event)) {
ChatPage::instance()->recievedDeviceVerificationReady(msg->content);
}
}
}

View file

@ -161,16 +161,17 @@ UserProfile::fetchDeviceList(const QString &userID)
for (auto sign_key : luk.value().keys) {
// checking if the signatures are empty as "at" could
// cause exceptions
if (!mk.value().signatures.empty()) {
auto signs =
mk.value().signatures.at(local_user_id);
auto signs = mk->signatures;
if (!signs.empty() &&
signs.find(local_user_id) != signs.end()) {
auto sign = signs.at(local_user_id);
try {
isUserVerified =
isUserVerified ||
(olm::client()->ed25519_verify_sig(
sign_key.second,
json(mk.value()),
signs.at(sign_key.first)));
sign.at(sign_key.first)));
} catch (std::out_of_range) {
isUserVerified =
isUserVerified || false;