Add reblogs and favourites counts to statuses in ActivityPub (#32007)
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user