aboutsummaryrefslogtreecommitdiffstats
path: root/src/archive/mastodon.cpp
diff options
context:
space:
mode:
authorConfuSomu2024-03-20 13:28:19 -0400
committerConfuSomu2024-03-20 13:28:19 -0400
commit4e59eadba3b0d4586a9122e6a825ea030a139c9a (patch)
tree6674c2b23ef6295e7a8d60bb034c3321e7a5a996 /src/archive/mastodon.cpp
parent0e32ef940e53c4f10d84762f2de6836025f87610 (diff)
downloadActorViewer-4e59eadba3b0d4586a9122e6a825ea030a139c9a.tar
ActorViewer-4e59eadba3b0d4586a9122e6a825ea030a139c9a.tar.gz
ActorViewer-4e59eadba3b0d4586a9122e6a825ea030a139c9a.zip
Use smart pointers with AP classes and Instance
Diffstat (limited to 'src/archive/mastodon.cpp')
-rw-r--r--src/archive/mastodon.cpp15
1 files changed, 8 insertions, 7 deletions
diff --git a/src/archive/mastodon.cpp b/src/archive/mastodon.cpp
index 121c366..044056c 100644
--- a/src/archive/mastodon.cpp
+++ b/src/archive/mastodon.cpp
@@ -1,4 +1,5 @@
#include "mastodon.h"
+#include "src/activitypub/apactor.h"
#include "src/list_item.h"
#include "src/types.h"
#include "src/activitypub/apactivity.h"
@@ -237,7 +238,7 @@ std::vector<APAttachmentFields> MastodonArchive::get_status_attachments_list(QJs
return list;
}
-APActivity* MastodonArchive::get_activity(ArchiveItemRef index, Hinting_t hinting) {
+APActivityPtr MastodonArchive::get_activity(ArchiveItemRef index, Hinting_t hinting) {
// the JSON AP Activity
QJsonObject activity = outbox_items->at(index).toObject();
@@ -320,17 +321,17 @@ APActivity* MastodonArchive::get_activity(ArchiveItemRef index, Hinting_t hintin
obj_url = activity["object"].toString();
if (not obj_url.isNull())
- act_fields.object = new APReblog({obj_url, act_fields.visibility});
+ act_fields.object = std::make_shared<APReblog>(APReblogFields {obj_url, act_fields.visibility});
else switch(obj_type) {
case APObjectType::UNKNOWN:
case APObjectType::NOTE:
- act_fields.object = new APPost(obj_fields); break;
+ act_fields.object = std::make_shared<APPost>(obj_fields); break;
case APObjectType::QUESTION:
- act_fields.object = new APQuestion(obj_fields); break;
+ act_fields.object = std::make_shared<APQuestion>(obj_fields); break;
}
// TODO: it is currently a waste to create this APActivity object that will be immediately destroyed but it allows us to extend archive parsing to something that will become abstract (and an abstract base class) and separate from display (the final goal) which will allow us to add other sources that feed us with posts, reblogs and Actor information. furthermore, these objects can be cached for reuse in a session.
- return new APActivity(act_fields);
+ return std::make_shared<APActivity>(act_fields);
}
// TODO: make this use an APActivity object that will be present as an StatusListItem member.
@@ -355,7 +356,7 @@ const QString MastodonArchive::get_html_status_text(ArchiveItemRef index) {
return text;
}
-APActor* MastodonArchive::get_main_actor() {
+APActorPtr MastodonArchive::get_main_actor() {
// Avoid recreating the Actor each time by caching it
if (actor) return actor;
@@ -436,7 +437,7 @@ APActor* MastodonArchive::get_main_actor() {
obj_fields.header = new APAttachment(att_fields);
}
- actor = new APActor(obj_fields);
+ actor = std::make_shared<APActor>(obj_fields);
// TODO: query type. it seems to be always "Person", but maybe if the account is a bot, it changes?
// The code also currently ignores possible featured tags and users