@ -12,7 +12,7 @@ class ResolveURLService < BaseService
process_local_url
process_local_url
elsif ! fetched_resource . nil?
elsif ! fetched_resource . nil?
process_url
process_url
els if @on_b ehalf_of. present?
els e
process_url_from_db
process_url_from_db
end
end
end
end
@ -30,6 +30,8 @@ class ResolveURLService < BaseService
end
end
def process_url_from_db
def process_url_from_db
return unless @on_behalf_of . present? && [ 401 , 403 , 404 ] . include? ( fetch_resource_service . response_code )
# It may happen that the resource is a private toot, and thus not fetchable,
# It may happen that the resource is a private toot, and thus not fetchable,
# but we can return the toot if we already know about it.
# but we can return the toot if we already know about it.
status = Status . find_by ( uri : @url ) || Status . find_by ( url : @url )
status = Status . find_by ( uri : @url ) || Status . find_by ( url : @url )
@ -40,7 +42,11 @@ class ResolveURLService < BaseService
end
end
def fetched_resource
def fetched_resource
@fetched_resource || = FetchResourceService . new . call ( @url )
@fetched_resource || = fetch_resource_service . call ( @url )
end
def fetch_resource_service
@_fetch_resource_service || = FetchResourceService . new
end
end
def resource_url
def resource_url