diff --git a/app/presenters/node_info_presenter.rb b/app/presenters/node_info_presenter.rb index 68a4c3c719218d24137ad293b20d6bef3be0a077..a52668b7f7e4ccd6dd28356c773f54c53387abb3 100644 --- a/app/presenters/node_info_presenter.rb +++ b/app/presenters/node_info_presenter.rb @@ -18,7 +18,7 @@ class NodeInfoPresenter 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? diff --git a/lib/node_info.rb b/lib/node_info.rb index 1b53b0991f39bea1c9ccc989ba82df12c1a1446a..0b4657d3a94e2070f8799549947b724ee3cb816d 100644 --- a/lib/node_info.rb +++ b/lib/node_info.rb @@ -33,6 +33,19 @@ module NodeInfo 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) @@ -68,8 +81,8 @@ module NodeInfo 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={}) @@ -103,7 +116,7 @@ module NodeInfo "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 diff --git a/spec/presenters/node_info_presenter_spec.rb b/spec/presenters/node_info_presenter_spec.rb index 500793d3baadfcf571e3aff17a8aef959fd7f843..028cfc5c70d7dc804f969a4bc1581c99c4454529 100644 --- a/spec/presenters/node_info_presenter_spec.rb +++ b/spec/presenters/node_info_presenter_spec.rb @@ -29,7 +29,10 @@ describe NodeInfoPresenter do "inbound" => ["diaspora"], "outbound" => ["diaspora"] }, - "services" => ["facebook"], + "services" => { + "inbound" => [], + "outbound" => ["facebook"] + }, "openRegistrations" => AppConfig.settings.enable_registrations?, "usage" => { "users" => {} @@ -58,7 +61,7 @@ describe NodeInfoPresenter do 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 @@ -82,7 +85,7 @@ describe NodeInfoPresenter do end it "it doesn't list those" do - expect(hash).to include "services" => ["twitter"] + expect(hash).to include "services" => include("outbound" => ["twitter"]) end end diff --git a/vendor/nodeinfo/schemas/1.0.json b/vendor/nodeinfo/schemas/1.0.json index de28dcb8e5c2abb23025e480874bb2043a532537..8d177557be10e9197ceb7a5df5aba1accbe0d440 100644 --- a/vendor/nodeinfo/schemas/1.0.json +++ b/vendor/nodeinfo/schemas/1.0.json @@ -8,6 +8,7 @@ "version", "software", "protocols", + "services", "openRegistrations", "usage", "metadata" @@ -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": {