From e8de6437602465aaeec05ff101cf1b56851242ce Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Sun, 13 Mar 2022 23:57:51 +0000 Subject: [PATCH] Convert domain from onion/i2p to account handle --- acceptreject.py | 21 ++++++++++++++++++--- inbox.py | 3 ++- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/acceptreject.py b/acceptreject.py index 054350110..1ce9d256c 100644 --- a/acceptreject.py +++ b/acceptreject.py @@ -76,7 +76,9 @@ def create_reject(base_dir: str, federation_list: [], def _accept_follow(base_dir: str, domain: str, message_json: {}, - federation_list: [], debug: bool) -> None: + federation_list: [], debug: bool, + curr_domain: str, + onion_domain: str, i2p_domain: str) -> None: """Receiving a follow Accept activity """ if not has_object_stringType(message_json, debug): @@ -144,6 +146,16 @@ def _accept_follow(base_dir: str, domain: str, message_json: {}, followed_actor) return + # convert from onion/i2p to clearnet accepted domain + if onion_domain: + if accepted_domain.endswith('.onion') and \ + not curr_domain.endswith('.onion'): + accepted_domain = curr_domain + if i2p_domain: + if accepted_domain.endswith('.i2p') and \ + not curr_domain.endswith('.i2p'): + accepted_domain = curr_domain + accepted_domain_full = accepted_domain if accepted_port: accepted_domain_full = accepted_domain + ':' + str(accepted_port) @@ -189,7 +201,9 @@ def receive_accept_reject(session, base_dir: str, cached_webfingers: {}, person_cache: {}, message_json: {}, federation_list: [], - debug: bool) -> bool: + debug: bool, + curr_domain: str, + onion_domain: str, i2p_domain: str) -> bool: """Receives an Accept or Reject within the POST section of HTTPServer """ if message_json['type'] != 'Accept' and message_json['type'] != 'Reject': @@ -215,7 +229,8 @@ def receive_accept_reject(session, base_dir: str, ' does not contain a nickname. ' + 'Assuming single user instance.') # receive follow accept - _accept_follow(base_dir, domain, message_json, federation_list, debug) + _accept_follow(base_dir, domain, message_json, federation_list, debug, + curr_domain, onion_domain, i2p_domain) if debug: print('DEBUG: Uh, ' + message_json['type'] + ', I guess') return True diff --git a/inbox.py b/inbox.py index 94e0791d1..70087df53 100644 --- a/inbox.py +++ b/inbox.py @@ -4602,7 +4602,8 @@ def run_inbox_queue(recent_posts_cache: {}, max_recent_posts: int, send_threads, post_log, cached_webfingers, person_cache, queue_json['post'], - federation_list, debug): + federation_list, debug, + domain, onion_domain, i2p_domain): print('Queue: Accept/Reject received from ' + key_id) if os.path.isfile(queue_filename): try: