| 1 | #pragma once |
| 2 | |
| 3 | /// @file |
| 4 | /// @brief The state event describing the membership status of a specific member. |
| 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 Membership states. |
| 18 | enum class Membership |
| 19 | { |
| 20 | //! The user has joined. |
| 21 | Join, |
| 22 | //! The user has been invited. |
| 23 | Invite, |
| 24 | //! The user is banned. |
| 25 | Ban, |
| 26 | //! The user has left. |
| 27 | Leave, |
| 28 | //! The user has requested to join. |
| 29 | Knock, |
| 30 | }; |
| 31 | |
| 32 | std::string |
| 33 | membershipToString(const Membership &membership); |
| 34 | |
| 35 | Membership |
| 36 | stringToMembership(const std::string &membership); |
| 37 | |
| 38 | //! Content of the `m.room.member` state event. |
| 39 | struct Member |
| 40 | { |
| 41 | //! The membership state of the user. |
| 42 | Membership membership; |
| 43 | //! The avatar URL for this user, if any. |
| 44 | std::string avatar_url; |
| 45 | //! The display name for this user, if any. |
| 46 | std::string display_name; |
| 47 | //! Flag indicating if the room containing this event was created |
| 48 | //! with the intention of being a direct chat. |
| 49 | bool is_direct = false; |
| 50 | |
| 51 | //! reason for the membership change, empty in most cases |
| 52 | std::string reason; |
| 53 | |
| 54 | //! In a restricted room, on what user was used to authorize the join. |
| 55 | std::string join_authorised_via_users_server; |
| 56 | |
| 57 | /* ThirdPartyInvite third_party_invite; */ |
| 58 | |
| 59 | friend void from_json(const nlohmann::json &obj, Member &member); |
| 60 | friend void to_json(nlohmann::json &obj, const Member &member); |
| 61 | }; |
| 62 | |
| 63 | } // namespace state |
| 64 | } // namespace events |
| 65 | } // namespace mtx |
| 66 | |