Merge branch 'stable' into develop

This commit is contained in:
Steffen van Bergerem 2015-08-23 14:45:33 +02:00
commit 89a3ea6d20
4 changed files with 79 additions and 39 deletions

View file

@ -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?

View file

@ -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

View file

@ -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

View file

@ -8,6 +8,7 @@
"version",
"software",
"protocols",
"services",
"openRegistrations",
"usage",
"metadata"
@ -92,7 +93,28 @@
}
},
"services": {
"description": "The third party sites this servers allows to publish messages to.",
"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": {
@ -125,6 +147,8 @@
"xmpp"
]
}
}
}
},
"openRegistrations": {
"description": "Whether this server allows open self-registration.",