Skip to content
Snippets Groups Projects
Verified Commit 01c1856d authored by Nicolas Werner's avatar Nicolas Werner
Browse files

Add support for restricted join rules additions

parent 513196f5
No related branches found
No related tags found
No related merge requests found
......@@ -22,10 +22,13 @@ enum class JoinRule
//! 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.
//! the same as invite, except anyone can knock. See MSC2403.
Knock,
//! Reserved but not yet implemented by the Matrix specification.
Private,
//! the same as invite, except users may also join if they are a member of a room listed in
//! the allow rules.
Restricted,
};
std::string
......
......@@ -51,6 +51,9 @@ struct Member
//! reason for the membership change, empty in most cases
std::string reason;
//! In a restricted room, on what user was used to authorize the join.
std::string join_authorised_via_users_server;
/* ThirdPartyInvite third_party_invite; */
};
......
......@@ -21,6 +21,8 @@ joinRuleToString(const JoinRule &rule)
return "knock";
case JoinRule::Private:
return "private";
case JoinRule::Restricted:
return "restricted";
}
return "";
......@@ -35,6 +37,8 @@ stringToJoinRule(const std::string &rule)
return JoinRule::Invite;
else if (rule == "knock")
return JoinRule::Knock;
else if (rule == "restricted")
return JoinRule::Restricted;
return JoinRule::Private;
}
......
......@@ -59,6 +59,10 @@ from_json(const json &obj, Member &member)
if (obj.find("reason") != obj.end())
member.reason = obj.at("reason").get<std::string>();
if (obj.contains("join_authorised_via_users_server"))
member.join_authorised_via_users_server =
obj.at("join_authorised_via_users_server").get<std::string>();
}
void
......@@ -68,7 +72,12 @@ to_json(json &obj, const Member &member)
obj["avatar_url"] = member.avatar_url;
obj["displayname"] = member.display_name;
obj["is_direct"] = member.is_direct;
obj["reason"] = member.reason;
if (!member.reason.empty())
obj["reason"] = member.reason;
if (!member.join_authorised_via_users_server.empty())
obj["join_authorised_via_users_server"] = member.join_authorised_via_users_server;
}
} // namespace state
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment