Add featured hashtags as an ActivityPub collection (#11595)
This commit is contained in:
parent
abc91e5fa6
commit
17340365bb
5 changed files with 49 additions and 16 deletions
|
@ -10,7 +10,7 @@ class ActivityPub::ActorSerializer < ActivityPub::Serializer
|
|||
:discoverable, :olm
|
||||
|
||||
attributes :id, :type, :following, :followers,
|
||||
:inbox, :outbox, :featured,
|
||||
:inbox, :outbox, :featured, :featured_tags,
|
||||
:preferred_username, :name, :summary,
|
||||
:url, :manually_approves_followers,
|
||||
:discoverable
|
||||
|
@ -81,6 +81,10 @@ class ActivityPub::ActorSerializer < ActivityPub::Serializer
|
|||
account_collection_url(object, :featured)
|
||||
end
|
||||
|
||||
def featured_tags
|
||||
account_collection_url(object, :tags)
|
||||
end
|
||||
|
||||
def endpoints
|
||||
object
|
||||
end
|
||||
|
|
|
@ -16,6 +16,8 @@ class ActivityPub::CollectionSerializer < ActivityPub::Serializer
|
|||
ActivityPub::NoteSerializer
|
||||
when 'Device'
|
||||
ActivityPub::DeviceSerializer
|
||||
when 'FeaturedTag'
|
||||
ActivityPub::HashtagSerializer
|
||||
when 'ActivityPub::CollectionPresenter'
|
||||
ActivityPub::CollectionSerializer
|
||||
when 'String'
|
||||
|
|
23
app/serializers/activitypub/hashtag_serializer.rb
Normal file
23
app/serializers/activitypub/hashtag_serializer.rb
Normal file
|
@ -0,0 +1,23 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class ActivityPub::HashtagSerializer < ActivityPub::Serializer
|
||||
include RoutingHelper
|
||||
|
||||
attributes :type, :href, :name
|
||||
|
||||
def type
|
||||
'Hashtag'
|
||||
end
|
||||
|
||||
def name
|
||||
"##{object.name}"
|
||||
end
|
||||
|
||||
def href
|
||||
if object.class.name == 'FeaturedTag'
|
||||
short_account_tag_url(object.account, object.tag)
|
||||
else
|
||||
tag_url(object)
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue