kopia lustrzana https://gitlab.com/jaywink/federation
Merge pull request #49 from jaywink/fix-hcard-selectors
Fix hcard selectors in parse_profile_from_hcardmerge-requests/130/head
commit
9617a6e56b
|
@ -7,6 +7,9 @@
|
||||||
* Deprecate receiving user `key` attribute for Diaspora protocol. Instead correct attribute is now `private_key` for any user passed to `federation.inbound.handle_receive`. We already use `private_key` in the message creation code so this is just to unify the user related required attributes.
|
* Deprecate receiving user `key` attribute for Diaspora protocol. Instead correct attribute is now `private_key` for any user passed to `federation.inbound.handle_receive`. We already use `private_key` in the message creation code so this is just to unify the user related required attributes.
|
||||||
* DEPRECATION: There is a fallback with `key` for user objects in the receiving payload part of the Diaspora protocol until 0.8.0.
|
* DEPRECATION: There is a fallback with `key` for user objects in the receiving payload part of the Diaspora protocol until 0.8.0.
|
||||||
|
|
||||||
|
### Fixes
|
||||||
|
* Loosen up hCard selectors when parsing profile from hCard document in `federation.utils.diaspora.parse_profile_from_hcard`. The selectors now match Diaspora upcoming federation documentation.
|
||||||
|
|
||||||
## [0.5.0] - 2016-09-05
|
## [0.5.0] - 2016-09-05
|
||||||
|
|
||||||
### Breaking changes
|
### Breaking changes
|
||||||
|
|
|
@ -105,16 +105,16 @@ def parse_profile_from_hcard(hcard):
|
||||||
doc = html.fromstring(hcard)
|
doc = html.fromstring(hcard)
|
||||||
domain = urlparse(_get_element_attr_or_none(doc, "a#pod_location", "href")).netloc
|
domain = urlparse(_get_element_attr_or_none(doc, "a#pod_location", "href")).netloc
|
||||||
profile = Profile(
|
profile = Profile(
|
||||||
name=_get_element_text_or_none(doc, "dl.entity_full_name span.fn"),
|
name=_get_element_text_or_none(doc, ".fn"),
|
||||||
image_urls={
|
image_urls={
|
||||||
"small": _get_element_attr_or_none(doc, "dl.entity_photo_small img.photo", "src"),
|
"small": _get_element_attr_or_none(doc, ".entity_photo_small .photo", "src"),
|
||||||
"medium": _get_element_attr_or_none(doc, "dl.entity_photo_medium img.photo", "src"),
|
"medium": _get_element_attr_or_none(doc, ".entity_photo_medium .photo", "src"),
|
||||||
"large": _get_element_attr_or_none(doc, "dl.entity_photo img.photo", "src"),
|
"large": _get_element_attr_or_none(doc, ".entity_photo .photo", "src"),
|
||||||
},
|
},
|
||||||
public=True if _get_element_text_or_none(doc, "dl.entity_searchable span.searchable") == "true" else False,
|
public=True if _get_element_text_or_none(doc, ".searchable") == "true" else False,
|
||||||
handle="%s@%s" % (_get_element_text_or_none(doc, "dl.entity_nickname span.nickname"), domain),
|
handle="%s@%s" % (_get_element_text_or_none(doc, ".nickname"), domain),
|
||||||
guid=_get_element_text_or_none(doc, "dl.entity_uid span.uid"),
|
guid=_get_element_text_or_none(doc, ".uid"),
|
||||||
public_key=_get_element_text_or_none(doc, "dl.entity_key pre.key"),
|
public_key=_get_element_text_or_none(doc, ".key"),
|
||||||
)
|
)
|
||||||
return profile
|
return profile
|
||||||
|
|
||||||
|
|
Ładowanie…
Reference in New Issue