forked from indymedia/epicyon
Check that webfinger returns a valid actor url
parent
fe135682c5
commit
536731f256
6
posts.py
6
posts.py
|
@ -115,7 +115,11 @@ def getUserUrl(wfRequest) -> str:
|
|||
for link in wfRequest['links']:
|
||||
if link.get('type') and link.get('href'):
|
||||
if link['type'] == 'application/activity+json':
|
||||
return link['href']
|
||||
if '/users/' in link['href'] or '/profile/' in link['href']:
|
||||
return link['href']
|
||||
else:
|
||||
print('Webfinger activity+json does not contain a valid actor')
|
||||
print(link['href'])
|
||||
return None
|
||||
|
||||
def parseUserFeed(session,feedUrl: str,asHeader: {}, \
|
||||
|
|
|
@ -51,14 +51,16 @@ def webfingerHandle(session,handle: str,httpPrefix: str,cachedWebfingers: {}, \
|
|||
wfDomain=wfDomain.split(':')[0]
|
||||
wf=getWebfingerFromCache(nickname+'@'+wfDomain,cachedWebfingers)
|
||||
if wf:
|
||||
return wf
|
||||
return wf
|
||||
url = '{}://{}/.well-known/webfinger'.format(httpPrefix,domain)
|
||||
par = {'resource': 'acct:{}'.format(nickname+'@'+wfDomain)}
|
||||
hdr = {'Accept': 'application/jrd+json'}
|
||||
hdr = {'Accept': 'application/jrd+json'}
|
||||
try:
|
||||
result = getJson(session, url, hdr, par,projectVersion,httpPrefix,fromDomain)
|
||||
except Exception as e:
|
||||
print("Unable to webfinger " + url)
|
||||
print('nickname: '+str(nickname))
|
||||
print('domain: '+str(wfDomain))
|
||||
print('headers: '+str(hdr))
|
||||
print('params: '+str(par))
|
||||
print(e)
|
||||
|
|
|
@ -2309,6 +2309,10 @@ def htmlProfileAfterSearch(baseDir: str,path: str,httpPrefix: str, \
|
|||
return None
|
||||
asHeader = {'Accept': 'application/activity+json; profile="https://www.w3.org/ns/activitystreams"'}
|
||||
personUrl = getUserUrl(wf)
|
||||
if not personUrl:
|
||||
if debug:
|
||||
print('DEBUG: Webfinger did not return an actor url')
|
||||
return None
|
||||
profileJson = getJson(session,personUrl,asHeader,None,projectVersion,httpPrefix,domain)
|
||||
if not profileJson:
|
||||
if debug:
|
||||
|
|
Loading…
Reference in New Issue