mirror of https://gitlab.com/bashrc2/epicyon
Support more webfinger types
parent
cd68373609
commit
3d3078d46e
2
tests.py
2
tests.py
|
@ -1757,7 +1757,7 @@ def test_follow_between_servers(base_dir: str) -> None:
|
||||||
assert THR_BOB.is_alive() is False
|
assert THR_BOB.is_alive() is False
|
||||||
|
|
||||||
# queue item removed
|
# queue item removed
|
||||||
time.sleep(4)
|
time.sleep(8)
|
||||||
assert len([name for name in os.listdir(queue_path)
|
assert len([name for name in os.listdir(queue_path)
|
||||||
if os.path.isfile(os.path.join(queue_path, name))]) == 0
|
if os.path.isfile(os.path.join(queue_path, name))]) == 0
|
||||||
|
|
||||||
|
|
36
webfinger.py
36
webfinger.py
|
@ -23,6 +23,8 @@ from utils import remove_domain_port
|
||||||
from utils import get_user_paths
|
from utils import get_user_paths
|
||||||
from utils import get_group_paths
|
from utils import get_group_paths
|
||||||
from utils import local_actor_url
|
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):
|
def _parse_handle(handle: str) -> (str, str, bool):
|
||||||
|
@ -304,16 +306,48 @@ def webfinger_lookup(path: str, base_dir: str,
|
||||||
return None
|
return None
|
||||||
handle = None
|
handle = None
|
||||||
res_type = 'acct'
|
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 = path.split('resource=' + res_type + ':')[1].strip()
|
||||||
handle = urllib.parse.unquote(handle)
|
handle = urllib.parse.unquote(handle)
|
||||||
if debug:
|
if debug:
|
||||||
print('DEBUG: WEBFINGER handle ' + handle)
|
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:
|
elif 'resource=' + res_type + '%3A' in path:
|
||||||
|
# GET /.well-known/webfinger?resource=acct%3Anick@domain
|
||||||
handle = path.split('resource=' + res_type + '%3A')[1]
|
handle = path.split('resource=' + res_type + '%3A')[1]
|
||||||
handle = urllib.parse.unquote(handle.strip())
|
handle = urllib.parse.unquote(handle.strip())
|
||||||
if debug:
|
if debug:
|
||||||
print('DEBUG: WEBFINGER handle ' + handle)
|
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 not handle:
|
||||||
if debug:
|
if debug:
|
||||||
print('DEBUG: WEBFINGER handle missing')
|
print('DEBUG: WEBFINGER handle missing')
|
||||||
|
|
Loading…
Reference in New Issue