Repos
C++
1.4 KB51 lines Opens in site
Directory
Raw
Download
#pragma once
// Spec: models.md Post (+ Model Updates). Wire wrapper: post, author, my_vote, comment_count, recent_comments,
// bookmarked, attachments, poll?, reactions. Post.Data.topic stays a raw string.
#include <cstdint>
#include <optional>
#include <string>
#include <vector>
#include "core/Date.hpp"
#include "core/Json.hpp"
#include "model/Attachment.hpp"
#include "model/Comment.hpp"
#include "model/Poll.hpp"
#include "model/Reactions.hpp"
#include "model/User.hpp"
#include "model/Vote.hpp"
namespace dp {
struct Post {
struct Data {
std::string id;
std::optional<std::string> title;
std::optional<std::string> topic;
std::string content;
std::optional<std::string> slug;
std::string userId;
std::int64_t stars = 0;
std::optional<std::string> image;
Date createdAt{};
std::optional<Date> updatedAt;
static Data fromJson(const Json& j);
};
Data data;
User author;
Vote myVote;
std::int64_t commentCount = 0;
std::vector<Comment> recentComments;
bool bookmarked = false;
std::vector<Attachment> attachments;
std::optional<Poll> poll;
Reactions reactions;
static Post fromJson(const Json& j);
std::string id() const { return "post:" + data.id; }
Post replacingReactions(const Reactions& newReactions) const;
Post replacingRecentComments(const std::vector<Comment>& newComments) const;
};
} // namespace dp