Skip to content
Repos

DevPlaceApp

C++ 786 B33 lines Opens in site

Directory Raw Download

#pragma once
// Spec: models.md Notification. Wire wrapper: notification, actor?. Data.type is a wire string mapped to
// NotificationType, unknown values give nullopt.
#include <optional>
#include <string>

#include "core/Date.hpp"
#include "core/Json.hpp"
#include "model/NotificationType.hpp"
#include "model/User.hpp"

namespace dp {

struct Notification {
  struct Data {
    std::string id;
    std::optional<NotificationType> type;
    std::string message;
    bool read = false;
    std::string relatedId;
    std::string targetUrl;
    Date createdAt{};
    static Data fromJson(const Json& j);
  };

  Data data;
  std::optional<User> actor;

  static Notification fromJson(const Json& j);
  std::string id() const { return "notification:" + data.id; }
};

}  // namespace dp
28.8ms