Fix error handling in ActivityPub::ProcessFeaturedItemService (#39787)
This commit is contained in:
parent
55ebcaf8f6
commit
c45bcd990b
@ -66,8 +66,8 @@ class ActivityPub::ProcessFeaturedItemService
|
||||
return false if local_actor_uri?
|
||||
return false if Account.exists?(uri: @actor_uri)
|
||||
|
||||
object_json = fetch_resource(@actor_uri, true)
|
||||
(Array(object_json['type']) & ActivityPub::FetchRemoteActorService::SUPPORTED_TYPES).empty?
|
||||
object_json = fetch_resource(@actor_uri, true, raise_on_error: :temporary)
|
||||
object_json.nil? || (as_array(object_json['fetch']) & ActivityPub::FetchRemoteActorService::SUPPORTED_TYPES).empty?
|
||||
end
|
||||
|
||||
def verify_authorization!
|
||||
|
||||
@ -143,6 +143,28 @@ RSpec.describe ActivityPub::ProcessFeaturedItemService do
|
||||
end.to_not change(CollectionItem, :count)
|
||||
end
|
||||
end
|
||||
|
||||
context 'when featured object cannot be fetched' do
|
||||
let(:hashtag_json) do
|
||||
{
|
||||
'id' => 'https://example.com/hashtags/people',
|
||||
'type' => 'Hashtag',
|
||||
'name' => '#people',
|
||||
}
|
||||
end
|
||||
let(:featured_object_uri) { hashtag_json['id'] }
|
||||
|
||||
before do
|
||||
stub_request(:get, featured_object_uri)
|
||||
.to_return(status: 404)
|
||||
end
|
||||
|
||||
it 'does not create a collection item and returns `nil`' do
|
||||
expect do
|
||||
expect(subject.call(collection, object, position:)).to be_nil
|
||||
end.to_not change(CollectionItem, :count)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'when only the id of the collection item is given' do
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user