aboutsummaryrefslogtreecommitdiffstats
path: root/src/activitypub/apactivity.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/activitypub/apactivity.cpp')
-rw-r--r--src/activitypub/apactivity.cpp46
1 files changed, 46 insertions, 0 deletions
diff --git a/src/activitypub/apactivity.cpp b/src/activitypub/apactivity.cpp
new file mode 100644
index 0000000..5f1c36d
--- /dev/null
+++ b/src/activitypub/apactivity.cpp
@@ -0,0 +1,46 @@
+#include "apactivity.h"
+#include "apactor.h"
+
+#include <QDebug>
+
+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;
+}
+
+APActivity::~APActivity() {
+ delete object;
+}
+
+QString APActivity::get_html_render(HtmlRenderDetails render_info) {
+ QString html(get_html_template("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(published.toLocalTime()));
+
+ return html;
+}