| 1 | #pragma once |
| 2 | |
| 3 | /// @file |
| 4 | /// @brief State event describing the visibility of the history. |
| 5 | |
| 6 | #if __has_include(<nlohmann/json_fwd.hpp>) |
| 7 | #include <nlohmann/json_fwd.hpp> |
| 8 | #else |
| 9 | #include <nlohmann/json.hpp> |
| 10 | #endif |
| 11 | |
| 12 | #include <string> |
| 13 | |
| 14 | namespace mtx { |
| 15 | namespace events { |
| 16 | namespace state { |
| 17 | //! The different visibilities. |
| 18 | enum class Visibility |
| 19 | { |
| 20 | //! All events while this is the `m.room.history_visibility` |
| 21 | //! value may be shared by any participating homeserver with anyone, |
| 22 | //! regardless of whether they have ever joined the room. |
| 23 | WorldReadable, |
| 24 | //! Previous events are always accessible to newly joined members. |
| 25 | //! All events in the room are accessible, even those sent when |
| 26 | //! the member was not a part of the room. |
| 27 | Shared, |
| 28 | //! Events are accessible to newly joined members from the point |
| 29 | //! they were invited onwards. Events stop being accessible when |
| 30 | //! the member's state changes to something other than invite or join. |
| 31 | Invited, |
| 32 | //! Events are accessible to newly joined members from the point |
| 33 | //! they joined the room onwards. Events stop being accessible |
| 34 | //! when the member's state changes to something other than join. |
| 35 | Joined, |
| 36 | }; |
| 37 | |
| 38 | std::string |
| 39 | visibilityToString(const Visibility &rule); |
| 40 | |
| 41 | Visibility |
| 42 | stringToVisibility(const std::string &rule); |
| 43 | |
| 44 | //! Content of the `m.room.history_visibility` state event. |
| 45 | struct HistoryVisibility |
| 46 | { |
| 47 | //! Who can see the room history. |
| 48 | Visibility history_visibility; |
| 49 | |
| 50 | friend void from_json(const nlohmann::json &obj, HistoryVisibility &event); |
| 51 | friend void to_json(nlohmann::json &obj, const HistoryVisibility &event); |
| 52 | }; |
| 53 | |
| 54 | } // namespace state |
| 55 | } // namespace events |
| 56 | } // namespace mtx |
| 57 | |