1#include "mtx/events/policy_rules.hpp"
2
3#include <nlohmann/json.hpp>
4
5namespace mtx::events::state::policy_rule {
6void
7from_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
14void
15to_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
24void
25from_json(const nlohmann::json &obj, UserRule &rule)
26{
27 from_json(obj, rule&: static_cast<Rule &>(rule));
28}
29void
30to_json(nlohmann::json &obj, const UserRule &rule)
31{
32 to_json(obj, rule: static_cast<const Rule &>(rule));
33}
34void
35from_json(const nlohmann::json &obj, RoomRule &rule)
36{
37 from_json(obj, rule&: static_cast<Rule &>(rule));
38}
39void
40to_json(nlohmann::json &obj, const RoomRule &rule)
41{
42 to_json(obj, rule: static_cast<const Rule &>(rule));
43}
44void
45from_json(const nlohmann::json &obj, ServerRule &rule)
46{
47 from_json(obj, rule&: static_cast<Rule &>(rule));
48}
49void
50to_json(nlohmann::json &obj, const ServerRule &rule)
51{
52 to_json(obj, rule: static_cast<const Rule &>(rule));
53}
54}
55