diff options
author | Fire Demon <firedemon@creature.cafe> | 2020-07-17 19:46:24 -0500 |
---|---|---|
committer | Fire Demon <firedemon@creature.cafe> | 2020-08-30 05:41:03 -0500 |
commit | 120683f52266900d0fede7bd67c43133bbc26bea (patch) | |
tree | 8b6558858bc3928e96d0c11217155e95ebde92a1 /app/services/fetch_resource_service.rb | |
parent | 78d33622a5b53a983e8d37777e8e56b9e3f3c29c (diff) |
[Federation] Add support for signing fetches as the participating local user in various scenarios
Diffstat (limited to 'app/services/fetch_resource_service.rb')
-rw-r--r-- | app/services/fetch_resource_service.rb | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/app/services/fetch_resource_service.rb b/app/services/fetch_resource_service.rb index 6c0093cd4..3264d14c2 100644 --- a/app/services/fetch_resource_service.rb +++ b/app/services/fetch_resource_service.rb @@ -7,9 +7,11 @@ class FetchResourceService < BaseService attr_reader :response_code - def call(url) + def call(url, on_behalf_of: nil) return if url.blank? + @on_behalf_of = on_behalf_of + process(url) rescue HTTP::Error, OpenSSL::SSL::SSLError, Addressable::URI::InvalidURIError, Mastodon::HostValidationError, Mastodon::LengthValidationError => e Rails.logger.debug "Error fetching resource #{@url}: #{e}" @@ -35,7 +37,7 @@ class FetchResourceService < BaseService # and prevents even public resources from being fetched, so # don't do it - request.on_behalf_of(Account.representative) unless Rails.env.development? + request.on_behalf_of(@on_behalf_of || Account.representative) unless Rails.env.development? end.perform(&block) end |