Add Room Verification Messages

This commit is contained in:
CH Chethan Reddy 2020-07-29 03:25:47 +05:30
parent 1fcd768f88
commit 3635c185e9
9 changed files with 245 additions and 49 deletions

View File

@ -106,13 +106,20 @@ Page {
} }
Connections { Connections {
target: TimelineManager target: TimelineManager
function onNewDeviceVerificationRequest(flow,transactionId,userId,deviceId) { function onNewDeviceVerificationRequest(flow,transactionId,userId,deviceId,isRequest) {
flow.userId = userId; flow.userId = userId;
flow.sender = false; flow.sender = false;
flow.deviceId = deviceId; flow.deviceId = deviceId;
flow.tranId = transactionId; switch(flow.type){
deviceVerificationList.add(flow.tranId); case DeviceVerificationFlow.ToDevice:
var dialog = deviceVerificationDialog.createObject(timelineRoot, {flow: flow}); flow.tranId = transactionId;
deviceVerificationList.add(flow.tranId);
break;
case DeviceVerificationFlow.RoomMsg:
deviceVerificationList.add(flow.tranId);
break;
}
var dialog = deviceVerificationDialog.createObject(timelineRoot, {flow: flow,isRequest = isRequest});
dialog.show(); dialog.show();
} }
} }

View File

@ -23,6 +23,8 @@ ApplicationWindow {
} }
property var flow property var flow
property bool isRequest
Connections { Connections {
target: flow target: flow
onVerificationCanceled: stack.replace(partnerAborted) onVerificationCanceled: stack.replace(partnerAborted)
@ -155,7 +157,10 @@ ApplicationWindow {
horizontalAlignment: Text.AlignHCenter horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter verticalAlignment: Text.AlignVCenter
} }
onClicked: { stack.replace(awaitingVerificationRequestAccept); flow.acceptVerificationRequest(); } onClicked: {
stack.replace(awaitingVerificationRequestAccept);
isRequest?flow.sendVerificationReady():flow.acceptVerificationRequest();
}
} }
} }
} }

View File

@ -52,6 +52,7 @@ class TopRoomBar;
class UserInfoWidget; class UserInfoWidget;
class UserSettings; class UserSettings;
class NotificationsManager; class NotificationsManager;
class TimelineModel;
constexpr int CONSENSUS_TIMEOUT = 1000; constexpr int CONSENSUS_TIMEOUT = 1000;
constexpr int SHOW_CONTENT_TIMEOUT = 3000; constexpr int SHOW_CONTENT_TIMEOUT = 3000;
@ -171,6 +172,9 @@ signals:
void recievedDeviceVerificationRequest( void recievedDeviceVerificationRequest(
const mtx::events::msg::KeyVerificationRequest &message, const mtx::events::msg::KeyVerificationRequest &message,
std::string sender); std::string sender);
void recievedRoomDeviceVerificationRequest(
const mtx::events::RoomEvent<mtx::events::msg::KeyVerificationRequest> &message,
TimelineModel *model);
void recievedDeviceVerificationCancel( void recievedDeviceVerificationCancel(
const mtx::events::msg::KeyVerificationCancel &message); const mtx::events::msg::KeyVerificationCancel &message);
void recievedDeviceVerificationKey(const mtx::events::msg::KeyVerificationKey &message); void recievedDeviceVerificationKey(const mtx::events::msg::KeyVerificationKey &message);

View File

@ -1,7 +1,9 @@
#include "DeviceVerificationFlow.h" #include "DeviceVerificationFlow.h"
#include "Cache.h" #include "Cache.h"
#include "ChatPage.h" #include "ChatPage.h"
#include "Logging.h" #include "Logging.h"
#include "timeline/TimelineModel.h"
#include <QDateTime> #include <QDateTime>
#include <QTimer> #include <QTimer>
@ -12,12 +14,14 @@ static constexpr int TIMEOUT = 2 * 60 * 1000; // 2 minutes
namespace msgs = mtx::events::msg; namespace msgs = mtx::events::msg;
DeviceVerificationFlow::DeviceVerificationFlow(QObject *, DeviceVerificationFlow::Type) DeviceVerificationFlow::DeviceVerificationFlow(QObject *, DeviceVerificationFlow::Type flow_type)
: type(flow_type)
{ {
timeout = new QTimer(this); timeout = new QTimer(this);
timeout->setSingleShot(true); timeout->setSingleShot(true);
this->sas = olm::client()->sas_init(); this->sas = olm::client()->sas_init();
this->isMacVerified = false; this->isMacVerified = false;
connect(timeout, &QTimer::timeout, this, [this]() { connect(timeout, &QTimer::timeout, this, [this]() {
emit timedout(); emit timedout();
this->cancelVerification(DeviceVerificationFlow::Error::Timeout); this->cancelVerification(DeviceVerificationFlow::Error::Timeout);
@ -267,6 +271,12 @@ DeviceVerificationFlow::getMethod()
return this->method; return this->method;
} }
DeviceVerificationFlow::Type
DeviceVerificationFlow::getType()
{
return this->type;
}
bool bool
DeviceVerificationFlow::getSender() DeviceVerificationFlow::getSender()
{ {
@ -279,6 +289,12 @@ DeviceVerificationFlow::getSasList()
return this->sasList; return this->sasList;
} }
void
DeviceVerificationFlow::setModel(TimelineModel *&model)
{
this->model_ = model;
}
void void
DeviceVerificationFlow::setTransactionId(QString transaction_id_) DeviceVerificationFlow::setTransactionId(QString transaction_id_)
{ {
@ -318,6 +334,12 @@ DeviceVerificationFlow::setMethod(DeviceVerificationFlow::Method method_)
this->method = method_; this->method = method_;
} }
void
DeviceVerificationFlow::setType(Type type)
{
this->type = type;
}
void void
DeviceVerificationFlow::setSender(bool sender_) DeviceVerificationFlow::setSender(bool sender_)
{ {
@ -328,6 +350,13 @@ DeviceVerificationFlow::setSender(bool sender_)
this->relation.in_reply_to.event_id = http::client()->generate_txn_id(); this->relation.in_reply_to.event_id = http::client()->generate_txn_id();
} }
void
DeviceVerificationFlow::setEventId(std::string event_id)
{
this->relation.in_reply_to.event_id = event_id;
this->transaction_id = event_id;
}
//! accepts a verification //! accepts a verification
void void
DeviceVerificationFlow::acceptVerificationRequest() DeviceVerificationFlow::acceptVerificationRequest()
@ -361,8 +390,9 @@ DeviceVerificationFlow::acceptVerificationRequest()
err->matrix_error.error, err->matrix_error.error,
static_cast<int>(err->status_code)); static_cast<int>(err->status_code));
}); });
} else if (this->type == DeviceVerificationFlow::Type::RoomMsg) { } else if (this->type == DeviceVerificationFlow::Type::RoomMsg && model_.has_value()) {
req.relates_to = this->relation; req.relates_to = this->relation;
(model_.value())->sendMessage(req);
} }
} }
//! responds verification request //! responds verification request
@ -389,8 +419,9 @@ DeviceVerificationFlow::sendVerificationReady()
err->matrix_error.error, err->matrix_error.error,
static_cast<int>(err->status_code)); static_cast<int>(err->status_code));
}); });
} else if (this->type == DeviceVerificationFlow::Type::RoomMsg) { } else if (this->type == DeviceVerificationFlow::Type::RoomMsg && model_.has_value()) {
req.relates_to = this->relation; req.relates_to = this->relation;
(model_.value())->sendMessage(req);
} }
} }
//! accepts a verification //! accepts a verification
@ -414,8 +445,9 @@ DeviceVerificationFlow::sendVerificationDone()
err->matrix_error.error, err->matrix_error.error,
static_cast<int>(err->status_code)); static_cast<int>(err->status_code));
}); });
} else if (this->type == DeviceVerificationFlow::Type::RoomMsg) { } else if (this->type == DeviceVerificationFlow::Type::RoomMsg && model_.has_value()) {
req.relates_to = this->relation; req.relates_to = this->relation;
(model_.value())->sendMessage(req);
} }
} }
//! starts the verification flow //! starts the verification flow
@ -448,8 +480,9 @@ DeviceVerificationFlow::startVerificationRequest()
err->matrix_error.error, err->matrix_error.error,
static_cast<int>(err->status_code)); static_cast<int>(err->status_code));
}); });
} else if (this->type == DeviceVerificationFlow::Type::RoomMsg) { } else if (this->type == DeviceVerificationFlow::Type::RoomMsg && model_.has_value()) {
req.relates_to = this->relation; req.relates_to = this->relation;
(model_.value())->sendMessage(req);
} }
} }
//! sends a verification request //! sends a verification request
@ -481,8 +514,8 @@ DeviceVerificationFlow::sendVerificationRequest()
err->matrix_error.error, err->matrix_error.error,
static_cast<int>(err->status_code)); static_cast<int>(err->status_code));
}); });
} else if (this->type == DeviceVerificationFlow::Type::RoomMsg) { } else if (this->type == DeviceVerificationFlow::Type::RoomMsg && model_.has_value()) {
std::cout << "lulz" << std::endl; (model_.value())->sendMessage(req);
} }
} }
//! cancels a verification flow //! cancels a verification flow
@ -531,8 +564,9 @@ DeviceVerificationFlow::cancelVerification(DeviceVerificationFlow::Error error_c
this->deleteLater(); this->deleteLater();
}); });
} else if (this->type == DeviceVerificationFlow::Type::RoomMsg) { } else if (this->type == DeviceVerificationFlow::Type::RoomMsg && model_.has_value()) {
req.relates_to = this->relation; req.relates_to = this->relation;
(model_.value())->sendMessage(req);
} }
// TODO : Handle Blocking user better // TODO : Handle Blocking user better
@ -570,8 +604,9 @@ DeviceVerificationFlow::sendVerificationKey()
err->matrix_error.error, err->matrix_error.error,
static_cast<int>(err->status_code)); static_cast<int>(err->status_code));
}); });
} else if (this->type == DeviceVerificationFlow::Type::RoomMsg) { } else if (this->type == DeviceVerificationFlow::Type::RoomMsg && model_.has_value()) {
req.relates_to = this->relation; req.relates_to = this->relation;
(model_.value())->sendMessage(req);
} }
} }
//! sends the mac of the keys //! sends the mac of the keys
@ -618,8 +653,9 @@ DeviceVerificationFlow::sendVerificationMac()
else else
this->isMacVerified = true; this->isMacVerified = true;
}); });
} else if (this->type == DeviceVerificationFlow::Type::RoomMsg) { } else if (this->type == DeviceVerificationFlow::Type::RoomMsg && model_.has_value()) {
req.relates_to = this->relation; req.relates_to = this->relation;
(model_.value())->sendMessage(req);
} }
} }
//! Completes the verification flow //! Completes the verification flow

View File

@ -10,6 +10,8 @@ class QTimer;
using sas_ptr = std::unique_ptr<mtx::crypto::SAS>; using sas_ptr = std::unique_ptr<mtx::crypto::SAS>;
struct TimelineModel;
class DeviceVerificationFlow : public QObject class DeviceVerificationFlow : public QObject
{ {
Q_OBJECT Q_OBJECT
@ -19,6 +21,7 @@ class DeviceVerificationFlow : public QObject
Q_PROPERTY(QString userId READ getUserId WRITE setUserId) Q_PROPERTY(QString userId READ getUserId WRITE setUserId)
Q_PROPERTY(QString deviceId READ getDeviceId WRITE setDeviceId) Q_PROPERTY(QString deviceId READ getDeviceId WRITE setDeviceId)
Q_PROPERTY(Method method READ getMethod WRITE setMethod) Q_PROPERTY(Method method READ getMethod WRITE setMethod)
Q_PROPERTY(Type type READ getType WRITE setType)
Q_PROPERTY(std::vector<int> sasList READ getSasList CONSTANT) Q_PROPERTY(std::vector<int> sasList READ getSasList CONSTANT)
public: public:
@ -27,6 +30,7 @@ public:
ToDevice, ToDevice,
RoomMsg RoomMsg
}; };
Q_ENUM(Type)
enum Method enum Method
{ {
@ -49,17 +53,24 @@ public:
DeviceVerificationFlow( DeviceVerificationFlow(
QObject *parent = nullptr, QObject *parent = nullptr,
DeviceVerificationFlow::Type = DeviceVerificationFlow::Type::ToDevice); DeviceVerificationFlow::Type = DeviceVerificationFlow::Type::ToDevice);
// getters
QString getTransactionId(); QString getTransactionId();
QString getUserId(); QString getUserId();
QString getDeviceId(); QString getDeviceId();
Method getMethod(); Method getMethod();
Type getType();
std::vector<int> getSasList(); std::vector<int> getSasList();
void setTransactionId(QString transaction_id_);
bool getSender(); bool getSender();
// setters
void setModel(TimelineModel *&model);
void setTransactionId(QString transaction_id_);
void setUserId(QString userID); void setUserId(QString userID);
void setDeviceId(QString deviceID); void setDeviceId(QString deviceID);
void setMethod(Method method_); void setMethod(Method method_);
void setType(Type type_);
void setSender(bool sender_); void setSender(bool sender_);
void setEventId(std::string event_id);
void callback_fn(const mtx::responses::QueryKeys &res, void callback_fn(const mtx::responses::QueryKeys &res,
mtx::http::RequestErr err, mtx::http::RequestErr err,
std::string user_id); std::string user_id);
@ -96,20 +107,25 @@ signals:
void refreshProfile(); void refreshProfile();
private: private:
// general
QString userId; QString userId;
QString deviceId; QString deviceId;
Method method; Method method;
Type type; Type type;
bool sender; bool sender;
QTimer *timeout = nullptr; QTimer *timeout = nullptr;
sas_ptr sas; sas_ptr sas;
bool isMacVerified = false; bool isMacVerified = false;
std::string mac_method; std::string mac_method;
std::string transaction_id;
std::string commitment; std::string commitment;
mtx::identifiers::User toClient; mtx::identifiers::User toClient;
std::vector<int> sasList; std::vector<int> sasList;
std::map<std::string, std::string> device_keys; std::map<std::string, std::string> device_keys;
// for to_device messages
std::string transaction_id;
// for room messages
std::optional<std::string> room_id;
std::optional<std::string> event_id;
std::optional<TimelineModel *> model_;
mtx::common::ReplyRelatesTo relation; mtx::common::ReplyRelatesTo relation;
}; };

View File

@ -138,6 +138,11 @@ struct RoomEventType
{ {
return qml_mtx_events::EventType::KeyVerificationAccept; return qml_mtx_events::EventType::KeyVerificationAccept;
} }
qml_mtx_events::EventType operator()(
const mtx::events::Event<mtx::events::msg::KeyVerificationReady> &)
{
return qml_mtx_events::EventType::KeyVerificationReady;
}
qml_mtx_events::EventType operator()( qml_mtx_events::EventType operator()(
const mtx::events::Event<mtx::events::msg::KeyVerificationCancel> &) const mtx::events::Event<mtx::events::msg::KeyVerificationCancel> &)
{ {
@ -637,30 +642,6 @@ TimelineModel::internalAddEvents(
continue; continue;
} }
if (std::get_if<mtx::events::RoomEvent<mtx::events::msg::KeyVerificationRequest>>(
&e)) {
std::cout << "got a request" << std::endl;
}
if (auto cancelVerification =
std::get_if<mtx::events::RoomEvent<mtx::events::msg::KeyVerificationCancel>>(
&e)) {
std::cout<<"it is happening"<<std::endl;
if (cancelVerification->content.relates_to.has_value()) {
QString event_id = QString::fromStdString(
cancelVerification->content.relates_to.value()
.in_reply_to.event_id);
auto request =
std::find(eventOrder.begin(), eventOrder.end(), event_id);
if (request != eventOrder.end()) {
auto event = events.value(event_id);
auto e = std::get_if<mtx::events::RoomEvent<
mtx::events::msg::KeyVerificationRequest>>(&event);
std::cout<<json(*e)<<std::endl;
}
}
}
if (auto redaction = if (auto redaction =
std::get_if<mtx::events::RedactionEvent<mtx::events::msg::Redaction>>(&e)) { std::get_if<mtx::events::RedactionEvent<mtx::events::msg::Redaction>>(&e)) {
QString redacts = QString::fromStdString(redaction->redacts); QString redacts = QString::fromStdString(redaction->redacts);
@ -728,6 +709,55 @@ TimelineModel::internalAddEvents(
if (encInfo) if (encInfo)
emit newEncryptedImage(encInfo.value()); emit newEncryptedImage(encInfo.value());
if (auto msg = std::get_if<
mtx::events::RoomEvent<mtx::events::msg::KeyVerificationRequest>>(
&e_)) {
last_verification_request_event = *msg;
}
if (auto msg = std::get_if<
mtx::events::RoomEvent<mtx::events::msg::KeyVerificationCancel>>(
&e_)) {
last_verification_cancel_event = *msg;
ChatPage::instance()->recievedDeviceVerificationCancel(
msg->content);
}
if (auto msg = std::get_if<
mtx::events::RoomEvent<mtx::events::msg::KeyVerificationAccept>>(
&e_)) {
ChatPage::instance()->recievedDeviceVerificationAccept(
msg->content);
}
if (auto msg = std::get_if<
mtx::events::RoomEvent<mtx::events::msg::KeyVerificationKey>>(&e_)) {
ChatPage::instance()->recievedDeviceVerificationKey(msg->content);
}
if (auto msg = std::get_if<
mtx::events::RoomEvent<mtx::events::msg::KeyVerificationMac>>(&e_)) {
ChatPage::instance()->recievedDeviceVerificationMac(msg->content);
}
if (auto msg = std::get_if<
mtx::events::RoomEvent<mtx::events::msg::KeyVerificationReady>>(
&e_)) {
ChatPage::instance()->recievedDeviceVerificationReady(msg->content);
}
if (auto msg = std::get_if<
mtx::events::RoomEvent<mtx::events::msg::KeyVerificationDone>>(&e_)) {
ChatPage::instance()->recievedDeviceVerificationDone(msg->content);
}
if (auto msg = std::get_if<
mtx::events::RoomEvent<mtx::events::msg::KeyVerificationStart>>(
&e_)) {
ChatPage::instance()->recievedDeviceVerificationStart(msg->content,
msg->sender);
}
} }
this->events.insert(id, e); this->events.insert(id, e);
@ -754,6 +784,13 @@ TimelineModel::internalAddEvents(
}); });
} }
} }
if (last_verification_request_event.origin_server_ts >
last_verification_cancel_event.origin_server_ts) {
ChatPage::instance()->recievedRoomDeviceVerificationRequest(
last_verification_request_event, this);
}
return ids; return ids;
} }
@ -1263,6 +1300,20 @@ struct SendMessageVisitor
TimelineModel *model_; TimelineModel *model_;
}; };
void
TimelineModel::processOnePendingMessage()
{
if (pending.isEmpty())
return;
QString txn_id_qstr = pending.first();
auto event = events.value(txn_id_qstr);
std::cout << "Inside the process one pending message" << std::endl;
std::cout << std::visit([](auto &e) { return json(e); }, event).dump(2) << std::endl;
std::visit(SendMessageVisitor{txn_id_qstr, this}, event);
}
void void
TimelineModel::addPendingMessage(mtx::events::collections::TimelineEvents event) TimelineModel::addPendingMessage(mtx::events::collections::TimelineEvents event)
{ {
@ -1275,7 +1326,51 @@ TimelineModel::addPendingMessage(mtx::events::collections::TimelineEvents event)
}, },
event); event);
std::visit(SendMessageVisitor{this}, event); if (std::get_if<mtx::events::RoomEvent<mtx::events::msg::KeyVerificationReady>>(&event)) {
std::visit(
[](auto &msg) { msg.type = mtx::events::EventType::KeyVerificationReady; },
event);
}
if (std::get_if<mtx::events::RoomEvent<mtx::events::msg::KeyVerificationStart>>(&event)) {
std::visit(
[](auto &msg) { msg.type = mtx::events::EventType::KeyVerificationStart; },
event);
}
if (std::get_if<mtx::events::RoomEvent<mtx::events::msg::KeyVerificationKey>>(&event)) {
std::visit([](auto &msg) { msg.type = mtx::events::EventType::KeyVerificationKey; },
event);
}
if (std::get_if<mtx::events::RoomEvent<mtx::events::msg::KeyVerificationMac>>(&event)) {
std::visit([](auto &msg) { msg.type = mtx::events::EventType::KeyVerificationMac; },
event);
}
if (std::get_if<mtx::events::RoomEvent<mtx::events::msg::KeyVerificationDone>>(&event)) {
std::visit(
[](auto &msg) { msg.type = mtx::events::EventType::KeyVerificationDone; }, event);
}
if (std::get_if<mtx::events::RoomEvent<mtx::events::msg::KeyVerificationCancel>>(&event)) {
std::visit(
[](auto &msg) { msg.type = mtx::events::EventType::KeyVerificationCancel; },
event);
}
if (std::get_if<mtx::events::RoomEvent<mtx::events::msg::KeyVerificationAccept>>(&event)) {
std::visit(
[](auto &msg) { msg.type = mtx::events::EventType::KeyVerificationAccept; },
event);
}
internalAddEvents({event});
QString txn_id_qstr = QString::fromStdString(mtx::accessors::event_id(event));
pending.push_back(txn_id_qstr);
if (!std::get_if<mtx::events::RoomEvent<mtx::events::msg::Reaction>>(&event)) {
beginInsertRows(QModelIndex(), 0, 0);
this->eventOrder.insert(this->eventOrder.begin(), txn_id_qstr);
endInsertRows();
}
updateLastMessage();
emit nextPendingMessage();
} }
bool bool

View File

@ -297,6 +297,11 @@ private:
std::vector<QString> typingUsers_; std::vector<QString> typingUsers_;
TimelineViewManager *manager_; TimelineViewManager *manager_;
// probably not the best way to do
mtx::events::RoomEvent<mtx::events::msg::KeyVerificationRequest>
last_verification_request_event;
mtx::events::RoomEvent<mtx::events::msg::KeyVerificationCancel>
last_verification_cancel_event;
friend struct SendMessageVisitor; friend struct SendMessageVisitor;
}; };

View File

@ -17,6 +17,8 @@
#include "emoji/EmojiModel.h" #include "emoji/EmojiModel.h"
#include "emoji/Provider.h" #include "emoji/Provider.h"
#include <iostream> //only for debugging
Q_DECLARE_METATYPE(mtx::events::collections::TimelineEvents) Q_DECLARE_METATYPE(mtx::events::collections::TimelineEvents)
Q_DECLARE_METATYPE(std::vector<DeviceInfo>) Q_DECLARE_METATYPE(std::vector<DeviceInfo>)
@ -185,18 +187,44 @@ TimelineViewManager::TimelineViewManager(QSharedPointer<UserSettings> userSettin
&ChatPage::decryptSidebarChanged, &ChatPage::decryptSidebarChanged,
this, this,
&TimelineViewManager::updateEncryptedDescriptions); &TimelineViewManager::updateEncryptedDescriptions);
connect(
dynamic_cast<ChatPage *>(parent),
&ChatPage::recievedRoomDeviceVerificationRequest,
this,
[this](const mtx::events::RoomEvent<mtx::events::msg::KeyVerificationRequest> &message,
TimelineModel *model) {
if (!(this->dvList->exist(QString::fromStdString(message.event_id)))) {
auto flow =
new DeviceVerificationFlow(this, DeviceVerificationFlow::Type::RoomMsg);
if (std::find(message.content.methods.begin(),
message.content.methods.end(),
mtx::events::msg::VerificationMethods::SASv1) !=
message.content.methods.end()) {
flow->setModel(model);
flow->setEventId(message.event_id);
emit newDeviceVerificationRequest(
std::move(flow),
QString::fromStdString(message.event_id),
QString::fromStdString(message.sender),
QString::fromStdString(message.content.from_device),
true);
} else {
flow->cancelVerification(
DeviceVerificationFlow::Error::UnknownMethod);
}
}
});
connect( connect(
dynamic_cast<ChatPage *>(parent), dynamic_cast<ChatPage *>(parent),
&ChatPage::recievedDeviceVerificationRequest, &ChatPage::recievedDeviceVerificationRequest,
this, this,
[this](const mtx::events::msg::KeyVerificationRequest &msg, std::string sender) { [this](const mtx::events::msg::KeyVerificationRequest &msg, std::string sender) {
auto flow = new DeviceVerificationFlow(this);
if (!(this->dvList->exist(QString::fromStdString(msg.transaction_id.value())))) { if (!(this->dvList->exist(QString::fromStdString(msg.transaction_id.value())))) {
auto flow = new DeviceVerificationFlow(this);
if (std::find(msg.methods.begin(), if (std::find(msg.methods.begin(),
msg.methods.end(), msg.methods.end(),
mtx::events::msg::VerificationMethods::SASv1) != mtx::events::msg::VerificationMethods::SASv1) !=
msg.methods.end()) { msg.methods.end()) {
// flow->sendVerificationReady();
emit newDeviceVerificationRequest( emit newDeviceVerificationRequest(
std::move(flow), std::move(flow),
QString::fromStdString(msg.transaction_id.value()), QString::fromStdString(msg.transaction_id.value()),
@ -213,9 +241,9 @@ TimelineViewManager::TimelineViewManager(QSharedPointer<UserSettings> userSettin
&ChatPage::recievedDeviceVerificationStart, &ChatPage::recievedDeviceVerificationStart,
this, this,
[this](const mtx::events::msg::KeyVerificationStart &msg, std::string sender) { [this](const mtx::events::msg::KeyVerificationStart &msg, std::string sender) {
auto flow = new DeviceVerificationFlow(this);
flow->canonical_json = nlohmann::json(msg);
if (!(this->dvList->exist(QString::fromStdString(msg.transaction_id.value())))) { if (!(this->dvList->exist(QString::fromStdString(msg.transaction_id.value())))) {
auto flow = new DeviceVerificationFlow(this);
flow->canonical_json = nlohmann::json(msg);
if ((std::find(msg.key_agreement_protocols.begin(), if ((std::find(msg.key_agreement_protocols.begin(),
msg.key_agreement_protocols.end(), msg.key_agreement_protocols.end(),
"curve25519-hkdf-sha256") != "curve25519-hkdf-sha256") !=
@ -246,7 +274,6 @@ TimelineViewManager::TimelineViewManager(QSharedPointer<UserSettings> userSettin
QString::fromStdString(msg.transaction_id.value()), QString::fromStdString(msg.transaction_id.value()),
QString::fromStdString(sender), QString::fromStdString(sender),
QString::fromStdString(msg.from_device)); QString::fromStdString(msg.from_device));
flow->canonical_json = nlohmann::json(msg);
} else { } else {
flow->cancelVerification( flow->cancelVerification(
DeviceVerificationFlow::Error::UnknownMethod); DeviceVerificationFlow::Error::UnknownMethod);

View File

@ -72,7 +72,8 @@ signals:
void newDeviceVerificationRequest(DeviceVerificationFlow *flow, void newDeviceVerificationRequest(DeviceVerificationFlow *flow,
QString transactionId, QString transactionId,
QString userId, QString userId,
QString deviceId); QString deviceId,
bool isRequest = false);
public slots: public slots:
void updateReadReceipts(const QString &room_id, const std::vector<QString> &event_ids); void updateReadReceipts(const QString &room_id, const std::vector<QString> &event_ids);