Description: support additional_creators Author: Sofia/Nep Origin: upstream, https://github.com/Nheko-Reborn/mtxclient/commit/6ace9ce Last-Update: 2025-10-28 --- This patch header follows DEP-3: http://dep.debian.net/deps/dep3/ --- a/mtxclient/include/mtx/events/create.hpp +++ b/mtxclient/include/mtx/events/create.hpp @@ -58,6 +58,9 @@ //! A reference to the room this room replaces, if the previous room was upgraded. std::optional predecessor; + //! Additional creators in v12+ rooms, nullopt in earlier versions or if the field is not present. + std::optional> additional_creators; + friend void from_json(const nlohmann::json &obj, Create &create); friend void to_json(nlohmann::json &obj, const Create &create); --- a/mtxclient/lib/structs/events/create.cpp +++ b/mtxclient/lib/structs/events/create.cpp @@ -45,6 +45,8 @@ if (obj.find("predecessor") != obj.end()) create.predecessor = obj.at("predecessor").get(); + if (obj.find("additional_creators") != obj.end()) + create.additional_creators = obj.at("additional_creators").get>(); } void @@ -60,6 +62,8 @@ obj["type"] = create.type.value(); if (create.predecessor) obj["predecessor"] = *create.predecessor; + if (create.additional_creators) + obj["additional_creators"] = *create.additional_creators; } } // namespace state --- a/mtxclient/tests/events.cpp +++ b/mtxclient/tests/events.cpp @@ -234,7 +234,8 @@ }, "state_key": "", "content": { - "creator": "@mujx:matrix.org" + "creator": "@mujx:matrix.org", + "additional_creators": ["@abc:example.com", "@123:example.com"] }, "type": "m.room.create" })"_json; @@ -247,6 +248,9 @@ EXPECT_EQ(event.unsigned_data.age, 3715756343L); EXPECT_EQ(event.origin_server_ts, 1506761923948L); EXPECT_EQ(event.state_key, ""); + EXPECT_TRUE(event.content.additional_creators.has_value()); + EXPECT_EQ(event.content.additional_creators->at(0), "@abc:example.com"); + EXPECT_EQ(event.content.additional_creators->at(1), "@123:example.com"); // EXPECT_EQ(event.content.creator, "@mujx:matrix.org"); json example_from_spec = R"({ @@ -297,7 +301,8 @@ "state_key": "", "content": { "creator": "@mujx:matrix.org", - "type": "m.space" + "type": "m.space", + "additional_creators": ["@abc:example.com", "@123:example.com"] }, "type": "m.room.create" })"_json; @@ -310,6 +315,9 @@ EXPECT_EQ(event.unsigned_data.age, 3715756343L); EXPECT_EQ(event.origin_server_ts, 1506761923948L); EXPECT_EQ(event.state_key, ""); + EXPECT_TRUE(event.content.additional_creators.has_value()); + EXPECT_EQ(event.content.additional_creators->at(0), "@abc:example.com"); + EXPECT_EQ(event.content.additional_creators->at(1), "@123:example.com"); // EXPECT_EQ(event.content.creator, "@mujx:matrix.org"); EXPECT_TRUE(event.content.type.has_value()); EXPECT_EQ(event.content.type.value(), ns::state::room_type::space);