diff options
Diffstat (limited to 'app/serializers')
4 files changed, 50 insertions, 2 deletions
diff --git a/app/serializers/activitypub/actor_serializer.rb b/app/serializers/activitypub/actor_serializer.rb index 627d4446b..5d2741b17 100644 --- a/app/serializers/activitypub/actor_serializer.rb +++ b/app/serializers/activitypub/actor_serializer.rb @@ -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 @@ -74,13 +74,17 @@ class ActivityPub::ActorSerializer < ActivityPub::Serializer end def outbox - account_outbox_url(object) + object.instance_actor? ? instance_actor_outbox_url : account_outbox_url(object) end def featured account_collection_url(object, :featured) end + def featured_tags + account_collection_url(object, :tags) + end + def endpoints object end diff --git a/app/serializers/activitypub/collection_serializer.rb b/app/serializers/activitypub/collection_serializer.rb index ea7af5433..34026a6b5 100644 --- a/app/serializers/activitypub/collection_serializer.rb +++ b/app/serializers/activitypub/collection_serializer.rb @@ -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' diff --git a/app/serializers/activitypub/hashtag_serializer.rb b/app/serializers/activitypub/hashtag_serializer.rb new file mode 100644 index 000000000..1a56e4dfe --- /dev/null +++ b/app/serializers/activitypub/hashtag_serializer.rb @@ -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 diff --git a/app/serializers/rest/account_featured_tag_serializer.rb b/app/serializers/rest/account_featured_tag_serializer.rb new file mode 100644 index 000000000..d8d5fd68c --- /dev/null +++ b/app/serializers/rest/account_featured_tag_serializer.rb @@ -0,0 +1,19 @@ +# frozen_string_literal: true + +class REST::AccountFeaturedTagSerializer < ActiveModel::Serializer + include RoutingHelper + + attributes :id, :name, :url + + def id + object.tag.id.to_s + end + + def name + "##{object.name}" + end + + def url + short_account_tag_url(object.account, object.tag) + end +end |