Skip to content

Commit

Permalink
Update NodeInfo to final 1.0 schema
Browse files Browse the repository at this point in the history
closes #6340
  • Loading branch information
jhass authored and Steffen van Bergerem committed Aug 23, 2015
1 parent a7287f4 commit a1ca45b
Show file tree
Hide file tree
Showing 4 changed files with 79 additions and 39 deletions.
2 changes: 1 addition & 1 deletion app/presenters/node_info_presenter.rb
Expand Up @@ -18,7 +18,7 @@ def document

def add_configuration(doc)
doc.software.version = version
doc.services = available_services
doc.services.outbound = available_services
doc.open_registrations = open_registrations?
doc.metadata["nodeName"] = name
doc.metadata["xmppChat"] = chat_enabled?
Expand Down
19 changes: 16 additions & 3 deletions lib/node_info.rb
Expand Up @@ -33,6 +33,19 @@ def version_10_hash
end
end

Services = Struct.new(:inbound, :outbound) do
def initialize(inbound=[], outbound=[])
super(inbound, outbound)
end

def version_10_hash
{
"inbound" => inbound,
"outbound" => outbound
}
end
end

Usage = Struct.new(:users, :local_posts, :local_comments) do
Users = Struct.new(:total, :active_halfyear, :active_month) do
def initialize(total=nil, active_halfyear=nil, active_month=nil)
Expand Down Expand Up @@ -68,8 +81,8 @@ def self.build
end
end

def initialize(version=nil, services=[], open_registrations=nil, metadata={})
super(version, Software.new, Protocols.new, services, open_registrations, Usage.new, metadata)
def initialize(version=nil, open_registrations=nil, metadata={})
super(version, Software.new, Protocols.new, Services.new, open_registrations, Usage.new, metadata)
end

def as_json(_options={})
Expand Down Expand Up @@ -103,7 +116,7 @@ def version_10_hash
"version" => "1.0",
"software" => software.version_10_hash,
"protocols" => protocols.version_10_hash,
"services" => services.empty? ? nil : services,
"services" => services.version_10_hash,
"openRegistrations" => open_registrations,
"usage" => usage.version_10_hash,
"metadata" => metadata
Expand Down
9 changes: 6 additions & 3 deletions spec/presenters/node_info_presenter_spec.rb
Expand Up @@ -29,7 +29,10 @@
"inbound" => ["diaspora"],
"outbound" => ["diaspora"]
},
"services" => ["facebook"],
"services" => {
"inbound" => [],
"outbound" => ["facebook"]
},
"openRegistrations" => AppConfig.settings.enable_registrations?,
"usage" => {
"users" => {}
Expand Down Expand Up @@ -58,7 +61,7 @@
end

it "provides services" do
expect(hash).to include "services" => %w(twitter facebook)
expect(hash).to include "services" => include("outbound" => %w(twitter facebook))
end
end

Expand All @@ -82,7 +85,7 @@
end

it "it doesn't list those" do
expect(hash).to include "services" => ["twitter"]
expect(hash).to include "services" => include("outbound" => ["twitter"])
end
end

Expand Down
88 changes: 56 additions & 32 deletions vendor/nodeinfo/schemas/1.0.json
Expand Up @@ -8,6 +8,7 @@
"version",
"software",
"protocols",
"services",
"openRegistrations",
"usage",
"metadata"
Expand Down Expand Up @@ -92,38 +93,61 @@
}
},
"services": {
"description": "The third party sites this servers allows to publish messages to.",
"type": "array",
"minItems": 0,
"items": {
"enum": [
"appnet",
"blogger",
"buddycloud",
"diaspora",
"dreamwidth",
"drupal",
"facebook",
"friendica",
"gnusocial",
"google",
"insanejournal",
"libertree",
"linkedin",
"livejournal",
"mediagoblin",
"myspace",
"pinterest",
"posterous",
"pumpio",
"redmatrix",
"smtp",
"tent",
"tumblr",
"twitter",
"wordpress",
"xmpp"
]
"description": "The third party sites this server can connect to via their application API.",
"type": "object",
"additionalProperties": false,
"required": [
"inbound",
"outbound"
],
"properties": {
"inbound": {
"description": "The third party sites this server can retrieve messages from for combined display with regular traffic.",
"type": "array",
"minItems": 0,
"items": {
"enum": [
"appnet",
"gnusocial",
"pumpio"
]
}
},
"outbound": {
"description": "The third party sites this server can publish messages to on the behalf of a user.",
"type": "array",
"minItems": 0,
"items": {
"enum": [
"appnet",
"blogger",
"buddycloud",
"diaspora",
"dreamwidth",
"drupal",
"facebook",
"friendica",
"gnusocial",
"google",
"insanejournal",
"libertree",
"linkedin",
"livejournal",
"mediagoblin",
"myspace",
"pinterest",
"posterous",
"pumpio",
"redmatrix",
"smtp",
"tent",
"tumblr",
"twitter",
"wordpress",
"xmpp"
]
}
}
}
},
"openRegistrations": {
Expand Down

0 comments on commit a1ca45b

Please sign in to comment.