master
Bob Mottram 2019-07-03 10:42:54 +01:00
parent c2cc03c76a
commit 1cd0a3670f
1 changed files with 1 additions and 11 deletions

View File

@ -149,34 +149,24 @@ def webfingerMeta() -> str:
def webfingerLookup(path: str,baseDir: str) -> {}: def webfingerLookup(path: str,baseDir: str) -> {}:
"""Lookup the webfinger endpoint for an account """Lookup the webfinger endpoint for an account
""" """
print('############### _webfinger lookup 1')
if not path.startswith('/.well-known/webfinger?'): if not path.startswith('/.well-known/webfinger?'):
return None return None
print('############### _webfinger lookup 2')
handle=None handle=None
if 'resource=acct:' in path: if 'resource=acct:' in path:
print('############### _webfinger lookup 3')
handle=path.split('resource=acct:')[1].strip() handle=path.split('resource=acct:')[1].strip()
else: else:
print('############### _webfinger lookup 4')
if 'resource=acct%3A' in path: if 'resource=acct%3A' in path:
print('############### _webfinger lookup 5')
handle=path.split('resource=acct%3A')[1].replace('%40','@').strip() handle=path.split('resource=acct%3A')[1].replace('%40','@').strip()
print('############### _webfinger lookup 6')
if not handle: if not handle:
return None return None
print('############### _webfinger lookup 7')
if '&' in handle: if '&' in handle:
handle=handle.split('&')[0].strip() handle=handle.split('&')[0].strip()
print('############### _webfinger lookup 8')
if '@' not in handle: if '@' not in handle:
return None return None
filename=baseDir+'/wfendpoints/'+handle.lower()+'.json' filename=baseDir+'/wfendpoints/'+handle.lower()+'.json'
print('############### _webfinger lookup 9: '+filename)
if not os.path.isfile(filename): if not os.path.isfile(filename):
return None return None
print('############### _webfinger lookup 10') wfJson={"nickname": "unknown"}
wfJson={"user": "unknown"}
with open(filename, 'r') as fp: with open(filename, 'r') as fp:
wfJson=commentjson.load(fp) wfJson=commentjson.load(fp)
return wfJson return wfJson