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 `user_id` of the room creator. This is set by the homeserver. |
41 | std::string creator; |
42 | |
43 | //! The room type, for example `m.space` for spaces. |
44 | std::optional<std::string> type; |
45 | |
46 | //! Whether users on other servers can join this room. |
47 | //! Defaults to **true** if key does not exist. |
48 | bool federate = true; |
49 | |
50 | //! The version of the room. Defaults to "1" if the key does not exist. |
51 | std::string room_version = "1" ; |
52 | |
53 | //! A reference to the room this room replaces, if the previous room was upgraded. |
54 | std::optional<PreviousRoom> predecessor; |
55 | |
56 | friend void from_json(const nlohmann::json &obj, Create &create); |
57 | |
58 | friend void to_json(nlohmann::json &obj, const Create &create); |
59 | }; |
60 | |
61 | } // namespace state |
62 | } // namespace events |
63 | } // namespace mtx |
64 | |