Skip to content
Snippets Groups Projects
hidden_events.cpp 940 B
Newer Older
#include "mtx/events/nheko_extensions/hidden_events.hpp"

namespace mtx {
namespace events {
namespace account_data {
namespace nheko_extensions {

void
from_json(const nlohmann::json &obj, HiddenEvents &content)
{
    if (obj.contains("hidden_event_types")) {
        content.hidden_event_types = std::vector<EventType>{};
        for (const auto &typeStr : obj.at("hidden_event_types")) {
            if (auto type = getEventType(typeStr.get<std::string>());
                type != EventType::Unsupported)
                content.hidden_event_types->push_back(type);
        }
}

void
to_json(nlohmann::json &obj, const HiddenEvents &content)
{
    if (content.hidden_event_types) {
        for (auto type : content.hidden_event_types.value()) {
            obj["hidden_event_types"].push_back(to_string(type));
        }
}
}
} // namespace account_data
} // namespace events
} // namespace mtx