aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorConfuSomu2023-09-12 10:08:19 -0400
committerConfuSomu2023-09-12 10:08:19 -0400
commit80a658f062328ab8b47dc6b2557d274f51278b3a (patch)
treeca590656dd14c80bd467031bac4b5d6749006708
parent40fd76d5b992fb868b44a6f76152655a0408e37b (diff)
downloadActorViewer-80a658f062328ab8b47dc6b2557d274f51278b3a.tar
ActorViewer-80a658f062328ab8b47dc6b2557d274f51278b3a.tar.gz
ActorViewer-80a658f062328ab8b47dc6b2557d274f51278b3a.zip
Define archive item ref type for Archive classes
This type allows extension and the implementation of a more complete archive item reference system in the future as it allows going beyond ints.
-rw-r--r--src/archive/base_archive.h7
-rw-r--r--src/archive/mastodon.cpp8
-rw-r--r--src/archive/mastodon.h4
3 files changed, 10 insertions, 9 deletions
diff --git a/src/archive/base_archive.h b/src/archive/base_archive.h
index a6bf98f..7d52cd5 100644
--- a/src/archive/base_archive.h
+++ b/src/archive/base_archive.h
@@ -22,6 +22,8 @@ public:
JsonNotActivityStream // for ActivityPub archives
};
+ typedef int ArchiveItemRef;
+
struct Hinting_t {
StatusType status_type = UNKNOWN;
};
@@ -32,9 +34,8 @@ public:
static Archive* create_archive(ArchiveType archive_type, const QString& main_filename);
virtual void update_status_list(ViewStatusTypes allowed_types, QListWidget *parent) = 0;
- // TODO: use a index type instead of a bare int as the former can be extended
- virtual APActivity* get_activity(int index, Hinting_t hinting) = 0;
- virtual const QString get_html_status_text(int status_index) = 0;
+ virtual APActivity* get_activity(ArchiveItemRef index, Hinting_t hinting) = 0;
+ virtual const QString get_html_status_text(ArchiveItemRef status_index) = 0;
virtual const QString get_instance_address();
protected:
diff --git a/src/archive/mastodon.cpp b/src/archive/mastodon.cpp
index 238b861..50253c6 100644
--- a/src/archive/mastodon.cpp
+++ b/src/archive/mastodon.cpp
@@ -237,9 +237,9 @@ std::vector<APAttachmentFields> MastodonArchive::get_status_attachments_list(QJs
return list;
}
-APActivity* MastodonArchive::get_activity(int status_index, Hinting_t hinting) {
+APActivity* MastodonArchive::get_activity(ArchiveItemRef index, Hinting_t hinting) {
// the JSON AP Activity
- QJsonObject activity = outbox_items->at(status_index).toObject();
+ QJsonObject activity = outbox_items->at(index).toObject();
APActivityFields act_fields = {
.visibility = hinting.status_type
@@ -334,9 +334,9 @@ APActivity* MastodonArchive::get_activity(int status_index, Hinting_t hinting) {
}
// TODO: make this use an APActivity object that will be present as an StatusListItem member.
-const QString MastodonArchive::get_html_status_text(int status_index) {
+const QString MastodonArchive::get_html_status_text(ArchiveItemRef index) {
QString text("");
- QJsonObject obj = outbox_items->at(status_index).toObject();
+ QJsonObject obj = outbox_items->at(index).toObject();
if (obj["object"].isObject()) {
QJsonObject activity = obj["object"].toObject();
diff --git a/src/archive/mastodon.h b/src/archive/mastodon.h
index bc9da3e..0d57d7a 100644
--- a/src/archive/mastodon.h
+++ b/src/archive/mastodon.h
@@ -18,8 +18,8 @@ public:
std::variant<QString, InitError> init();
void update_status_list(ViewStatusTypes allowed_types, QListWidget *parent);
- APActivity* get_activity(int index, Hinting_t hinting = {});
- const QString get_html_status_text(int status_index);
+ APActivity* get_activity(ArchiveItemRef index, Hinting_t hinting = {});
+ const QString get_html_status_text(ArchiveItemRef status_index);
const QString get_instance_address();
private:
QDir archive_root_dir;