#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 #include #include #include #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 title; std::optional topic; std::string content; std::optional slug; std::string userId; std::int64_t stars = 0; std::optional image; Date createdAt{}; std::optional updatedAt; static Data fromJson(const Json& j); }; Data data; User author; Vote myVote; std::int64_t commentCount = 0; std::vector recentComments; bool bookmarked = false; std::vector attachments; std::optional 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& newComments) const; }; } // namespace dp