diff --git a/daemon.py b/daemon.py index 19926f4e9..81c112e24 100644 --- a/daemon.py +++ b/daemon.py @@ -1229,10 +1229,10 @@ class PubServer(BaseHTTPRequestHandler): self.server.vcard_is_active = False return True if 'vcard+xml' in accept_str: - vcard_str = actor_to_vcard_xml(actor_json) + vcard_str = actor_to_vcard_xml(actor_json, domain) header_type = 'text/vcard+xml; charset=utf-8' else: - vcard_str = actor_to_vcard(actor_json) + vcard_str = actor_to_vcard(actor_json, domain) header_type = 'text/vcard; charset=utf-8' if vcard_str: msg = vcard_str.encode('utf-8') diff --git a/epicyon.py b/epicyon.py index 635deeda9..ec6644a2b 100644 --- a/epicyon.py +++ b/epicyon.py @@ -291,7 +291,7 @@ parser.add_argument('--postsraw', dest='postsraw', type=str, help='Show raw json of posts for the given handle') parser.add_argument('--vcard', dest='vcard', type=str, default=None, help='Show the vcard for a given activitypub actor url') -parser.add_argument('--vcardxml', dest='vcardxml', type=str, default=None, +parser.add_argument('--xmlvcard', dest='xmlvcard', type=str, default=None, help='Show the xml vcard for a given ' + 'activitypub actor url') parser.add_argument('--json', dest='json', type=str, default=None, @@ -986,7 +986,7 @@ if args.vcard: print(test_vcard) sys.exit() -if args.vcardxml: +if args.xmlvcard: session = create_session(None) if not args.domain: args.domain = get_config_param(base_dir, 'domain') diff --git a/pgp.py b/pgp.py index ce8297b39..6a84784a9 100644 --- a/pgp.py +++ b/pgp.py @@ -630,7 +630,7 @@ def pgp_public_key_upload(base_dir: str, session, return actor_update -def actor_to_vcard(actor: {}) -> str: +def actor_to_vcard(actor: {}, domain: str) -> str: """Returns a vcard for a given actor """ vcard_str = 'BEGIN:VCARD\n' @@ -638,10 +638,10 @@ def actor_to_vcard(actor: {}) -> str: vcard_str += 'REV:' + actor['published'] + '\n' vcard_str += 'FN:' + remove_html(actor['name']) + '\n' vcard_str += 'NICKNAME:' + actor['preferredUsername'] + '\n' - vcard_str += 'URL:profile:' + actor['url'] + '\n' + vcard_str += 'URL;TYPE=profile:' + actor['url'] + '\n' blog_address = get_blog_address(actor) if blog_address: - vcard_str += 'URL:blog:' + blog_address + '\n' + vcard_str += 'URL;TYPE=blog:' + blog_address + '\n' vcard_str += 'NOTE:' + remove_html(actor['summary']) + '\n' if actor['icon']['url']: vcard_str += 'PHOTO:' + actor['icon']['url'] + '\n' @@ -652,23 +652,25 @@ def actor_to_vcard(actor: {}) -> str: email_address = get_email_address(actor) if email_address: vcard_str += 'EMAIL;TYPE=internet:' + email_address + '\n' + vcard_str += 'IMPP;TYPE=fediverse:' + \ + actor['preferredUsername'] + '@' + domain + '\n' xmpp_address = get_xmpp_address(actor) if xmpp_address: - vcard_str += 'IMPP:xmpp:' + xmpp_address + '\n' + vcard_str += 'IMPP;TYPE=xmpp:' + xmpp_address + '\n' jami_address = get_jami_address(actor) if jami_address: - vcard_str += 'IMPP:jami:' + jami_address + '\n' + vcard_str += 'IMPP;TYPE=jami:' + jami_address + '\n' matrix_address = get_matrix_address(actor) if matrix_address: - vcard_str += 'IMPP:matrix:' + matrix_address + '\n' + vcard_str += 'IMPP;TYPE=matrix:' + matrix_address + '\n' briar_address = get_briar_address(actor) if briar_address: if briar_address.startswith('briar://'): briar_address = briar_address.split('briar://')[1] - vcard_str += 'IMPP:briar:' + briar_address + '\n' + vcard_str += 'IMPP;TYPE=briar:' + briar_address + '\n' cwtch_address = get_cwtch_address(actor) if cwtch_address: - vcard_str += 'IMPP:cwtch:' + cwtch_address + '\n' + vcard_str += 'IMPP;TYPE=cwtch:' + cwtch_address + '\n' if actor.get('hasOccupation'): if len(actor['hasOccupation']) > 0: if actor['hasOccupation'][0].get('name'): @@ -684,7 +686,7 @@ def actor_to_vcard(actor: {}) -> str: return vcard_str -def actor_to_vcard_xml(actor: {}) -> str: +def actor_to_vcard_xml(actor: {}, domain: str) -> str: """Returns a xml formatted vcard for a given actor """ vcard_str = '\n' @@ -699,6 +701,10 @@ def actor_to_vcard_xml(actor: {}) -> str: email_address = get_email_address(actor) if email_address: vcard_str += ' ' + email_address + '\n' + vcard_str += ' ' + \ + 'fediverse' + \ + '' + actor['preferredUsername'] + '@' + domain + \ + '\n' xmpp_address = get_xmpp_address(actor) if xmpp_address: vcard_str += ' ' + \