90 lines
2.2 KiB
C++
90 lines
2.2 KiB
C++
#pragma once
|
|
|
|
#include <string>
|
|
#include <vector>
|
|
#include <memory>
|
|
#include <nlohmann/json_fwd.hpp>
|
|
|
|
#include "blankie/serializer.h"
|
|
|
|
enum PostSortingMethod {
|
|
Posts = 0,
|
|
PostsAndReplies,
|
|
MediaOnly,
|
|
};
|
|
|
|
struct Emoji {
|
|
std::string shortcode;
|
|
std::string url;
|
|
};
|
|
|
|
struct AccountField {
|
|
std::string name;
|
|
blankie::html::HTMLString value_html;
|
|
time_t verified_at; // negative is not verified
|
|
};
|
|
struct Account {
|
|
std::string id;
|
|
std::string username;
|
|
std::string server;
|
|
bool same_server;
|
|
std::string display_name;
|
|
time_t created_at;
|
|
blankie::html::HTMLString note_html;
|
|
std::string avatar;
|
|
std::string avatar_static;
|
|
std::string header;
|
|
int64_t followers_count;
|
|
uint64_t following_count;
|
|
uint64_t statuses_count;
|
|
std::vector<Emoji> emojis;
|
|
std::vector<AccountField> fields;
|
|
|
|
constexpr std::string acct(bool always_show_domain = true) const {
|
|
std::string res = this->username;
|
|
if (always_show_domain || !this->same_server) {
|
|
res += '@';
|
|
res += this->server;
|
|
}
|
|
return res;
|
|
}
|
|
};
|
|
|
|
struct Media {
|
|
std::string type;
|
|
std::string url;
|
|
std::optional<std::string> preview_url;
|
|
std::optional<std::string> remote_url;
|
|
std::optional<std::string> description;
|
|
};
|
|
|
|
struct Post {
|
|
std::string id;
|
|
time_t created_at;
|
|
std::optional<std::string> in_reply_to_id;
|
|
std::optional<std::string> in_reply_to_account_id;
|
|
bool sensitive;
|
|
std::string spoiler_text;
|
|
uint64_t replies_count;
|
|
uint64_t reblogs_count;
|
|
uint64_t favorites_count;
|
|
time_t edited_at; // negative is not edited
|
|
blankie::html::HTMLString content;
|
|
std::unique_ptr<Post> reblog;
|
|
Account account;
|
|
std::vector<Media> media_attachments;
|
|
std::vector<Emoji> emojis;
|
|
};
|
|
|
|
struct PostContext {
|
|
std::vector<Post> ancestors;
|
|
std::vector<Post> descendants;
|
|
};
|
|
|
|
void from_json(const nlohmann::json& j, Emoji& emoji);
|
|
void from_json(const nlohmann::json& j, AccountField& field);
|
|
void from_json(const nlohmann::json& j, Account& account);
|
|
void from_json(const nlohmann::json& j, Media& media);
|
|
void from_json(const nlohmann::json& j, Post& post);
|
|
void from_json(const nlohmann::json& j, PostContext& context);
|