Class: ActivityPub::WebResolver

Inherits:
Object
  • Object
show all
Defined in:
lib/activitypub/resolvers.rb

Class Method Summary collapse

Class Method Details

.call(path) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/activitypub/resolvers.rb', line 13

def self.call(path)

  uri = URI(path)
  addr = IPAddr.new(IPSocket.getaddress(uri.host))
  if addr.loopback? || addr.private? || addr.link_local?
    raise "Local access denied"
  end
  
  response = Faraday.get(path, {}, {"Accept": "application/activity+json"})
  if response.status == 200
    ActivityPub.from_json(response.body)
  else
    response
  end
end