Remove more backward-compatibility code for discovery
This was needed for pods older than 0.5.2.0
This commit is contained in:
parent
a3ad1ea7e4
commit
b788fbdad1
3 changed files with 2 additions and 38 deletions
|
|
@ -160,7 +160,7 @@ module DiasporaFederation
|
||||||
doc = parse_html_and_validate(html_string)
|
doc = parse_html_and_validate(html_string)
|
||||||
|
|
||||||
new(
|
new(
|
||||||
guid: guid_from_doc(doc),
|
guid: content_from_doc(doc, :uid),
|
||||||
nickname: content_from_doc(doc, :nickname),
|
nickname: content_from_doc(doc, :nickname),
|
||||||
full_name: content_from_doc(doc, :fn),
|
full_name: content_from_doc(doc, :fn),
|
||||||
photo_large_url: photo_from_doc(doc, :photo),
|
photo_large_url: photo_from_doc(doc, :photo),
|
||||||
|
|
@ -275,13 +275,6 @@ module DiasporaFederation
|
||||||
private_class_method def self.photo_from_doc(doc, photo_selector)
|
private_class_method def self.photo_from_doc(doc, photo_selector)
|
||||||
element_from_doc(doc, photo_selector)["src"]
|
element_from_doc(doc, photo_selector)["src"]
|
||||||
end
|
end
|
||||||
|
|
||||||
# @deprecated hack for old hcard
|
|
||||||
# @todo remove this when all pods have the new generator
|
|
||||||
private_class_method def self.guid_from_doc(doc)
|
|
||||||
uid_element = element_from_doc(doc, :uid)
|
|
||||||
uid_element.content unless uid_element[:class].include? "nickname"
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -177,8 +177,7 @@ module DiasporaFederation
|
||||||
# * friendica has two aliases and the first is with "acct:": return only an URL starting with http (or https)
|
# * friendica has two aliases and the first is with "acct:": return only an URL starting with http (or https)
|
||||||
private_class_method def self.parse_alias(aliases)
|
private_class_method def self.parse_alias(aliases)
|
||||||
return nil unless aliases
|
return nil unless aliases
|
||||||
# TODO: Old pods had quotes around alias. Remove the +map+ in next line, when all pods use this gem
|
aliases.find {|a| a.start_with?("http") }
|
||||||
aliases.map {|a| a.gsub(/\A"|"\Z/, "") }.find {|a| a.start_with?("http") }
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -75,34 +75,6 @@ XML
|
||||||
expect(wf).to be_frozen
|
expect(wf).to be_frozen
|
||||||
end
|
end
|
||||||
|
|
||||||
it "reads old-style XML" do
|
|
||||||
historic_xml = <<-XML
|
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<XRD xmlns="http://docs.oasis-open.org/ns/xri/xrd-1.0">
|
|
||||||
<Subject>#{acct}</Subject>
|
|
||||||
<Alias>"#{person.alias_url}"</Alias>
|
|
||||||
<Link rel="http://microformats.org/profile/hcard" type="text/html" href="#{person.hcard_url}"/>
|
|
||||||
<Link rel="http://joindiaspora.com/seed_location" type = "text/html" href="#{person.url}"/>
|
|
||||||
<Link rel="http://joindiaspora.com/guid" type = "text/html" href="#{person.guid}"/>
|
|
||||||
|
|
||||||
<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="diaspora-public-key" type = "RSA" href="#{public_key_base64}"/>
|
|
||||||
</XRD>
|
|
||||||
XML
|
|
||||||
|
|
||||||
wf = Discovery::WebFinger.from_xml(historic_xml)
|
|
||||||
expect(wf.acct_uri).to eq(acct)
|
|
||||||
expect(wf.alias_url).to eq(person.alias_url)
|
|
||||||
expect(wf.hcard_url).to eq(person.hcard_url)
|
|
||||||
expect(wf.seed_url).to eq(person.url)
|
|
||||||
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)
|
|
||||||
end
|
|
||||||
|
|
||||||
it "reads friendica XML (two aliases, first with acct)" do
|
it "reads friendica XML (two aliases, first with acct)" do
|
||||||
friendica_xml = <<-XML
|
friendica_xml = <<-XML
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue