diff options
| author | Andrew Branson <andrew.branson@jolla.com> | 2026-02-12 12:34:14 +0100 |
|---|---|---|
| committer | Andrew Branson <andrew.branson@jolla.com> | 2026-02-12 15:05:57 +0100 |
| commit | bce74e963abeb96a9c335f5461611dee544abc4c (patch) | |
| tree | ca584a97f1094212c79942702c6b96f6c66029c0 /common | |
| parent | 6ec21cf79e0103b874086089673800bd32fc6bea (diff) | |
Enhance Mastodon post actions and metadata handling for reblogs and favourites
Diffstat (limited to 'common')
| -rw-r--r-- | common/mastodonpostsdatabase.cpp | 22 | ||||
| -rw-r--r-- | common/mastodonpostsdatabase.h | 3 |
2 files changed, 25 insertions, 0 deletions
diff --git a/common/mastodonpostsdatabase.cpp b/common/mastodonpostsdatabase.cpp index ee04327..7f82162 100644 --- a/common/mastodonpostsdatabase.cpp +++ b/common/mastodonpostsdatabase.cpp @@ -25,6 +25,8 @@ static const char *BOOSTED_BY_KEY = "boosted_by"; static const char *REPLIES_COUNT_KEY = "replies_count"; static const char *FAVOURITES_COUNT_KEY = "favourites_count"; static const char *REBLOGS_COUNT_KEY = "reblogs_count"; +static const char *FAVOURITED_KEY = "favourited"; +static const char *REBLOGGED_KEY = "reblogged"; static const char *INSTANCE_URL_KEY = "instance_url"; MastodonPostsDatabase::MastodonPostsDatabase() @@ -49,6 +51,8 @@ void MastodonPostsDatabase::addMastodonPost( int repliesCount, int favouritesCount, int reblogsCount, + bool favourited, + bool reblogged, const QString &instanceUrl, int account) { @@ -59,6 +63,8 @@ void MastodonPostsDatabase::addMastodonPost( extra.insert(REPLIES_COUNT_KEY, repliesCount); extra.insert(FAVOURITES_COUNT_KEY, favouritesCount); extra.insert(REBLOGS_COUNT_KEY, reblogsCount); + extra.insert(FAVOURITED_KEY, favourited); + extra.insert(REBLOGGED_KEY, reblogged); extra.insert(INSTANCE_URL_KEY, instanceUrl); addPost(identifier, name, body, timestamp, icon, images, extra, account); } @@ -111,6 +117,22 @@ int MastodonPostsDatabase::reblogsCount(const SocialPost::ConstPtr &post) return post->extra().value(REBLOGS_COUNT_KEY).toInt(); } +bool MastodonPostsDatabase::favourited(const SocialPost::ConstPtr &post) +{ + if (post.isNull()) { + return false; + } + return post->extra().value(FAVOURITED_KEY).toBool(); +} + +bool MastodonPostsDatabase::reblogged(const SocialPost::ConstPtr &post) +{ + if (post.isNull()) { + return false; + } + return post->extra().value(REBLOGGED_KEY).toBool(); +} + QString MastodonPostsDatabase::instanceUrl(const SocialPost::ConstPtr &post) { if (post.isNull()) { diff --git a/common/mastodonpostsdatabase.h b/common/mastodonpostsdatabase.h index 66d3f09..9736fa8 100644 --- a/common/mastodonpostsdatabase.h +++ b/common/mastodonpostsdatabase.h @@ -35,6 +35,7 @@ public: const QList<QPair<QString, SocialPostImage::ImageType> > &images, const QString &url, const QString &boostedBy, int repliesCount, int favouritesCount, int reblogsCount, + bool favourited, bool reblogged, const QString &instanceUrl, int account); @@ -44,6 +45,8 @@ public: static int repliesCount(const SocialPost::ConstPtr &post); static int favouritesCount(const SocialPost::ConstPtr &post); static int reblogsCount(const SocialPost::ConstPtr &post); + static bool favourited(const SocialPost::ConstPtr &post); + static bool reblogged(const SocialPost::ConstPtr &post); static QString instanceUrl(const SocialPost::ConstPtr &post); }; |
