Add support for searching AP users (#4599)

* Add support for searching AP users

* use JsonLdHelper
This commit is contained in:
Yamagishi Kazutoshi
2017-08-14 21:08:34 +09:00
committed by Eugen Rochko
parent 26d26644ac
commit 5f22c0189d
4 changed files with 30 additions and 11 deletions

View File

@ -1,6 +1,8 @@
# frozen_string_literal: true
class FetchRemoteResourceService < BaseService
include JsonLdHelper
attr_reader :url
def call(url)
@ -14,11 +16,11 @@ class FetchRemoteResourceService < BaseService
private
def process_url
case xml_root
when 'feed'
FetchRemoteAccountService.new.call(atom_url, body)
when 'entry'
FetchRemoteStatusService.new.call(atom_url, body)
case type
when 'Person'
FetchRemoteAccountService.new.call(atom_url, body, protocol)
when 'Note'
FetchRemoteStatusService.new.call(atom_url, body, protocol)
end
end
@ -34,6 +36,25 @@ class FetchRemoteResourceService < BaseService
fetched_atom_feed.second
end
def protocol
fetched_atom_feed.third
end
def type
return json_data['type'] if protocol == :activitypub
case xml_root
when 'feed'
'Person'
when 'entry'
'Note'
end
end
def json_data
@_json_data ||= body_to_json(body)
end
def xml_root
xml_data.root.name
end