summary refs log tree commit diff
path: root/src/timeline/TimelineViewManager.cpp
diff options
context:
space:
mode:
authorCH Chethan Reddy <40890937+Chethan2k1@users.noreply.github.com>2020-06-26 15:10:37 +0530
committerCH Chethan Reddy <40890937+Chethan2k1@users.noreply.github.com>2020-07-30 22:10:27 +0530
commitffa61095b8be7c61c3b4cdd693e59239ab668516 (patch)
tree4223b877e5e55d484f443ed4d9dd4c0aaaf7abb3 /src/timeline/TimelineViewManager.cpp
parentAdd some Userprofile buttons (diff)
downloadnheko-ffa61095b8be7c61c3b4cdd693e59239ab668516.tar.xz
Error Handling and some fixes
Diffstat (limited to 'src/timeline/TimelineViewManager.cpp')
-rw-r--r--src/timeline/TimelineViewManager.cpp45
1 files changed, 40 insertions, 5 deletions
diff --git a/src/timeline/TimelineViewManager.cpp b/src/timeline/TimelineViewManager.cpp

index 14c66951..0b732232 100644 --- a/src/timeline/TimelineViewManager.cpp +++ b/src/timeline/TimelineViewManager.cpp
@@ -184,6 +184,9 @@ TimelineViewManager::TimelineViewManager(QSharedPointer<UserSettings> userSettin QString::fromStdString(msg.content.transaction_id), QString::fromStdString(msg.sender), QString::fromStdString(msg.content.from_device)); + } else { + flow->cancelVerification( + DeviceVerificationFlow::Error::UnknownMethod); } } }); @@ -197,11 +200,43 @@ TimelineViewManager::TimelineViewManager(QSharedPointer<UserSettings> userSettin auto flow = new DeviceVerificationFlow(this); flow->canonical_json = nlohmann::json(msg.content); if (!(this->dvList->exist(QString::fromStdString(msg.content.transaction_id)))) { - emit newDeviceVerificationRequest( - std::move(flow), - QString::fromStdString(msg.content.transaction_id), - QString::fromStdString(msg.sender), - QString::fromStdString(msg.content.from_device)); + if ((std::find(msg.content.key_agreement_protocols.begin(), + msg.content.key_agreement_protocols.end(), + "curve25519-hkdf-sha256") != + msg.content.key_agreement_protocols.end()) && + (std::find(msg.content.hashes.begin(), + msg.content.hashes.end(), + "sha256") != msg.content.hashes.end()) && + (std::find(msg.content.message_authentication_codes.begin(), + msg.content.message_authentication_codes.end(), + "hmac-sha256") != + msg.content.message_authentication_codes.end())) { + if (std::find(msg.content.short_authentication_string.begin(), + msg.content.short_authentication_string.end(), + mtx::events::msg::SASMethods::Emoji) != + msg.content.short_authentication_string.end()) { + flow->setMethod(DeviceVerificationFlow::Method::Emoji); + } else if (std::find( + msg.content.short_authentication_string.begin(), + msg.content.short_authentication_string.end(), + mtx::events::msg::SASMethods::Decimal) != + msg.content.short_authentication_string.end()) { + flow->setMethod(DeviceVerificationFlow::Method::Decimal); + } else { + flow->cancelVerification( + DeviceVerificationFlow::Error::UnknownMethod); + return; + } + emit newDeviceVerificationRequest( + std::move(flow), + QString::fromStdString(msg.content.transaction_id), + QString::fromStdString(msg.sender), + QString::fromStdString(msg.content.from_device)); + flow->canonical_json = nlohmann::json(msg.content); + } else { + flow->cancelVerification( + DeviceVerificationFlow::Error::UnknownMethod); + } } }); }