diff --git a/tests.py b/tests.py index 53da447af..cfa151a63 100644 --- a/tests.py +++ b/tests.py @@ -1757,7 +1757,7 @@ def test_follow_between_servers(base_dir: str) -> None: assert THR_BOB.is_alive() is False # queue item removed - time.sleep(4) + time.sleep(8) assert len([name for name in os.listdir(queue_path) if os.path.isfile(os.path.join(queue_path, name))]) == 0 diff --git a/webfinger.py b/webfinger.py index 2101aabb0..46d7c4136 100644 --- a/webfinger.py +++ b/webfinger.py @@ -23,6 +23,8 @@ from utils import remove_domain_port from utils import get_user_paths from utils import get_group_paths from utils import local_actor_url +from utils import get_nickname_from_actor +from utils import get_domain_from_actor def _parse_handle(handle: str) -> (str, str, bool): @@ -304,16 +306,48 @@ def webfinger_lookup(path: str, base_dir: str, return None handle = None res_type = 'acct' - if 'resource=' + res_type + ':' in path: + if 'resource=' + res_type + ':http' in path: + # GET /.well-known/webfinger?resource=acct:https://domain/users/nick + actor = path.split('resource=' + res_type + ':')[1] + actor = urllib.parse.unquote(actor.strip()) + wf_nickname = get_nickname_from_actor(actor) + wf_domain, port = get_domain_from_actor(actor) + if wf_nickname and wf_domain: + handle = wf_nickname + '@' + wf_domain + if debug: + print('DEBUG: WEBFINGER handle ' + handle) + elif 'resource=' + res_type + ':' in path: + # GET /.well-known/webfinger?resource=acct:nick@domain handle = path.split('resource=' + res_type + ':')[1].strip() handle = urllib.parse.unquote(handle) if debug: print('DEBUG: WEBFINGER handle ' + handle) + elif 'resource=' + res_type + '%3Ahttp' in path: + # GET /.well-known/webfinger?resource=acct%3Ahttps://domain/users/nick + actor = path.split('resource=' + res_type + '%3A')[1] + actor = urllib.parse.unquote(actor.strip()) + wf_nickname = get_nickname_from_actor(actor) + wf_domain, port = get_domain_from_actor(actor) + if wf_nickname and wf_domain: + handle = wf_nickname + '@' + wf_domain + if debug: + print('DEBUG: WEBFINGER handle ' + handle) elif 'resource=' + res_type + '%3A' in path: + # GET /.well-known/webfinger?resource=acct%3Anick@domain handle = path.split('resource=' + res_type + '%3A')[1] handle = urllib.parse.unquote(handle.strip()) if debug: print('DEBUG: WEBFINGER handle ' + handle) + elif 'resource=http' in path: + # GET /.well-known/webfinger?resource=https://domain/users/nick + actor = path.split('resource=')[1] + actor = urllib.parse.unquote(actor.strip()) + wf_nickname = get_nickname_from_actor(actor) + wf_domain, port = get_domain_from_actor(actor) + if wf_nickname and wf_domain: + handle = wf_nickname + '@' + wf_domain + if debug: + print('DEBUG: WEBFINGER handle ' + handle) if not handle: if debug: print('DEBUG: WEBFINGER handle missing')