Debian Codegraph @

mtxclient/include/mtx/events/create.hpp

raw symbols ◀ ▶ SCIP
1 Debian patch touch this file
1 #pragma once
2
3 /// @file
4 /// @brief The first event in a room.
5
6 #include <optional>
7
8 #if __has_include(<nlohmann/json_fwd.hpp>)
9 #include <nlohmann/json_fwd.hpp>
10 #else
11 #include <nlohmann/json.hpp>
12 #endif
13
14 namespace mtx {
15 namespace events {
16 namespace state {
17 //! The predecessor of this room.
18 struct PreviousRoom
19 {
20 //! Required. The ID of the old room.
21 std::string room_id;
22 //! Required. The event ID of the last known event in the old room.
23 std::string event_id;
24 };
25
26 //! Definitions of different room types.
27 namespace room_type {
28 //! The room type for a space.
29 inline constexpr std::string_view space = "m.space";
30 //! MSC for policy list rooms, see https://github.com/matrix-org/matrix-spec-proposals/pull/3784
31 inline constexpr std::string_view exp_policy = "support.feline.policy.lists.msc.v1";
32 }
33
34 //! Content of the `m.room.create` event.
35 //
36 //! This is the first event in a room and cannot be changed.
37 //! It acts as the root of all other events.
38 struct Create
39 {
40 // The create field is removed in room version 11. We remove the field instead of deprecating
41 // it, since it seems to cause warnings in EVERY generated destructor or copy constructor and
42 // using the sender is easy enough.
43
44 // The `user_id` of the room creator. This is set by the homeserver.
45 //[[deprecated("Removed in future room versions, check the sender instead")]] std::string
46 // creator;
47
48 //! The room type, for example `m.space` for spaces.
49 std::optional<std::string> type;
50
51 //! Whether users on other servers can join this room.
52 //! Defaults to **true** if key does not exist.
53 bool federate = true;
54
55 //! The version of the room. Defaults to "1" if the key does not exist.
56 std::string room_version = "1";
57
58 //! A reference to the room this room replaces, if the previous room was upgraded.
59 std::optional<PreviousRoom> predecessor;
60
•61 //! Additional creators in v12+ rooms, nullopt in earlier versions or if the field is not present.
62 std::optional<std::vector<std::string>> additional_creators;
63
64 friend void from_json(const nlohmann::json &obj, Create &create);
65
66 friend void to_json(nlohmann::json &obj, const Create &create);
67 };
68
69 } // namespace state
70 } // namespace events
71 } // namespace mtx