#include "model/Notification.hpp" #include "core/JsonDecode.hpp" namespace dp { Notification::Data Notification::Data::fromJson(const Json& j) { using D = JsonDecode; Data d; d.id = D::req(j, "uid"); d.type = NotificationType::fromRaw(D::req(j, "type")); d.message = D::req(j, "message"); d.read = D::req(j, "read"); d.relatedId = D::req(j, "related_uid"); d.targetUrl = D::req(j, "target_url"); d.createdAt = D::reqDate(j, "created_at"); return d; } Notification Notification::fromJson(const Json& j) { using D = JsonDecode; Notification n; n.data = Data::fromJson(D::child(j, "notification")); if (const Json* actor = JsonRead::child(j, "actor")) n.actor = User::fromJson(*actor); return n; } } // namespace dp