#pragma once // Spec: models.md PostDetail (+ Model Updates `with`). Wire is flat: post, author, is_owner, star_count, my_vote, ... #include #include #include #include #include "core/Json.hpp" #include "model/Attachment.hpp" #include "model/Comment.hpp" #include "model/Poll.hpp" #include "model/Post.hpp" #include "model/Reactions.hpp" #include "model/User.hpp" #include "model/Vote.hpp" namespace dp { struct PostDetail { Post::Data post; User author; bool isOwner = false; std::int64_t starCount = 0; Vote myVote; std::vector comments; std::vector attachments; bool bookmarked = false; std::optional poll; std::int64_t commentCount = 0; std::vector relatedPosts; std::vector topics; Reactions reactions; static PostDetail fromJson(const Json& j); std::string id() const { return "post:" + post.id; } // Copy with some fields replaced; nullopt keeps the current value. PostDetail with(std::optional myVote = std::nullopt, std::optional starCount = std::nullopt, std::optional> comments = std::nullopt, std::optional reactions = std::nullopt) const; }; } // namespace dp