don't parse guid from hcard if it is equals to nickname
This commit is contained in:
parent
3978ea00a1
commit
35f0af3c55
2 changed files with 13 additions and 2 deletions
|
|
@ -164,7 +164,7 @@ module DiasporaFederation
|
||||||
doc = parse_html_and_validate(html_string)
|
doc = parse_html_and_validate(html_string)
|
||||||
|
|
||||||
data = {
|
data = {
|
||||||
guid: content_from_doc(doc, :uid),
|
guid: guid_from_doc(doc),
|
||||||
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),
|
||||||
url: element_from_doc(doc, :url)["href"],
|
url: element_from_doc(doc, :url)["href"],
|
||||||
|
|
@ -173,7 +173,7 @@ module DiasporaFederation
|
||||||
photo_small_url: photo_from_doc(doc, :photo_small),
|
photo_small_url: photo_from_doc(doc, :photo_small),
|
||||||
searchable: (content_from_doc(doc, :searchable) == "true"),
|
searchable: (content_from_doc(doc, :searchable) == "true"),
|
||||||
|
|
||||||
# TODO: change me! ###################
|
# TODO: remove me! ###################
|
||||||
first_name: content_from_doc(doc, :given_name),
|
first_name: content_from_doc(doc, :given_name),
|
||||||
last_name: content_from_doc(doc, :family_name)
|
last_name: content_from_doc(doc, :family_name)
|
||||||
#######################################
|
#######################################
|
||||||
|
|
@ -288,6 +288,14 @@ module DiasporaFederation
|
||||||
element_from_doc(doc, photo_selector)["src"]
|
element_from_doc(doc, photo_selector)["src"]
|
||||||
end
|
end
|
||||||
private_class_method :photo_from_doc
|
private_class_method :photo_from_doc
|
||||||
|
|
||||||
|
# @deprecated hack for old hcard
|
||||||
|
# @todo remove this when all pods have the new generator
|
||||||
|
def self.guid_from_doc(doc)
|
||||||
|
uid_element = element_from_doc(doc, :uid)
|
||||||
|
uid_element.content unless uid_element[:class].include? "nickname"
|
||||||
|
end
|
||||||
|
private_class_method :guid_from_doc
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -227,6 +227,9 @@ HTML
|
||||||
|
|
||||||
expect(hcard.first_name).to eq(person.first_name)
|
expect(hcard.first_name).to eq(person.first_name)
|
||||||
expect(hcard.last_name).to eq(person.last_name)
|
expect(hcard.last_name).to eq(person.last_name)
|
||||||
|
|
||||||
|
expect(hcard.guid).to be_nil
|
||||||
|
expect(hcard.public_key).to be_nil
|
||||||
end
|
end
|
||||||
|
|
||||||
it "fails if the document is incomplete" do
|
it "fails if the document is incomplete" do
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue