aboutsummaryrefslogtreecommitdiffstats
path: root/src/activitypub/apactivity.h
diff options
context:
space:
mode:
authorConfuSomu2023-07-05 15:14:46 +0200
committerConfuSomu2023-07-05 15:14:46 +0200
commite515ca109faa897e84be8a97a1240c59df612dd4 (patch)
tree2a5e0593bb4387449a9a60fb2aefcc74779b5c67 /src/activitypub/apactivity.h
parent0dfab2456b2dcd33f1879ac7d5606dd65cdb8e40 (diff)
downloadActorViewer-e515ca109faa897e84be8a97a1240c59df612dd4.tar
ActorViewer-e515ca109faa897e84be8a97a1240c59df612dd4.tar.gz
ActorViewer-e515ca109faa897e84be8a97a1240c59df612dd4.zip
Implement a small library of ActivityPub objects
These objects allow, and will allow us, to move HTML rendering out of the archive parser and into separate classes. Each of the derived classes specialise HTML rendering for their specific requirements. Furthermore, these ActivityPub objects will be able to be expanded upon and have support to be written to disk, in a database, for instance. Separating ActivityPub object retrieving from rendering allows us to implement other retrieving sources and methods, such as downloading posts from a configured remote instance.
Diffstat (limited to 'src/activitypub/apactivity.h')
-rw-r--r--src/activitypub/apactivity.h45
1 files changed, 45 insertions, 0 deletions
diff --git a/src/activitypub/apactivity.h b/src/activitypub/apactivity.h
new file mode 100644
index 0000000..fcfb86c
--- /dev/null
+++ b/src/activitypub/apactivity.h
@@ -0,0 +1,45 @@
+#pragma once
+
+#include "apactor.h"
+#include "apbase.h"
+#include "apobject.h"
+#include "../types.h"
+#include <QDateTime>
+
+enum struct APActivityType {CREATE, ANNOUNCE, UNKNOWN};
+
+struct APActivityFields {
+ QString by_actor;
+ QStringList to_actors;
+ QStringList cc_actors;
+ QString object_url; // maps to "id", represents the Activity, *not* the URL of the object it contains
+ QString published;
+ APObject* object; // will generally be a APPost or APReblog
+ StatusType visibility;
+ APActivityType type = APActivityType::UNKNOWN;
+};
+
+class APActivity : APBase {
+public:
+ APActivity();
+
+ // An Activity that can easily be constructed from an ActivityStreams JSON Activity. Make sure to pass the APObject.
+ APActivity(APActivityFields fields);
+ ~APActivity();
+
+ APObject* object = nullptr; // the object that's manipulated by this Activity, use APPost for something useful and "manually" create it
+
+ QString get_html_render(HtmlRenderDetails render_info);
+
+private:
+ APActorList to_actors;
+ APActorList cc_actors;
+ APActor by_actor; // the Actor who did this Activity, maps to "actor"
+
+ APActivityType type;
+ StatusType visibility;
+
+ //QString object_url; // activity's URL, maps to "id"
+
+ QDateTime published;
+};