parent
a7287f4f93
commit
a1ca45b201
4 changed files with 79 additions and 39 deletions
|
|
@ -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?
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
88
vendor/nodeinfo/schemas/1.0.json
vendored
88
vendor/nodeinfo/schemas/1.0.json
vendored
|
|
@ -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": {
|
||||
|
|
|
|||
Loading…
Reference in a new issue