1 | #include "mtx/events/nheko_extensions/hidden_events.hpp" |
---|---|
2 | |
3 | #include <nlohmann/json.hpp> |
4 | |
5 | namespace mtx { |
6 | namespace events { |
7 | namespace account_data { |
8 | namespace nheko_extensions { |
9 | |
10 | void |
11 | from_json(const nlohmann::json &obj, HiddenEvents &content) |
12 | { |
13 | if (obj.contains(key: "hidden_event_types")) { |
14 | content.hidden_event_types = std::vector<EventType>{}; |
15 | for (const auto &typeStr : obj.at(key: "hidden_event_types")) { |
16 | auto type = getEventType(type: typeStr.get<std::string>()); |
17 | content.hidden_event_types->push_back(x: type); |
18 | } |
19 | } |
20 | } |
21 | |
22 | void |
23 | to_json(nlohmann::json &obj, const HiddenEvents &content) |
24 | { |
25 | if (content.hidden_event_types) { |
26 | for (auto type : content.hidden_event_types.value()) { |
27 | obj["hidden_event_types"].push_back(val: to_string(type)); |
28 | } |
29 | } |
30 | } |
31 | } |
32 | } // namespace account_data |
33 | } // namespace events |
34 | } // namespace mtx |
35 |