summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2024-09-20 19:29:42 +0200
committerEugen Rochko <eugen@zeonfederated.com>2024-09-20 19:29:42 +0200
commita31cfe909c148aa1e9590d99f7d0b9df1f3c061d (patch)
treeb3d370a46244069c103849d3a71420a8058931a0
parent7ed9c590b98610f8d68deab9ef8df260eec6d8f0 (diff)
Add reblogs and favourites counts to statuses in ActivityPubfeature-note-likes-shares
-rw-r--r--app/serializers/activitypub/note_serializer.rb16
1 files changed, 16 insertions, 0 deletions
diff --git a/app/serializers/activitypub/note_serializer.rb b/app/serializers/activitypub/note_serializer.rb
index 27e058199d6..ca48d1c2b09 100644
--- a/app/serializers/activitypub/note_serializer.rb
+++ b/app/serializers/activitypub/note_serializer.rb
@@ -19,6 +19,8 @@ class ActivityPub::NoteSerializer < ActivityPub::Serializer
has_many :virtual_tags, key: :tag
has_one :replies, serializer: ActivityPub::CollectionSerializer, if: :local?
+ has_one :likes, serializer: ActivityPub::CollectionSerializer, if: :local?
+ has_one :shares, serializer: ActivityPub::CollectionSerializer, if: :local?
has_many :poll_options, key: :one_of, if: :poll_and_not_multiple?
has_many :poll_options, key: :any_of, if: :poll_and_multiple?
@@ -64,6 +66,20 @@ class ActivityPub::NoteSerializer < ActivityPub::Serializer
)
end
+ def likes
+ ActivityPub::CollectionPresenter.new(
+ type: :unordered,
+ size: object.favourites_count
+ )
+ end
+
+ def shares
+ ActivityPub::CollectionPresenter.new(
+ type: :unordered,
+ size: object.reblogs_count
+ )
+ end
+
def language?
object.language.present?
end