| 1 | #pragma once |
| 2 | |
| 3 | /// @file |
| 4 | /// @brief An event describing, if guest accounts can join a room. |
| 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 | |
| 18 | //! The different access states for a room. |
| 19 | enum class AccessState |
| 20 | { |
| 21 | CanJoin, //! Joining is allowd (for guests) |
| 22 | Forbidden, //! Guests can't join. |
| 23 | }; |
| 24 | |
| 25 | //! Converts @p AccessState to @p std::string for serialization. |
| 26 | std::string |
| 27 | accessStateToString(AccessState state); |
| 28 | |
| 29 | //! Converts @p std::string to @p AccessState for deserialization. |
| 30 | AccessState |
| 31 | stringToAccessState(const std::string &state); |
| 32 | |
| 33 | //! Content of the `m.room.guest_access` state event. |
| 34 | struct GuestAccess |
| 35 | { |
| 36 | //! Whether guests can join the room. |
| 37 | AccessState guest_access = AccessState::Forbidden; |
| 38 | |
| 39 | friend void from_json(const nlohmann::json &obj, GuestAccess &guest_access); |
| 40 | friend void to_json(nlohmann::json &obj, const GuestAccess &guest_access); |
| 41 | }; |
| 42 | |
| 43 | } // namespace state |
| 44 | } // namespace events |
| 45 | } // namespace mtx |
| 46 | |