| 1 | #pragma once |
| 2 | |
| 3 | /// @file |
| 4 | /// @brief A nheko specific event in account data used to block or allow list invites. |
| 5 | |
| 6 | #include <map> |
| 7 | #include <string> |
| 8 | |
| 9 | #if __has_include(<nlohmann/json_fwd.hpp>) |
| 10 | #include <nlohmann/json_fwd.hpp> |
| 11 | #else |
| 12 | #include <nlohmann/json.hpp> |
| 13 | #endif |
| 14 | |
| 15 | namespace mtx { |
| 16 | namespace events { |
| 17 | namespace account_data { |
| 18 | namespace nheko_extensions { |
| 19 | //! Custom event to allow or block invites. |
| 20 | struct InvitePermissions |
| 21 | { |
| 22 | //! Default permissions |
| 23 | std::string default_; |
| 24 | |
| 25 | //! Server allowed to invite |
| 26 | std::map<std::string, std::string, std::less<>> server_allow; |
| 27 | //! Server denied from inviting |
| 28 | std::map<std::string, std::string, std::less<>> server_deny; |
| 29 | |
| 30 | //! Rooms the user accepts invites to |
| 31 | std::map<std::string, std::string, std::less<>> room_allow; |
| 32 | //! Rooms the user blocks invites to |
| 33 | std::map<std::string, std::string, std::less<>> room_deny; |
| 34 | |
| 35 | //! Users the user is accepting invites from |
| 36 | std::map<std::string, std::string, std::less<>> user_allow; |
| 37 | //! Users the user is blocking invites from |
| 38 | std::map<std::string, std::string, std::less<>> user_deny; |
| 39 | |
| 40 | [[nodiscard]] bool invite_allowed(std::string_view room_id, std::string_view inviter) const; |
| 41 | |
| 42 | friend void from_json(const nlohmann::json &obj, InvitePermissions &content); |
| 43 | friend void to_json(nlohmann::json &obj, const InvitePermissions &content); |
| 44 | }; |
| 45 | } |
| 46 | } // namespace account_data |
| 47 | } // namespace events |
| 48 | } // namespace mtx |