Refactor featured collections URL code (#38709)
This commit is contained in:
parent
0e4ee62dfc
commit
fc1ba93cdc
@ -31,6 +31,8 @@ class ActivityPub::TagManager
|
||||
short_account_status_url(target.account, target)
|
||||
when :flag
|
||||
target.uri
|
||||
when :featured_collection
|
||||
account_collection_url(target.account, target)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@ -1,9 +1,6 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class ActivityPub::FeaturedCollectionSerializer < ActivityPub::Serializer
|
||||
# include Rails.application.routes.url_helpers
|
||||
include RoutingHelper
|
||||
|
||||
attributes :id, :type, :total_items, :name, :attributed_to, :url,
|
||||
:sensitive, :discoverable, :published, :updated
|
||||
|
||||
@ -35,7 +32,7 @@ class ActivityPub::FeaturedCollectionSerializer < ActivityPub::Serializer
|
||||
end
|
||||
|
||||
def url
|
||||
account_collection_url(object.account, object)
|
||||
ActivityPub::TagManager.instance.url_for(object)
|
||||
end
|
||||
|
||||
def total_items
|
||||
|
||||
@ -1,8 +1,6 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class REST::CollectionSerializer < ActiveModel::Serializer
|
||||
include RoutingHelper
|
||||
|
||||
attributes :id, :uri, :name, :description, :language, :account_id,
|
||||
:local, :sensitive, :discoverable, :url, :item_count,
|
||||
:created_at, :updated_at
|
||||
@ -20,7 +18,7 @@ class REST::CollectionSerializer < ActiveModel::Serializer
|
||||
end
|
||||
|
||||
def url
|
||||
object.local? ? account_collection_url(object.account, object) : object.url
|
||||
ActivityPub::TagManager.instance.url_for(object)
|
||||
end
|
||||
|
||||
def description
|
||||
@ -37,8 +35,4 @@ class REST::CollectionSerializer < ActiveModel::Serializer
|
||||
def account_id
|
||||
object.account_id.to_s
|
||||
end
|
||||
|
||||
def tag
|
||||
object.tag
|
||||
end
|
||||
end
|
||||
|
||||
@ -3,8 +3,6 @@
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe REST::CollectionSerializer do
|
||||
include RoutingHelper
|
||||
|
||||
subject do
|
||||
serialized_record_json(collection, described_class, options: {
|
||||
scope: current_user,
|
||||
@ -39,7 +37,7 @@ RSpec.describe REST::CollectionSerializer do
|
||||
'local' => true,
|
||||
'sensitive' => true,
|
||||
'discoverable' => false,
|
||||
'url' => account_collection_url(collection.account, collection),
|
||||
'url' => ActivityPub::TagManager.instance.url_for(collection),
|
||||
'tag' => a_hash_including('name' => 'discovery'),
|
||||
'created_at' => match_api_datetime_format,
|
||||
'updated_at' => match_api_datetime_format,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user