add ostatus subscribe-url to webfinger
This commit is contained in:
parent
fb00b95c74
commit
7ed848c2f5
5 changed files with 70 additions and 50 deletions
|
|
@ -75,6 +75,10 @@ module DiasporaFederation
|
|||
# Panzer draft for Salmon, paragraph 3.3
|
||||
property :salmon_url
|
||||
|
||||
# @!attribute [r] subscribe_url
|
||||
# This url is used to find another user on the home-pod of the user in the webfinger.
|
||||
property :subscribe_url
|
||||
|
||||
# @!attribute [r] guid
|
||||
# @deprecated Either convert these to +Property+ elements or move to the
|
||||
# +hCard+, which actually has fields for an +UID+ defined in the +vCard+
|
||||
|
|
@ -121,6 +125,9 @@ module DiasporaFederation
|
|||
# +salmon_url+ link relation
|
||||
REL_SALMON = "salmon"
|
||||
|
||||
# +subscribe_url+ link relation
|
||||
REL_SUBSCRIBE = "http://ostatus.org/schema/1.0/subscribe"
|
||||
|
||||
# @deprecated This should be a +Property+ or moved to the +hcard+, but +Link+
|
||||
# is inappropriate according to the specification (will affect older
|
||||
# Diaspora* installations).
|
||||
|
|
@ -152,17 +159,19 @@ module DiasporaFederation
|
|||
public_key = parse_link(links, REL_PUBKEY)
|
||||
|
||||
new(
|
||||
acct_uri: data[:subject],
|
||||
alias_url: parse_alias(data[:aliases]),
|
||||
hcard_url: parse_link(links, REL_HCARD),
|
||||
seed_url: parse_link(links, REL_SEED),
|
||||
profile_url: parse_link(links, REL_PROFILE),
|
||||
atom_url: parse_link(links, REL_ATOM),
|
||||
salmon_url: parse_link(links, REL_SALMON),
|
||||
acct_uri: data[:subject],
|
||||
alias_url: parse_alias(data[:aliases]),
|
||||
hcard_url: parse_link(links, REL_HCARD),
|
||||
seed_url: parse_link(links, REL_SEED),
|
||||
profile_url: parse_link(links, REL_PROFILE),
|
||||
atom_url: parse_link(links, REL_ATOM),
|
||||
salmon_url: parse_link(links, REL_SALMON),
|
||||
|
||||
subscribe_url: parse_link_template(links, REL_SUBSCRIBE),
|
||||
|
||||
# TODO: remove me! ##########
|
||||
guid: parse_link(links, REL_GUID),
|
||||
public_key: (Base64.strict_decode64(public_key) if public_key)
|
||||
guid: parse_link(links, REL_GUID),
|
||||
public_key: (Base64.strict_decode64(public_key) if public_key)
|
||||
)
|
||||
end
|
||||
|
||||
|
|
@ -182,27 +191,18 @@ module DiasporaFederation
|
|||
private_class_method :parse_xml_and_validate
|
||||
|
||||
def add_links_to(doc)
|
||||
doc.links << {rel: REL_HCARD,
|
||||
type: "text/html",
|
||||
href: @hcard_url}
|
||||
doc.links << {rel: REL_SEED,
|
||||
type: "text/html",
|
||||
href: @seed_url}
|
||||
doc.links << {rel: REL_HCARD, type: "text/html", href: @hcard_url}
|
||||
doc.links << {rel: REL_SEED, type: "text/html", href: @seed_url}
|
||||
|
||||
# TODO: remove me! ##############
|
||||
doc.links << {rel: REL_GUID,
|
||||
type: "text/html",
|
||||
href: @guid}
|
||||
doc.links << {rel: REL_GUID, type: "text/html", href: @guid}
|
||||
##################################
|
||||
|
||||
doc.links << {rel: REL_PROFILE,
|
||||
type: "text/html",
|
||||
href: @profile_url}
|
||||
doc.links << {rel: REL_ATOM,
|
||||
type: "application/atom+xml",
|
||||
href: @atom_url}
|
||||
doc.links << {rel: REL_SALMON,
|
||||
href: @salmon_url}
|
||||
doc.links << {rel: REL_PROFILE, type: "text/html", href: @profile_url}
|
||||
doc.links << {rel: REL_ATOM, type: "application/atom+xml", href: @atom_url}
|
||||
doc.links << {rel: REL_SALMON, href: @salmon_url}
|
||||
|
||||
doc.links << {rel: REL_SUBSCRIBE, template: @subscribe_url}
|
||||
|
||||
# TODO: remove me! ##############
|
||||
doc.links << {rel: REL_PUBKEY,
|
||||
|
|
@ -211,12 +211,23 @@ module DiasporaFederation
|
|||
##################################
|
||||
end
|
||||
|
||||
def self.find_link(links, rel)
|
||||
links.find {|l| l[:rel] == rel }
|
||||
end
|
||||
private_class_method :find_link
|
||||
|
||||
def self.parse_link(links, rel)
|
||||
element = links.find {|l| l[:rel] == rel }
|
||||
element = find_link(links, rel)
|
||||
element ? element[:href] : nil
|
||||
end
|
||||
private_class_method :parse_link
|
||||
|
||||
def self.parse_link_template(links, rel)
|
||||
element = find_link(links, rel)
|
||||
element ? element[:template] : nil
|
||||
end
|
||||
private_class_method :parse_link_template
|
||||
|
||||
# this method is used to parse the alias_url from the XML.
|
||||
# * redmatrix has sometimes no alias, return nil
|
||||
# * old pods had quotes around the alias url, this can be removed later
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ module DiasporaFederation
|
|||
atom_url "http://localhost:3000/public/user.atom"
|
||||
salmon_url "http://localhost:3000/receive/users/0123456789abcdef"
|
||||
public_key
|
||||
subscribe_url "http://localhost:3000/people?q={uri}"
|
||||
end
|
||||
|
||||
factory :h_card, class: DiasporaFederation::Discovery::HCard do
|
||||
|
|
|
|||
|
|
@ -6,15 +6,16 @@ module DiasporaFederation
|
|||
|
||||
let(:data) {
|
||||
{
|
||||
acct_uri: "acct:#{person.diaspora_id}",
|
||||
alias_url: person.alias_url,
|
||||
hcard_url: person.hcard_url,
|
||||
seed_url: person.url,
|
||||
profile_url: person.profile_url,
|
||||
atom_url: person.atom_url,
|
||||
salmon_url: person.salmon_url,
|
||||
guid: person.guid,
|
||||
public_key: person.serialized_public_key
|
||||
acct_uri: "acct:#{person.diaspora_id}",
|
||||
alias_url: person.alias_url,
|
||||
hcard_url: person.hcard_url,
|
||||
seed_url: person.url,
|
||||
profile_url: person.profile_url,
|
||||
atom_url: person.atom_url,
|
||||
salmon_url: person.salmon_url,
|
||||
guid: person.guid,
|
||||
public_key: person.serialized_public_key,
|
||||
subscribe_url: person.subscribe_url
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -30,6 +31,7 @@ module DiasporaFederation
|
|||
<Link rel="http://webfinger.net/rel/profile-page" type="text/html" href="#{person.profile_url}"/>
|
||||
<Link rel="http://schemas.google.com/g/2010#updates-from" type="application/atom+xml" href="#{person.atom_url}"/>
|
||||
<Link rel="salmon" href="#{person.salmon_url}"/>
|
||||
<Link rel="http://ostatus.org/schema/1.0/subscribe" template="#{person.subscribe_url}"/>
|
||||
<Link rel="diaspora-public-key" type="RSA" href="#{public_key_base64}"/>
|
||||
</XRD>
|
||||
XML
|
||||
|
|
@ -54,6 +56,7 @@ XML
|
|||
expect(wf.profile_url).to eq(person.profile_url)
|
||||
expect(wf.atom_url).to eq(person.atom_url)
|
||||
expect(wf.salmon_url).to eq(person.salmon_url)
|
||||
expect(wf.subscribe_url).to eq(person.subscribe_url)
|
||||
|
||||
expect(wf.guid).to eq(person.guid)
|
||||
expect(wf.public_key).to eq(person.serialized_public_key)
|
||||
|
|
@ -150,6 +153,7 @@ XML
|
|||
expect(wf.profile_url).to eq(person.profile_url)
|
||||
expect(wf.atom_url).to eq(person.atom_url)
|
||||
expect(wf.salmon_url).to eq(person.salmon_url)
|
||||
expect(wf.subscribe_url).to eq("https://pod.example.tld/follow?url={uri}")
|
||||
|
||||
expect(wf.guid).to eq(person.guid)
|
||||
expect(wf.public_key).to eq(person.serialized_public_key)
|
||||
|
|
@ -211,6 +215,7 @@ XML
|
|||
<Link rel="http://webfinger.net/rel/profile-page" type="text/html" href="#{person.profile_url}"/>
|
||||
<Link rel="http://schemas.google.com/g/2010#updates-from" type="application/atom+xml" href="#{person.atom_url}"/>
|
||||
<Link rel="salmon" href="#{person.salmon_url}"/>
|
||||
<Link rel="http://ostatus.org/schema/1.0/subscribe" template="#{person.subscribe_url}"/>
|
||||
</XRD>
|
||||
XML
|
||||
|
||||
|
|
@ -222,6 +227,7 @@ XML
|
|||
expect(wf.profile_url).to eq(person.profile_url)
|
||||
expect(wf.atom_url).to eq(person.atom_url)
|
||||
expect(wf.salmon_url).to eq(person.salmon_url)
|
||||
expect(wf.subscribe_url).to eq(person.subscribe_url)
|
||||
|
||||
expect(wf.guid).to be_nil
|
||||
expect(wf.public_key).to be_nil
|
||||
|
|
|
|||
|
|
@ -1,11 +1,12 @@
|
|||
class Person < ActiveRecord::Base
|
||||
include ::Diaspora::Guid
|
||||
|
||||
def alias_url; "#{url}people/#{guid}" end
|
||||
def hcard_url; "#{url}hcard/users/#{guid}" end
|
||||
def profile_url; "#{url}u/#{nickname}" end
|
||||
def atom_url; "#{url}public/#{nickname}.atom" end
|
||||
def salmon_url; "#{url}receive/users/#{guid}" end
|
||||
def alias_url; "#{url}people/#{guid}" end
|
||||
def hcard_url; "#{url}hcard/users/#{guid}" end
|
||||
def profile_url; "#{url}u/#{nickname}" end
|
||||
def atom_url; "#{url}public/#{nickname}.atom" end
|
||||
def salmon_url; "#{url}receive/users/#{guid}" end
|
||||
def subscribe_url; "#{url}people?q={uri}" end
|
||||
|
||||
def nickname; diaspora_id.split("@")[0] end
|
||||
|
||||
|
|
|
|||
|
|
@ -20,15 +20,16 @@ DiasporaFederation.configure do |config|
|
|||
person = Person.find_by(diaspora_id: diaspora_id)
|
||||
if person
|
||||
DiasporaFederation::Discovery::WebFinger.new(
|
||||
acct_uri: "acct:#{person.diaspora_id}",
|
||||
alias_url: person.alias_url,
|
||||
hcard_url: person.hcard_url,
|
||||
seed_url: person.url,
|
||||
profile_url: person.profile_url,
|
||||
atom_url: person.atom_url,
|
||||
salmon_url: person.salmon_url,
|
||||
guid: person.guid,
|
||||
public_key: person.serialized_public_key
|
||||
acct_uri: "acct:#{person.diaspora_id}",
|
||||
alias_url: person.alias_url,
|
||||
hcard_url: person.hcard_url,
|
||||
seed_url: person.url,
|
||||
profile_url: person.profile_url,
|
||||
atom_url: person.atom_url,
|
||||
salmon_url: person.salmon_url,
|
||||
subscribe_url: person.subscribe_url,
|
||||
guid: person.guid,
|
||||
public_key: person.serialized_public_key
|
||||
)
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Reference in a new issue