diff --git a/include/mtx/events/collections.hpp b/include/mtx/events/collections.hpp index 0bbf183316c132d845483c99ed9d0f7dd853f3e4..df4a17ee5439df81e9ba6a9d15c9346c0259912e 100644 --- a/include/mtx/events/collections.hpp +++ b/include/mtx/events/collections.hpp @@ -58,6 +58,7 @@ using DeviceEvents = std::variant<events::DeviceEvent<msgs::RoomKey>, events::DeviceEvent<msgs::KeyRequest>, events::DeviceEvent<msgs::OlmEncrypted>, events::DeviceEvent<msgs::Encrypted>, + events::DeviceEvent<msgs::Dummy>, events::DeviceEvent<msgs::KeyVerificationRequest>, events::DeviceEvent<msgs::KeyVerificationStart>, events::DeviceEvent<msgs::KeyVerificationReady>, @@ -287,6 +288,8 @@ template<> constexpr inline EventType to_device_content_to_type<mtx::events::msg::Encrypted> = EventType::RoomEncrypted; template<> +constexpr inline EventType to_device_content_to_type<mtx::events::msg::Dummy> = EventType::Dummy; +template<> constexpr inline EventType to_device_content_to_type<mtx::events::msg::KeyVerificationRequest> = EventType::KeyVerificationRequest; template<> diff --git a/include/mtx/events/encrypted.hpp b/include/mtx/events/encrypted.hpp index 7eeef31b11e807e94c679eac71956bdb446e15ff..eb31cc44ec5c5a9e206256c130cf85e0f208b99c 100644 --- a/include/mtx/events/encrypted.hpp +++ b/include/mtx/events/encrypted.hpp @@ -104,6 +104,16 @@ from_json(const nlohmann::json &obj, Encrypted &event); void to_json(nlohmann::json &obj, const Encrypted &event); +//! Content of the `m.dummy` event. +struct Dummy +{}; + +void +from_json(const nlohmann::json &obj, Dummy &event); + +void +to_json(nlohmann::json &obj, const Dummy &event); + //! Content of the `m.room_key` event. struct RoomKey { diff --git a/include/mtx/events/event_type.hpp b/include/mtx/events/event_type.hpp index 16ba250f20a047859de1786682300cb027d74ff4..e602a18cb084c13636a339d110486b042fa244ae 100644 --- a/include/mtx/events/event_type.hpp +++ b/include/mtx/events/event_type.hpp @@ -115,7 +115,10 @@ enum class EventType //! m.image_pack.rooms, currently im.ponies.emote_rooms ImagePackRooms, - // Unsupported event + //! `m.dummy`, used in crypto for example + Dummy, + + //! Unsupported event Unsupported, }; diff --git a/include/mtxclient/http/client.hpp b/include/mtxclient/http/client.hpp index c6fd3af9f45a5e4a42dc53ad1a91232b64d3e5ff..5bb888ea425cf6fe972716ba2c08fbd918835e91 100644 --- a/include/mtxclient/http/client.hpp +++ b/include/mtxclient/http/client.hpp @@ -743,6 +743,7 @@ MTXCLIENT_SEND_TO_DEVICE_FWD(mtx::events::msg::ForwardedRoomKey) MTXCLIENT_SEND_TO_DEVICE_FWD(mtx::events::msg::KeyRequest) MTXCLIENT_SEND_TO_DEVICE_FWD(mtx::events::msg::OlmEncrypted) MTXCLIENT_SEND_TO_DEVICE_FWD(mtx::events::msg::Encrypted) +MTXCLIENT_SEND_TO_DEVICE_FWD(mtx::events::msg::Dummy) MTXCLIENT_SEND_TO_DEVICE_FWD(mtx::events::msg::KeyVerificationRequest) MTXCLIENT_SEND_TO_DEVICE_FWD(mtx::events::msg::KeyVerificationStart) MTXCLIENT_SEND_TO_DEVICE_FWD(mtx::events::msg::KeyVerificationReady) diff --git a/lib/http/client.cpp b/lib/http/client.cpp index 826f41227a0b32493ea3ad95322365c7aa613beb..f4ac8da657e8a56d0f6079b585bf352d98f94057 100644 --- a/lib/http/client.cpp +++ b/lib/http/client.cpp @@ -1483,6 +1483,7 @@ MTXCLIENT_SEND_TO_DEVICE(mtx::events::msg::ForwardedRoomKey) MTXCLIENT_SEND_TO_DEVICE(mtx::events::msg::KeyRequest) MTXCLIENT_SEND_TO_DEVICE(mtx::events::msg::OlmEncrypted) MTXCLIENT_SEND_TO_DEVICE(mtx::events::msg::Encrypted) +MTXCLIENT_SEND_TO_DEVICE(mtx::events::msg::Dummy) MTXCLIENT_SEND_TO_DEVICE(mtx::events::msg::KeyVerificationRequest) MTXCLIENT_SEND_TO_DEVICE(mtx::events::msg::KeyVerificationStart) MTXCLIENT_SEND_TO_DEVICE(mtx::events::msg::KeyVerificationReady) diff --git a/lib/structs/events.cpp b/lib/structs/events.cpp index a16f42ff7039aaa103eb97afcb02e55a872ae97e..090f50d842a984102e33b009af6d749598dda409 100644 --- a/lib/structs/events.cpp +++ b/lib/structs/events.cpp @@ -44,6 +44,8 @@ getEventType(const std::string &type) return EventType::RoomCreate; else if (type == "m.room.encrypted") return EventType::RoomEncrypted; + else if (type == "m.dummy") + return EventType::Dummy; else if (type == "m.room.encryption") return EventType::RoomEncryption; else if (type == "m.room.guest_access") @@ -144,6 +146,8 @@ to_string(EventType type) return "m.room.create"; case EventType::RoomEncrypted: return "m.room.encrypted"; + case EventType::Dummy: + return "m.dummy"; case EventType::RoomEncryption: return "m.room.encryption"; case EventType::RoomGuestAccess: diff --git a/lib/structs/events/collections.cpp b/lib/structs/events/collections.cpp index f49578f5180da3633f821fb5ffdf60d7235b7bd8..bf22a3792e24d1752435a46b981a4e655616eec0 100644 --- a/lib/structs/events/collections.cpp +++ b/lib/structs/events/collections.cpp @@ -85,6 +85,7 @@ MTXCLIENT_INSTANTIATE_JSON_FUNCTIONS(events::DeviceEvent, msgs::ForwardedRoomKey MTXCLIENT_INSTANTIATE_JSON_FUNCTIONS(events::DeviceEvent, msgs::KeyRequest) MTXCLIENT_INSTANTIATE_JSON_FUNCTIONS(events::DeviceEvent, msgs::SecretRequest) MTXCLIENT_INSTANTIATE_JSON_FUNCTIONS(events::DeviceEvent, msgs::SecretSend) +MTXCLIENT_INSTANTIATE_JSON_FUNCTIONS(events::DeviceEvent, msgs::Dummy) MTXCLIENT_INSTANTIATE_JSON_FUNCTIONS(events::DeviceEvent, Unknown) MTXCLIENT_INSTANTIATE_JSON_FUNCTIONS(events::EphemeralEvent, ephemeral::Typing) @@ -325,6 +326,7 @@ from_json(const json &obj, TimelineEvent &e) case events::EventType::NhekoHiddenEvents: case events::EventType::ImagePackInAccountData: case events::EventType::ImagePackRooms: + case events::EventType::Dummy: return; } } diff --git a/lib/structs/events/encrypted.cpp b/lib/structs/events/encrypted.cpp index 04d80dee765d6ea9d10fde0378b2be9bbeb6699f..7bbcb245736cc276fed330d938e4818d57d931ce 100644 --- a/lib/structs/events/encrypted.cpp +++ b/lib/structs/events/encrypted.cpp @@ -116,6 +116,16 @@ to_json(json &obj, const Encrypted &content) common::add_relations(obj, content.relations); } +void +from_json(const json &, Dummy &) +{} + +void +to_json(json &obj, const Dummy &) +{ + obj = json::object(); +} + void from_json(const json &obj, RoomKey &event) { diff --git a/lib/structs/responses/common.cpp b/lib/structs/responses/common.cpp index 9e7bfd3f6f296306509dba73f38fbd12c66a6974..8a98046189fe7853bfba4af882cc475fae7cae1f 100644 --- a/lib/structs/responses/common.cpp +++ b/lib/structs/responses/common.cpp @@ -160,6 +160,7 @@ parse_room_account_data_events( case events::EventType::RoomCanonicalAlias: case events::EventType::RoomCreate: case events::EventType::RoomEncrypted: + case events::EventType::Dummy: case events::EventType::RoomEncryption: case events::EventType::RoomGuestAccess: case events::EventType::RoomHistoryVisibility: @@ -629,6 +630,7 @@ parse_timeline_events(const json &events, case events::EventType::NhekoHiddenEvents: case events::EventType::ImagePackRooms: case events::EventType::ImagePackInAccountData: + case events::EventType::Dummy: continue; } } @@ -664,6 +666,15 @@ parse_device_events(const json &events, break; } + case events::EventType::Dummy: { + try { + container.emplace_back(events::DeviceEvent<Dummy>(e)); + } catch (json::exception &err) { + log_error(err, e); + } + + break; + } case events::EventType::RoomKey: { try { container.emplace_back(events::DeviceEvent<RoomKey>(e)); @@ -970,6 +981,7 @@ parse_state_events(const json &events, case events::EventType::NhekoHiddenEvents: case events::EventType::ImagePackRooms: case events::EventType::ImagePackInAccountData: + case events::EventType::Dummy: continue; } } @@ -1137,6 +1149,7 @@ parse_stripped_events(const json &events, case events::EventType::ImagePackInAccountData: case events::EventType::ImagePackInRoom: case events::EventType::ImagePackRooms: + case events::EventType::Dummy: continue; } }