summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorCH Chethan Reddy <40890937+Chethan2k1@users.noreply.github.com>2020-09-03 09:29:32 +0530
committerCH Chethan Reddy <40890937+Chethan2k1@users.noreply.github.com>2020-09-03 09:37:16 +0530
commit5358854de37fcf51c5d24f022b231da17f3b85c7 (patch)
tree50cd2c5aecc872b850ac07d2080d7fa223c4da5c /src
parentFix catch by value warning (diff)
downloadnheko-5358854de37fcf51c5d24f022b231da17f3b85c7.tar.xz
Add support for Encrypted to-device verification messages
Diffstat (limited to 'src')
-rw-r--r--src/DeviceVerificationFlow.cpp2
-rw-r--r--src/Olm.cpp45
-rw-r--r--src/timeline/TimelineModel.cpp2
3 files changed, 47 insertions, 2 deletions
diff --git a/src/DeviceVerificationFlow.cpp b/src/DeviceVerificationFlow.cpp

index 00c9602c..37866716 100644 --- a/src/DeviceVerificationFlow.cpp +++ b/src/DeviceVerificationFlow.cpp
@@ -165,7 +165,7 @@ DeviceVerificationFlow::DeviceVerificationFlow(QObject *, } if (this->method == DeviceVerificationFlow::Method::Emoji) { - std::cout<<info<<std::endl; + std::cout << info << std::endl; this->sasList = this->sas->generate_bytes_emoji(info); } else if (this->method == DeviceVerificationFlow::Method::Decimal) { this->sasList = this->sas->generate_bytes_decimal(info); diff --git a/src/Olm.cpp b/src/Olm.cpp
index 74af61dd..9e997801 100644 --- a/src/Olm.cpp +++ b/src/Olm.cpp
@@ -139,6 +139,51 @@ handle_olm_message(const OlmMessage &msg) auto payload = try_olm_decryption(msg.sender_key, cipher.second); if (!payload.is_null()) { + std::string msg_type = payload["type"]; + + if (msg_type == to_string(mtx::events::EventType::KeyVerificationAccept)) { + ChatPage::instance()->recievedDeviceVerificationAccept( + payload["content"]); + return; + } else if (msg_type == + to_string(mtx::events::EventType::KeyVerificationRequest)) { + ChatPage::instance()->recievedDeviceVerificationRequest( + payload["content"], payload["sender"]); + return; + } else if (msg_type == + to_string(mtx::events::EventType::KeyVerificationCancel)) { + ChatPage::instance()->recievedDeviceVerificationCancel( + payload["content"]); + return; + } else if (msg_type == + to_string(mtx::events::EventType::KeyVerificationKey)) { + ChatPage::instance()->recievedDeviceVerificationKey( + payload["content"]); + return; + } else if (msg_type == + to_string(mtx::events::EventType::KeyVerificationMac)) { + ChatPage::instance()->recievedDeviceVerificationMac( + payload["content"]); + return; + } else if (msg_type == + to_string(mtx::events::EventType::KeyVerificationStart)) { + ChatPage::instance()->recievedDeviceVerificationStart( + payload["content"], payload["sender"]); + return; + } else if (msg_type == + to_string(mtx::events::EventType::KeyVerificationReady)) { + ChatPage::instance()->recievedDeviceVerificationReady( + payload["content"]); + return; + } else if (msg_type == + to_string(mtx::events::EventType::KeyVerificationDone)) { + ChatPage::instance()->recievedDeviceVerificationDone( + payload["content"]); + return; + } + } + + if (!payload.is_null()) { nhlog::crypto()->debug("decrypted olm payload: {}", payload.dump(2)); create_inbound_megolm_session(msg.sender, msg.sender_key, payload); return; diff --git a/src/timeline/TimelineModel.cpp b/src/timeline/TimelineModel.cpp
index aea2645a..8f0e470e 100644 --- a/src/timeline/TimelineModel.cpp +++ b/src/timeline/TimelineModel.cpp
@@ -879,7 +879,7 @@ TimelineModel::sendEncryptedMessage(mtx::events::RoomEvent<T> msg, mtx::events:: using namespace mtx::identifiers; json doc = {{"type", mtx::events::to_string(eventType)}, - {"content", msg.content}, + {"content", json(msg.content)}, {"room_id", room_id}}; try {