From 83dd0b09c6306d548591b33700e110cd750a5099 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Thu, 15 Aug 2024 19:27:29 +0100 Subject: [PATCH] Add website to vcard --- daemon_get.py | 2 +- daemon_get_vcard.py | 6 +++--- pgp.py | 13 +++++++++++-- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/daemon_get.py b/daemon_get.py index 55a6ebd0a..78ed882bf 100644 --- a/daemon_get.py +++ b/daemon_get.py @@ -342,7 +342,7 @@ def daemon_http_get(self) -> None: if show_vcard(self, self.server.base_dir, self.path, calling_domain, referer_domain, - self.server.domain): + self.server.domain, self.server.translate): return # getting the public key for an account diff --git a/daemon_get_vcard.py b/daemon_get_vcard.py index dd6fa4728..399c6cb96 100644 --- a/daemon_get_vcard.py +++ b/daemon_get_vcard.py @@ -22,7 +22,7 @@ from pgp import actor_to_vcard def show_vcard(self, base_dir: str, path: str, calling_domain: str, - referer_domain: str, domain: str) -> bool: + referer_domain: str, domain: str, translate: {}) -> bool: """Returns a vcard for the given account """ if not has_accept(self, calling_domain): @@ -68,10 +68,10 @@ def show_vcard(self, base_dir: str, path: str, calling_domain: str, self.server.vcard_is_active = False return True if 'application/vcard+xml' in accept_str: - vcard_str = actor_to_vcard_xml(actor_json, domain) + vcard_str = actor_to_vcard_xml(actor_json, domain, translate) header_type = 'application/vcard+xml; charset=utf-8' else: - vcard_str = actor_to_vcard(actor_json, domain) + vcard_str = actor_to_vcard(actor_json, domain, translate) header_type = 'text/vcard; charset=utf-8' if vcard_str: msg = vcard_str.encode('utf-8') diff --git a/pgp.py b/pgp.py index 0e264bd50..06d8a959c 100644 --- a/pgp.py +++ b/pgp.py @@ -37,6 +37,7 @@ from matrix import get_matrix_address from briar import get_briar_address from cwtch import get_cwtch_address from blog import get_blog_address +from donate import get_website from utils import get_attachment_property_value @@ -719,7 +720,7 @@ def pgp_public_key_upload(base_dir: str, session, return actor_update -def actor_to_vcard(actor: {}, domain: str) -> str: +def actor_to_vcard(actor: {}, domain: str, translate: {}) -> str: """Returns a vcard for a given actor """ actor_url_str = get_url_from_post(actor['url']) @@ -771,6 +772,9 @@ def actor_to_vcard(actor: {}, domain: str) -> str: peertube = get_peertube(actor) if peertube: vcard_str += 'SOCIALPROFILE;SERVICE-TYPE=PeerTube:' + peertube + '\n' + website = get_website(actor, translate) + if website: + vcard_str += 'URL:' + website + '\n' xmpp_address = get_xmpp_address(actor) if xmpp_address: vcard_str += 'IMPP:xmpp:' + xmpp_address + '\n' @@ -821,7 +825,7 @@ def actor_to_vcard(actor: {}, domain: str) -> str: return vcard_str -def actor_to_vcard_xml(actor: {}, domain: str) -> str: +def actor_to_vcard_xml(actor: {}, domain: str, translate: {}) -> str: """Returns a xml formatted vcard for a given actor """ vcard_str = '\n' @@ -906,6 +910,11 @@ def actor_to_vcard_xml(actor: {}, domain: str) -> str: vcard_str += ' ' + \ 'blog' + \ '' + blog_address + '\n' + website = get_website(actor, translate) + if website: + vcard_str += ' ' + \ + 'website' + \ + '' + website + '\n' vcard_str += ' ' + actor['published'] + '\n' url_str = get_url_from_post(actor['icon']['url']) if url_str: