From 58ad9243d6abc18514523182520a5b5ae7e7ebde Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Fri, 27 May 2022 11:00:23 +0100 Subject: [PATCH] Set the user agent domain --- posts.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/posts.py b/posts.py index b54673732..c102b29b0 100644 --- a/posts.py +++ b/posts.py @@ -3287,7 +3287,8 @@ def send_to_named_addresses_thread(server, session, session_onion, session_i2p, def _has_shared_inbox(session, http_prefix: str, domain: str, - debug: bool, signing_priv_key_pem: str) -> bool: + debug: bool, signing_priv_key_pem: str, + ua_domain: str) -> bool: """Returns true if the given domain has a shared inbox This tries the new and the old way of webfingering the shared inbox """ @@ -3297,7 +3298,7 @@ def _has_shared_inbox(session, http_prefix: str, domain: str, try_handles.append('inbox@' + domain) for handle in try_handles: wf_request = webfinger_handle(session, handle, http_prefix, {}, - domain, __version__, debug, False, + ua_domain, __version__, debug, False, signing_priv_key_pem) if wf_request: if isinstance(wf_request, dict): @@ -3411,9 +3412,16 @@ def send_to_followers(server, session, session_onion, session_i2p, curr_session = session_i2p curr_http_prefix = 'http' + # get the domain showin by the user agent + ua_domain = domain + if follower_domain.endswith('.onion'): + ua_domain = onion_domain + elif follower_domain.endswith('.i2p'): + ua_domain = i2p_domain + with_shared_inbox = \ _has_shared_inbox(curr_session, curr_http_prefix, follower_domain, - debug, signing_priv_key_pem) + debug, signing_priv_key_pem, ua_domain) if debug: if with_shared_inbox: print(follower_domain + ' has shared inbox')