diff options
Diffstat (limited to 'app/services/fetch_remote_resource_service.rb')
-rw-r--r-- | app/services/fetch_remote_resource_service.rb | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/app/services/fetch_remote_resource_service.rb b/app/services/fetch_remote_resource_service.rb new file mode 100644 index 000000000..80aa74365 --- /dev/null +++ b/app/services/fetch_remote_resource_service.rb @@ -0,0 +1,18 @@ +# frozen_string_literal: true + +class FetchRemoteResourceService < BaseService + def call(url) + atom_url, body = FetchAtomService.new.call(url) + + return nil if atom_url.nil? + + xml = Nokogiri::XML(body) + xml.encoding = 'utf-8' + + if xml.root.name == 'feed' + FetchRemoteAccountService.new.call(atom_url) + elsif xml.root.name == 'entry' + FetchRemoteStatusService.new.call(atom_url) + end + end +end |