Add vcard to webfinger

merge-requests/30/head
Bob Mottram 2022-02-16 10:24:04 +00:00
parent 346d11f77a
commit 41f1818cda
1 changed files with 24 additions and 2 deletions

View File

@ -171,6 +171,11 @@ def create_webfinger_endpoint(nickname: str, domain: str, port: int,
"rel": "http://webfinger.net/rel/profile-page", "rel": "http://webfinger.net/rel/profile-page",
"type": "text/html" "type": "text/html"
}, },
{
"href": profile_page_href,
"rel": "http://webfinger.net/rel/profile-page",
"type": "text/vcard"
},
{ {
"href": person_id, "href": person_id,
"rel": "self", "rel": "self",
@ -280,7 +285,7 @@ def webfinger_lookup(path: str, base_dir: str,
return wf_json return wf_json
def _webfinger_updateAvatar(wf_json: {}, actor_json: {}) -> bool: def _webfinger_update_avatar(wf_json: {}, actor_json: {}) -> bool:
"""Updates the avatar image link """Updates the avatar image link
""" """
found = False found = False
@ -307,6 +312,20 @@ def _webfinger_updateAvatar(wf_json: {}, actor_json: {}) -> bool:
return True return True
def _webfinger_update_vcard(wf_json: {}, actor_json: {}) -> bool:
"""Updates the vcard link
"""
for link in wf_json['links']:
if link['type'] == 'text/vcard':
return False
wf_json['links'].append({
"href": actor_json['url'],
"rel": "http://webfinger.net/rel/profile-page",
"type": "text/vcard"
})
return True
def _webfinger_add_blog_link(wf_json: {}, actor_json: {}) -> bool: def _webfinger_add_blog_link(wf_json: {}, actor_json: {}) -> bool:
"""Adds a blog link to webfinger if needed """Adds a blog link to webfinger if needed
""" """
@ -412,7 +431,10 @@ def _webfinger_updateFromProfile(wf_json: {}, actor_json: {}) -> bool:
wf_json['aliases'].remove(full_alias) wf_json['aliases'].remove(full_alias)
changed = True changed = True
if _webfinger_updateAvatar(wf_json, actor_json): if _webfinger_update_avatar(wf_json, actor_json):
changed = True
if _webfinger_update_vcard(wf_json, actor_json):
changed = True changed = True
if _webfinger_add_blog_link(wf_json, actor_json): if _webfinger_add_blog_link(wf_json, actor_json):