mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-11-26 13:08:48 +03:00
Add support non-encrypted room-verification messages
This commit is contained in:
parent
e8eeb480d5
commit
898be090af
2 changed files with 60 additions and 58 deletions
|
@ -280,71 +280,18 @@ EventStore::handleSync(const mtx::responses::Timeline &events)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
handle_room_verification(event);
|
||||||
|
|
||||||
// decrypting and checking some encrypted messages
|
// decrypting and checking some encrypted messages
|
||||||
if (auto encrypted =
|
if (auto encrypted =
|
||||||
std::get_if<mtx::events::EncryptedEvent<mtx::events::msg::Encrypted>>(
|
std::get_if<mtx::events::EncryptedEvent<mtx::events::msg::Encrypted>>(
|
||||||
&event)) {
|
&event)) {
|
||||||
auto d_event = decryptEvent({room_id_, encrypted->event_id}, *encrypted);
|
mtx::events::collections::TimelineEvents *d_event =
|
||||||
|
decryptEvent({room_id_, encrypted->event_id}, *encrypted);
|
||||||
if (std::visit(
|
if (std::visit(
|
||||||
[](auto e) { return (e.sender != utils::localUser().toStdString()); },
|
[](auto e) { return (e.sender != utils::localUser().toStdString()); },
|
||||||
*d_event)) {
|
*d_event)) {
|
||||||
if (std::get_if<mtx::events::RoomEvent<
|
handle_room_verification(*d_event);
|
||||||
mtx::events::msg::KeyVerificationRequest>>(d_event)) {
|
|
||||||
auto msg = std::get_if<mtx::events::RoomEvent<
|
|
||||||
mtx::events::msg::KeyVerificationRequest>>(d_event);
|
|
||||||
last_verification_request_event = *msg;
|
|
||||||
continue;
|
|
||||||
} else if (std::get_if<mtx::events::RoomEvent<
|
|
||||||
mtx::events::msg::KeyVerificationCancel>>(d_event)) {
|
|
||||||
auto msg = std::get_if<mtx::events::RoomEvent<
|
|
||||||
mtx::events::msg::KeyVerificationCancel>>(d_event);
|
|
||||||
last_verification_cancel_event = *msg;
|
|
||||||
ChatPage::instance()->recievedDeviceVerificationCancel(
|
|
||||||
msg->content);
|
|
||||||
continue;
|
|
||||||
} else if (std::get_if<mtx::events::RoomEvent<
|
|
||||||
mtx::events::msg::KeyVerificationAccept>>(d_event)) {
|
|
||||||
auto msg = std::get_if<mtx::events::RoomEvent<
|
|
||||||
mtx::events::msg::KeyVerificationAccept>>(d_event);
|
|
||||||
ChatPage::instance()->recievedDeviceVerificationAccept(
|
|
||||||
msg->content);
|
|
||||||
continue;
|
|
||||||
} else if (std::get_if<mtx::events::RoomEvent<
|
|
||||||
mtx::events::msg::KeyVerificationKey>>(d_event)) {
|
|
||||||
auto msg = std::get_if<mtx::events::RoomEvent<
|
|
||||||
mtx::events::msg::KeyVerificationKey>>(d_event);
|
|
||||||
ChatPage::instance()->recievedDeviceVerificationKey(
|
|
||||||
msg->content);
|
|
||||||
continue;
|
|
||||||
} else if (std::get_if<mtx::events::RoomEvent<
|
|
||||||
mtx::events::msg::KeyVerificationMac>>(d_event)) {
|
|
||||||
auto msg = std::get_if<mtx::events::RoomEvent<
|
|
||||||
mtx::events::msg::KeyVerificationMac>>(d_event);
|
|
||||||
ChatPage::instance()->recievedDeviceVerificationMac(
|
|
||||||
msg->content);
|
|
||||||
continue;
|
|
||||||
} else if (std::get_if<mtx::events::RoomEvent<
|
|
||||||
mtx::events::msg::KeyVerificationReady>>(d_event)) {
|
|
||||||
auto msg = std::get_if<mtx::events::RoomEvent<
|
|
||||||
mtx::events::msg::KeyVerificationReady>>(d_event);
|
|
||||||
ChatPage::instance()->recievedDeviceVerificationReady(
|
|
||||||
msg->content);
|
|
||||||
continue;
|
|
||||||
} else if (std::get_if<mtx::events::RoomEvent<
|
|
||||||
mtx::events::msg::KeyVerificationDone>>(d_event)) {
|
|
||||||
auto msg = std::get_if<mtx::events::RoomEvent<
|
|
||||||
mtx::events::msg::KeyVerificationDone>>(d_event);
|
|
||||||
ChatPage::instance()->recievedDeviceVerificationDone(
|
|
||||||
msg->content);
|
|
||||||
continue;
|
|
||||||
} else if (std::get_if<mtx::events::RoomEvent<
|
|
||||||
mtx::events::msg::KeyVerificationStart>>(d_event)) {
|
|
||||||
auto msg = std::get_if<mtx::events::RoomEvent<
|
|
||||||
mtx::events::msg::KeyVerificationStart>>(d_event);
|
|
||||||
ChatPage::instance()->recievedDeviceVerificationStart(
|
|
||||||
msg->content, msg->sender);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
// only the key.verification.ready sent by localuser's other device
|
// only the key.verification.ready sent by localuser's other device
|
||||||
// is of significance as it is used for detecting accepted request
|
// is of significance as it is used for detecting accepted request
|
||||||
|
@ -368,6 +315,60 @@ EventStore::handleSync(const mtx::responses::Timeline &events)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
EventStore::handle_room_verification(mtx::events::collections::TimelineEvents event)
|
||||||
|
{
|
||||||
|
if (std::get_if<mtx::events::RoomEvent<mtx::events::msg::KeyVerificationRequest>>(&event)) {
|
||||||
|
auto msg =
|
||||||
|
std::get<mtx::events::RoomEvent<mtx::events::msg::KeyVerificationRequest>>(event);
|
||||||
|
last_verification_request_event = msg;
|
||||||
|
return;
|
||||||
|
} else if (std::get_if<mtx::events::RoomEvent<mtx::events::msg::KeyVerificationCancel>>(
|
||||||
|
&event)) {
|
||||||
|
auto msg =
|
||||||
|
std::get<mtx::events::RoomEvent<mtx::events::msg::KeyVerificationCancel>>(event);
|
||||||
|
last_verification_cancel_event = msg;
|
||||||
|
ChatPage::instance()->recievedDeviceVerificationCancel(msg.content);
|
||||||
|
return;
|
||||||
|
} else if (std::get_if<mtx::events::RoomEvent<mtx::events::msg::KeyVerificationAccept>>(
|
||||||
|
&event)) {
|
||||||
|
auto msg =
|
||||||
|
std::get<mtx::events::RoomEvent<mtx::events::msg::KeyVerificationAccept>>(event);
|
||||||
|
ChatPage::instance()->recievedDeviceVerificationAccept(msg.content);
|
||||||
|
return;
|
||||||
|
} else if (std::get_if<mtx::events::RoomEvent<mtx::events::msg::KeyVerificationKey>>(
|
||||||
|
&event)) {
|
||||||
|
auto msg =
|
||||||
|
std::get<mtx::events::RoomEvent<mtx::events::msg::KeyVerificationKey>>(event);
|
||||||
|
ChatPage::instance()->recievedDeviceVerificationKey(msg.content);
|
||||||
|
return;
|
||||||
|
} else if (std::get_if<mtx::events::RoomEvent<mtx::events::msg::KeyVerificationMac>>(
|
||||||
|
&event)) {
|
||||||
|
auto msg =
|
||||||
|
std::get<mtx::events::RoomEvent<mtx::events::msg::KeyVerificationMac>>(event);
|
||||||
|
ChatPage::instance()->recievedDeviceVerificationMac(msg.content);
|
||||||
|
return;
|
||||||
|
} else if (std::get_if<mtx::events::RoomEvent<mtx::events::msg::KeyVerificationReady>>(
|
||||||
|
&event)) {
|
||||||
|
auto msg =
|
||||||
|
std::get<mtx::events::RoomEvent<mtx::events::msg::KeyVerificationReady>>(event);
|
||||||
|
ChatPage::instance()->recievedDeviceVerificationReady(msg.content);
|
||||||
|
return;
|
||||||
|
} else if (std::get_if<mtx::events::RoomEvent<mtx::events::msg::KeyVerificationDone>>(
|
||||||
|
&event)) {
|
||||||
|
auto msg =
|
||||||
|
std::get<mtx::events::RoomEvent<mtx::events::msg::KeyVerificationDone>>(event);
|
||||||
|
ChatPage::instance()->recievedDeviceVerificationDone(msg.content);
|
||||||
|
return;
|
||||||
|
} else if (std::get_if<mtx::events::RoomEvent<mtx::events::msg::KeyVerificationStart>>(
|
||||||
|
&event)) {
|
||||||
|
auto msg =
|
||||||
|
std::get<mtx::events::RoomEvent<mtx::events::msg::KeyVerificationStart>>(event);
|
||||||
|
ChatPage::instance()->recievedDeviceVerificationStart(msg.content, msg.sender);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
QVariantList
|
QVariantList
|
||||||
EventStore::reactions(const std::string &event_id)
|
EventStore::reactions(const std::string &event_id)
|
||||||
{
|
{
|
||||||
|
|
|
@ -110,6 +110,7 @@ private:
|
||||||
mtx::events::collections::TimelineEvents *decryptEvent(
|
mtx::events::collections::TimelineEvents *decryptEvent(
|
||||||
const IdIndex &idx,
|
const IdIndex &idx,
|
||||||
const mtx::events::EncryptedEvent<mtx::events::msg::Encrypted> &e);
|
const mtx::events::EncryptedEvent<mtx::events::msg::Encrypted> &e);
|
||||||
|
void handle_room_verification(mtx::events::collections::TimelineEvents event);
|
||||||
|
|
||||||
std::string room_id_;
|
std::string room_id_;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue