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