Skip to content
Snippets Groups Projects
join_rules.hpp 1.2 KiB
Newer Older
  • Learn to ignore specific revisions
  • /// @file
    /// @brief Manage the permission of how people can join a room.
    
    
    #if __has_include(<nlohmann/json_fwd.hpp>)
    #include <nlohmann/json_fwd.hpp>
    #else
    
    #include <nlohmann/json.hpp>
    
    #include <string>
    
    
    namespace mtx {
    namespace events {
    namespace state {
    
    //! The different JoinRules
    
    enum class JoinRule
    {
            //! Anyone can join the room without any prior action.
            Public,
            //! A user who wishes to join the room must first receive
            //! an invite to the room from someone already inside of the room.
            Invite,
            //! Reserved but not yet implemented by the Matrix specification.
            Knock,
            //! Reserved but not yet implemented by the Matrix specification.
            Private,
    };
    
    std::string
    joinRuleToString(const JoinRule &rule);
    
    JoinRule
    stringToJoinRule(const std::string &rule);
    
    //! Content of the `m.room.join_rules` state event.
    struct JoinRules
    {
            //! The type of rules used for users wishing to join this room.
            JoinRule join_rule;
    };
    
    void
    
    from_json(const nlohmann::json &obj, JoinRules &join_rules);
    
    to_json(nlohmann::json &obj, const JoinRules &join_rules);
    
    
    } // namespace state
    } // namespace events
    } // namespace mtx