0
0
Fork 0

Add reblogs and favourites counts to statuses in ActivityPub (#32007)

This commit is contained in:
Eugen Rochko 2024-09-23 15:14:15 +02:00 committed by GitHub
parent b5bdc69f7b
commit aaab6b7adc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 105 additions and 1 deletions

View file

@ -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,22 @@ class ActivityPub::NoteSerializer < ActivityPub::Serializer
)
end
def likes
ActivityPub::CollectionPresenter.new(
id: ActivityPub::TagManager.instance.likes_uri_for(object),
type: :unordered,
size: object.favourites_count
)
end
def shares
ActivityPub::CollectionPresenter.new(
id: ActivityPub::TagManager.instance.shares_uri_for(object),
type: :unordered,
size: object.reblogs_count
)
end
def language?
object.language.present?
end