Handle Device Verification related to_device messages

This commit is contained in:
Chethan2k1 2020-06-09 22:06:41 +05:30 committed by CH Chethan Reddy
parent cd5dd0e39b
commit 1eb162cb6f
7 changed files with 153 additions and 14 deletions

View file

@ -1,11 +1,15 @@
#include <QObject>
#include <variant>
#include "Olm.h"
#include "Cache.h"
#include "ChatPage.h"
#include "Logging.h"
#include "MatrixClient.h"
#include "Utils.h"
#include <DeviceVerificationFlow.h>
#include <iostream> // only for debugging
static const std::string STORAGE_SECRET_KEY("secret");
constexpr auto MEGOLM_ALGO = "m.megolm.v1.aes-sha2";
@ -27,7 +31,6 @@ handle_to_device_messages(const std::vector<mtx::events::collections::DeviceEven
{
if (msgs.empty())
return;
nhlog::crypto()->info("received {} to_device messages", msgs.size());
nlohmann::json j_msg;
@ -74,6 +77,24 @@ handle_to_device_messages(const std::vector<mtx::events::collections::DeviceEven
e.what(),
j_msg.dump(2));
}
} else if (msg_type == to_string(mtx::events::EventType::KeyVerificationAccept)) {
ChatPage::instance()->recievedDeviceVerificationAccept(msg);
std::cout << j_msg.dump(2) << std::endl;
} else if (msg_type == to_string(mtx::events::EventType::KeyVerificationRequest)) {
ChatPage::instance()->recievedDeviceVerificationRequest(msg);
std::cout << j_msg.dump(2) << std::endl;
} else if (msg_type == to_string(mtx::events::EventType::KeyVerificationCancel)) {
ChatPage::instance()->recievedDeviceVerificationCancel(msg);
std::cout << j_msg.dump(2) << std::endl;
} else if (msg_type == to_string(mtx::events::EventType::KeyVerificationKey)) {
ChatPage::instance()->recievedDeviceVerificationKey(msg);
std::cout << j_msg.dump(2) << std::endl;
} else if (msg_type == to_string(mtx::events::EventType::KeyVerificationMac)) {
ChatPage::instance()->recievedDeviceVerificationMac(msg);
std::cout << j_msg.dump(2) << std::endl;
} else if (msg_type == to_string(mtx::events::EventType::KeyVerificationStart)) {
ChatPage::instance()->recievedDeviceVerificationStart(msg);
std::cout << j_msg.dump(2) << std::endl;
} else {
nhlog::crypto()->warn("unhandled event: {}", j_msg.dump(2));
}