#include "apactivity.h" #include "apactor.h" #include "src/settings_interface.h" APActivity::APActivity() {} APActivity::APActivity(APActivityFields fields) { for (QString actor_url : fields.to_actors) to_actors.push_back(APActor(actor_url)); for (QString actor_url : fields.cc_actors) cc_actors.push_back(APActor(actor_url)); by_actor = fields.by_actor; object_url = fields.object_url; published = QDateTime::fromString(fields.published, Qt::ISODate); visibility = fields.visibility; type = fields.type; object = fields.object; } QString APActivity::get_html_render(HtmlRenderDetails render_info) { QString html(get_html_template(QStringLiteral("apactivity"))); switch (type) { case APActivityType::CREATE: html.replace("{{type}}", "Create"); break; case APActivityType::ANNOUNCE: html.replace("{{type}}", "Announce"); break; default: html.replace("{{type}}", "Unknown"); break; } html.replace("{{by}}", by_actor.get_html_render(render_info)); html.replace("{{object}}", object->get_html_render(render_info)); if (published.isValid()) html.replace("{{published}}", render_info.locale->toString( SettingsInterface::quick_read_setting("ui/timezone") ? published.toUTC() : published.toLocalTime() )); return html; }