Debian Codegraph @

mtxclient/include/mtx/events/join_rules.hpp

raw symbols SCIP
1 #pragma once
2
3 /// @file
4 /// @brief Manage the permission of how people 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 //! The different JoinRules
18 enum class JoinRule
19 {
20 //! Anyone can join the room without any prior action.
21 Public,
22 //! A user who wishes to join the room must first receive
23 //! an invite to the room from someone already inside of the room.
24 Invite,
25 //! the same as invite, except anyone can knock. See MSC2403.
26 Knock,
27 //! Reserved but not yet implemented by the Matrix specification.
28 Private,
29 //! the same as invite, except users may also join if they are a member of a room listed in
30 //! the allow rules.
31 Restricted,
32 //! a user can request an invite using the same functions offered by the knock join rule, or can
33 //! attempt to join having satisfied an allow condition per the restricted join rule.
34 KnockRestricted,
35 };
36
37 std::string
38 joinRuleToString(const JoinRule &rule);
39
40 JoinRule
41 stringToJoinRule(const std::string &rule);
42
43 enum class JoinAllowanceType
44 {
45 RoomMembership,
46 Unknown,
47 };
48
49 //! An additional rule specifying what users are allowed to join.
50 struct JoinAllowance
51 {
52 //! "m.room_membership" to describe that we are allowing access via room membership. Future
53 //! MSCs may define other types.
54 JoinAllowanceType type;
55 //! The room ID to check the membership of.
56 std::string room_id;
57
58 friend void from_json(const nlohmann::json &obj, JoinAllowance &join_rules);
59 friend void to_json(nlohmann::json &obj, const JoinAllowance &join_rules);
60 };
61
62 //! Content of the `m.room.join_rules` state event.
63 struct JoinRules
64 {
65 //! The type of rules used for users wishing to join this room.
66 JoinRule join_rule;
67
68 //! A list of rooms to join via. Might be extended to other join types in the future.
69 //! Only relevant in combination with restricted joinrules atm.
70 std::vector<JoinAllowance> allow;
71
72 friend void from_json(const nlohmann::json &obj, JoinRules &join_rules);
73 friend void to_json(nlohmann::json &obj, const JoinRules &join_rules);
74 };
75
76 } // namespace state
77 } // namespace events
78 } // namespace mtx