diff --git a/models.cpp b/models.cpp index 65c8a1c..6756bc8 100644 --- a/models.cpp +++ b/models.cpp @@ -32,6 +32,11 @@ static std::regex host_regex(R"EOF(https?://([a-z0-9-.]+)/.+)EOF", std::regex::E void from_json(const json& j, Account& account) { using namespace std::string_literals; + // https://dlx.pink/notice/AbtdJkjioOo8ZSdDhw + if (j.size() == 0) { + return; + } + j.at("id").get_to(account.id); j.at("username").get_to(account.username); j.at("display_name").get_to(account.display_name); diff --git a/routes/status.cpp b/routes/status.cpp index e23d2bb..4014d26 100644 --- a/routes/status.cpp +++ b/routes/status.cpp @@ -32,7 +32,8 @@ void status_route(const httplib::Request& req, httplib::Response& res) { return; } - if (post->reblog) { + // https://dlx.pink/notice/AbtdJkjioOo8ZSdDhw + if (post->reblog && !post->reblog->account.id.empty()) { serve_redirect(req, res, get_origin(req) + '/' + server + "/@" + post->reblog->account.acct(false) + '/' + post->reblog->id, true); return; } diff --git a/servehelper.cpp b/servehelper.cpp index 602902f..efbb9bd 100644 --- a/servehelper.cpp +++ b/servehelper.cpp @@ -478,13 +478,13 @@ static Element serialize_post(const httplib::Request& req, const std::string& se Element div("div", {{"class", "post"}}, { Element("div", {{"class", "post-header"}}, { - Element("a", {{"href", get_origin(req) + '/' + server + "/@" + post.account.acct(false)}}, { + !post.account.id.empty() ? Element("a", {{"href", get_origin(req) + '/' + server + "/@" + post.account.acct(false)}}, { Element("img", {{"class", "post-avatar"}, {"alt", "User profile picture"}, {"loading", "lazy"}, {"src", post.account.avatar_static}}, {}), Element("span", { Element("b", {preprocess_html(req, post.account.emojis, post.account.display_name)}), Element("br"), "@", post.account.acct(), }), - }), + }) : Element("b", {"Unknown user"}), Element("a", {{"class", "post-time_header"}, {"href", get_origin(req) + '/' + server + "/@" + post.account.acct(false) + '/' + post.id + "#m"}, {"title", time_title}}, { Element("time", {{"datetime", to_rfc3339(post.created_at)}}, {relative_time(post.created_at, current_time()), time_badge}), }),