Class: Fediverse::NodeInfo

Inherits:
Object
  • Object
show all
Defined in:
lib/fediverse/node_info.rb

Defined Under Namespace

Classes: NoActivityPubError, NotFoundError

Class Method Summary collapse

Class Method Details

.fetch(domain) ⇒ Object

Raises:



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/fediverse/node_info.rb', line 7

def fetch(domain)
  url = nodeinfo_url(domain)

  hash = Federails::Utils::JsonRequest.get_json url
  raise NoActivityPubError, "#{domain} does not handle activitypub protocol" unless hash['protocols'].include? 'activitypub'

  {
    domain:           domain,
    nodeinfo_url:     url,
    software_version: hash.dig('software', 'version'),
    software_name:    hash.dig('software', 'name'),
    protocols:        hash['protocols'],
    services:         hash['services'],
  }
end