aboutsummaryrefslogtreecommitdiffstats
path: root/src/activitypub/appost.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/appost.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/appost.h')
-rw-r--r--src/activitypub/appost.h43
1 files changed, 43 insertions, 0 deletions
diff --git a/src/activitypub/appost.h b/src/activitypub/appost.h
new file mode 100644
index 0000000..a8b99c5
--- /dev/null
+++ b/src/activitypub/appost.h
@@ -0,0 +1,43 @@
+#pragma once
+
+#include "apobject.h"
+#include "src/activitypub/apbase.h"
+#include "src/types.h"
+#include <vector>
+
+// All these fields (including APAttachmentFields, etc. in other files) are made to map to the fields present in the ActivityStream JSON's "object" for very easy construction.
+// There are additional fields that we don't use so they are not included in the objects (including parent and APActivity).
+
+struct APObjectFields {
+ QStringList to_actors; // Start APObject
+ QStringList cc_actors;
+ QString by_actor;
+ QString object_url;
+ QString web_url;
+ QString reply_to_url;
+ QString published;
+ std::vector<APAttachmentFields> attachments; // End APObject
+ QStringList languages; // This is taken from "content_map"
+ QString content;
+ QString summary;
+ StatusType visibility; // status type discovery is better left to the archive/API parser as this can very between fedi implementations and archive formats
+};
+
+// APPost represents an ActivityPub Note Object
+class APPost : public APObject {
+public:
+ APPost();
+ // A post that will be built from strings, including attachments
+ APPost(APObjectFields fields);
+ ~APPost() {};
+
+ QString get_html_render(HtmlRenderDetails render_info);
+
+protected:
+ bool is_sensitive = false;
+ QString summary; // content warning
+ QStringList languages;
+ QString content;
+
+ QString get_html_status_languages();
+};