summary refs log tree commit diff
path: root/include/Cache.h
diff options
context:
space:
mode:
authortwahm <39034410+twahm@users.noreply.github.com>2018-05-12 17:31:58 -0500
committermujx <mujx@users.noreply.github.com>2018-05-13 01:31:58 +0300
commit4bd43780d9497daa5e1af7f7a450d25c18377819 (patch)
tree95ef5443c02fb7f40a4c3d6bd5c42b7ccb980cb8 /include/Cache.h
parentUse the correct avatar size for HiDPI displays (diff)
downloadnheko-4bd43780d9497daa5e1af7f7a450d25c18377819.tar.xz
Add read support for room access options (#324)
- Join rules
- Guest access
Diffstat (limited to 'include/Cache.h')
-rw-r--r--include/Cache.h28
1 files changed, 20 insertions, 8 deletions
diff --git a/include/Cache.h b/include/Cache.h

index a39633a8..20f277a9 100644 --- a/include/Cache.h +++ b/include/Cache.h
@@ -22,7 +22,9 @@ #include <QImage> #include <json.hpp> #include <lmdb++.h> +#include <mtx/events/join_rules.hpp> #include <mtx/responses.hpp> +using mtx::events::state::JoinRule; struct RoomMember { @@ -74,15 +76,20 @@ struct RoomInfo bool is_invite = false; //! Total number of members in the room. int16_t member_count = 0; + //! Who can access to the room. + JoinRule join_rule = JoinRule::Public; + bool guest_access = false; }; inline void to_json(json &j, const RoomInfo &info) { - j["name"] = info.name; - j["topic"] = info.topic; - j["avatar_url"] = info.avatar_url; - j["is_invite"] = info.is_invite; + j["name"] = info.name; + j["topic"] = info.topic; + j["avatar_url"] = info.avatar_url; + j["is_invite"] = info.is_invite; + j["join_rule"] = info.join_rule; + j["guest_access"] = info.guest_access; if (info.member_count != 0) j["member_count"] = info.member_count; @@ -91,10 +98,12 @@ to_json(json &j, const RoomInfo &info) inline void from_json(const json &j, RoomInfo &info) { - info.name = j.at("name"); - info.topic = j.at("topic"); - info.avatar_url = j.at("avatar_url"); - info.is_invite = j.at("is_invite"); + info.name = j.at("name"); + info.topic = j.at("topic"); + info.avatar_url = j.at("avatar_url"); + info.is_invite = j.at("is_invite"); + info.join_rule = j.at("join_rule"); + info.guest_access = j.at("guest_access"); if (j.count("member_count")) info.member_count = j.at("member_count"); @@ -164,6 +173,9 @@ public: //! Calculate & return the name of the room. QString getRoomName(lmdb::txn &txn, lmdb::dbi &statesdb, lmdb::dbi &membersdb); + //! Get room join rules + JoinRule getRoomJoinRule(lmdb::txn &txn, lmdb::dbi &statesdb); + bool getRoomGuestAccess(lmdb::txn &txn, lmdb::dbi &statesdb); //! Retrieve the topic of the room if any. QString getRoomTopic(lmdb::txn &txn, lmdb::dbi &statesdb); //! Retrieve the room avatar's url if any.