| 1 | #include "mtx/events/policy_rules.hpp" |
| 2 | |
| 3 | #include <nlohmann/json.hpp> |
| 4 | |
| 5 | namespace mtx::events::state::policy_rule { |
| 6 | void |
| 7 | from_json(const nlohmann::json &obj, Rule &rule) |
| 8 | { |
| 9 | rule.entity = obj.value(key: "entity" , default_value: "" ); |
| 10 | rule.recommendation = obj.value(key: "recommendation" , default_value: "" ); |
| 11 | rule.reason = obj.value(key: "reason" , default_value: "" ); |
| 12 | } |
| 13 | |
| 14 | void |
| 15 | to_json(nlohmann::json &obj, const Rule &rule) |
| 16 | { |
| 17 | obj = nlohmann::json{ |
| 18 | {"entity" , rule.entity}, |
| 19 | {"recommendation" , rule.recommendation}, |
| 20 | {"reason" , rule.reason}, |
| 21 | }; |
| 22 | } |
| 23 | |
| 24 | void |
| 25 | from_json(const nlohmann::json &obj, UserRule &rule) |
| 26 | { |
| 27 | from_json(obj, rule&: static_cast<Rule &>(rule)); |
| 28 | } |
| 29 | void |
| 30 | to_json(nlohmann::json &obj, const UserRule &rule) |
| 31 | { |
| 32 | to_json(obj, rule: static_cast<const Rule &>(rule)); |
| 33 | } |
| 34 | void |
| 35 | from_json(const nlohmann::json &obj, RoomRule &rule) |
| 36 | { |
| 37 | from_json(obj, rule&: static_cast<Rule &>(rule)); |
| 38 | } |
| 39 | void |
| 40 | to_json(nlohmann::json &obj, const RoomRule &rule) |
| 41 | { |
| 42 | to_json(obj, rule: static_cast<const Rule &>(rule)); |
| 43 | } |
| 44 | void |
| 45 | from_json(const nlohmann::json &obj, ServerRule &rule) |
| 46 | { |
| 47 | from_json(obj, rule&: static_cast<Rule &>(rule)); |
| 48 | } |
| 49 | void |
| 50 | to_json(nlohmann::json &obj, const ServerRule &rule) |
| 51 | { |
| 52 | to_json(obj, rule: static_cast<const Rule &>(rule)); |
| 53 | } |
| 54 | } |
| 55 | |