blob: ebd9d18caf43d83b98b4f676b837aa3c0b291ae8 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
#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}}", "<i>Unknown</i>"); 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<AppSettingsTypes::Timezone>("ui/timezone") ? published.toUTC() : published.toLocalTime()
));
return html;
}
|