Less verbose

main
Bob Mottram 2021-03-14 20:41:37 +00:00
parent a3be3c1803
commit 041b6f0a8c
4 changed files with 32 additions and 24 deletions

View File

@ -76,7 +76,7 @@ def _updateMovedHandle(baseDir: str, nickname: str, domain: str,
'Accept': 'application/activity+json; profile="' + profileStr + '"'
}
if not personUrl:
personUrl = getUserUrl(wfRequest)
personUrl = getUserUrl(wfRequest, 0, debug)
if not personUrl:
return ctr

View File

@ -1204,7 +1204,7 @@ def getActorJson(handle: str, http: bool, gnunet: bool,
'Accept': 'application/activity+json; profile="' + profileStr + '"'
}
if not personUrl:
personUrl = getUserUrl(wfRequest)
personUrl = getUserUrl(wfRequest, 0, debug)
if nickname == domain:
personUrl = personUrl.replace('/users/', '/actor/')
personUrl = personUrl.replace('/accounts/', '/actor/')

View File

@ -148,7 +148,7 @@ def _cleanHtml(rawHtml: str) -> str:
return html.unescape(text)
def getUserUrl(wfRequest: {}, sourceId=0) -> str:
def getUserUrl(wfRequest: {}, sourceId=0, debug=False) -> str:
"""Gets the actor url from a webfinger request
"""
if not wfRequest.get('links'):
@ -166,7 +166,7 @@ def getUserUrl(wfRequest: {}, sourceId=0) -> str:
if link['type'] != 'application/activity+json':
continue
if '/@' not in link['href']:
if not hasUsersPath(link['href']):
if debug and not hasUsersPath(link['href']):
print('getUserUrl webfinger activity+json ' +
'contains single user instance actor ' +
str(sourceId) + ' ' + str(link))
@ -229,7 +229,7 @@ def getPersonBox(baseDir: str, session, wfRequest: {},
return None, None, None, None, None, None, None
if not wfRequest.get('errors'):
personUrl = getUserUrl(wfRequest, sourceId)
personUrl = getUserUrl(wfRequest, sourceId, False)
else:
if nickname == 'dev':
# try single user instance

View File

@ -75,12 +75,14 @@ def htmlProfileAfterSearch(cssCache: {},
searchDomain, searchPort = getDomainFromActor(profileHandle)
else:
if '@' not in profileHandle:
print('DEBUG: no @ in ' + profileHandle)
if debug:
print('DEBUG: no @ in ' + profileHandle)
return None
if profileHandle.startswith('@'):
profileHandle = profileHandle[1:]
if '@' not in profileHandle:
print('DEBUG: no @ in ' + profileHandle)
if debug:
print('DEBUG: no @ in ' + profileHandle)
return None
searchNickname = profileHandle.split('@')[0]
searchDomain = profileHandle.split('@')[1]
@ -91,17 +93,21 @@ def htmlProfileAfterSearch(cssCache: {},
searchPort = int(searchPortStr)
searchDomain = searchDomain.split(':')[0]
if searchPort:
print('DEBUG: Search for handle ' +
str(searchNickname) + '@' + str(searchDomain) + ':' +
str(searchPort))
if debug:
print('DEBUG: Search for handle ' +
str(searchNickname) + '@' + str(searchDomain) + ':' +
str(searchPort))
else:
print('DEBUG: Search for handle ' +
str(searchNickname) + '@' + str(searchDomain))
if debug:
print('DEBUG: Search for handle ' +
str(searchNickname) + '@' + str(searchDomain))
if not searchNickname:
print('DEBUG: No nickname found in ' + profileHandle)
if debug:
print('DEBUG: No nickname found in ' + profileHandle)
return None
if not searchDomain:
print('DEBUG: No domain found in ' + profileHandle)
if debug:
print('DEBUG: No domain found in ' + profileHandle)
return None
searchDomainFull = getFullDomain(searchDomain, searchPort)
@ -117,17 +123,19 @@ def htmlProfileAfterSearch(cssCache: {},
httpPrefix, cachedWebfingers,
domain, projectVersion, debug)
if not wf:
print('DEBUG: Unable to webfinger ' +
searchNickname + '@' + searchDomainFull)
print('DEBUG: cachedWebfingers ' + str(cachedWebfingers))
print('DEBUG: httpPrefix ' + httpPrefix)
print('DEBUG: domain ' + domain)
if debug:
print('DEBUG: Unable to webfinger ' +
searchNickname + '@' + searchDomainFull)
print('DEBUG: cachedWebfingers ' + str(cachedWebfingers))
print('DEBUG: httpPrefix ' + httpPrefix)
print('DEBUG: domain ' + domain)
return None
if not isinstance(wf, dict):
print('WARN: Webfinger search for ' +
searchNickname + '@' + searchDomainFull +
' did not return a dict. ' +
str(wf))
if debug:
print('WARN: Webfinger search for ' +
searchNickname + '@' + searchDomainFull +
' did not return a dict. ' +
str(wf))
return None
personUrl = None
@ -140,7 +148,7 @@ def htmlProfileAfterSearch(cssCache: {},
'Accept': 'application/activity+json; profile="' + profileStr + '"'
}
if not personUrl:
personUrl = getUserUrl(wf)
personUrl = getUserUrl(wf, 0, debug)
if not personUrl:
# try single user instance
asHeader = {