mirror of https://gitlab.com/bashrc2/epicyon
Less verbose
parent
a3be3c1803
commit
041b6f0a8c
|
@ -76,7 +76,7 @@ def _updateMovedHandle(baseDir: str, nickname: str, domain: str,
|
||||||
'Accept': 'application/activity+json; profile="' + profileStr + '"'
|
'Accept': 'application/activity+json; profile="' + profileStr + '"'
|
||||||
}
|
}
|
||||||
if not personUrl:
|
if not personUrl:
|
||||||
personUrl = getUserUrl(wfRequest)
|
personUrl = getUserUrl(wfRequest, 0, debug)
|
||||||
if not personUrl:
|
if not personUrl:
|
||||||
return ctr
|
return ctr
|
||||||
|
|
||||||
|
|
|
@ -1204,7 +1204,7 @@ def getActorJson(handle: str, http: bool, gnunet: bool,
|
||||||
'Accept': 'application/activity+json; profile="' + profileStr + '"'
|
'Accept': 'application/activity+json; profile="' + profileStr + '"'
|
||||||
}
|
}
|
||||||
if not personUrl:
|
if not personUrl:
|
||||||
personUrl = getUserUrl(wfRequest)
|
personUrl = getUserUrl(wfRequest, 0, debug)
|
||||||
if nickname == domain:
|
if nickname == domain:
|
||||||
personUrl = personUrl.replace('/users/', '/actor/')
|
personUrl = personUrl.replace('/users/', '/actor/')
|
||||||
personUrl = personUrl.replace('/accounts/', '/actor/')
|
personUrl = personUrl.replace('/accounts/', '/actor/')
|
||||||
|
|
6
posts.py
6
posts.py
|
@ -148,7 +148,7 @@ def _cleanHtml(rawHtml: str) -> str:
|
||||||
return html.unescape(text)
|
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
|
"""Gets the actor url from a webfinger request
|
||||||
"""
|
"""
|
||||||
if not wfRequest.get('links'):
|
if not wfRequest.get('links'):
|
||||||
|
@ -166,7 +166,7 @@ def getUserUrl(wfRequest: {}, sourceId=0) -> str:
|
||||||
if link['type'] != 'application/activity+json':
|
if link['type'] != 'application/activity+json':
|
||||||
continue
|
continue
|
||||||
if '/@' not in link['href']:
|
if '/@' not in link['href']:
|
||||||
if not hasUsersPath(link['href']):
|
if debug and not hasUsersPath(link['href']):
|
||||||
print('getUserUrl webfinger activity+json ' +
|
print('getUserUrl webfinger activity+json ' +
|
||||||
'contains single user instance actor ' +
|
'contains single user instance actor ' +
|
||||||
str(sourceId) + ' ' + str(link))
|
str(sourceId) + ' ' + str(link))
|
||||||
|
@ -229,7 +229,7 @@ def getPersonBox(baseDir: str, session, wfRequest: {},
|
||||||
return None, None, None, None, None, None, None
|
return None, None, None, None, None, None, None
|
||||||
|
|
||||||
if not wfRequest.get('errors'):
|
if not wfRequest.get('errors'):
|
||||||
personUrl = getUserUrl(wfRequest, sourceId)
|
personUrl = getUserUrl(wfRequest, sourceId, False)
|
||||||
else:
|
else:
|
||||||
if nickname == 'dev':
|
if nickname == 'dev':
|
||||||
# try single user instance
|
# try single user instance
|
||||||
|
|
|
@ -75,12 +75,14 @@ def htmlProfileAfterSearch(cssCache: {},
|
||||||
searchDomain, searchPort = getDomainFromActor(profileHandle)
|
searchDomain, searchPort = getDomainFromActor(profileHandle)
|
||||||
else:
|
else:
|
||||||
if '@' not in profileHandle:
|
if '@' not in profileHandle:
|
||||||
print('DEBUG: no @ in ' + profileHandle)
|
if debug:
|
||||||
|
print('DEBUG: no @ in ' + profileHandle)
|
||||||
return None
|
return None
|
||||||
if profileHandle.startswith('@'):
|
if profileHandle.startswith('@'):
|
||||||
profileHandle = profileHandle[1:]
|
profileHandle = profileHandle[1:]
|
||||||
if '@' not in profileHandle:
|
if '@' not in profileHandle:
|
||||||
print('DEBUG: no @ in ' + profileHandle)
|
if debug:
|
||||||
|
print('DEBUG: no @ in ' + profileHandle)
|
||||||
return None
|
return None
|
||||||
searchNickname = profileHandle.split('@')[0]
|
searchNickname = profileHandle.split('@')[0]
|
||||||
searchDomain = profileHandle.split('@')[1]
|
searchDomain = profileHandle.split('@')[1]
|
||||||
|
@ -91,17 +93,21 @@ def htmlProfileAfterSearch(cssCache: {},
|
||||||
searchPort = int(searchPortStr)
|
searchPort = int(searchPortStr)
|
||||||
searchDomain = searchDomain.split(':')[0]
|
searchDomain = searchDomain.split(':')[0]
|
||||||
if searchPort:
|
if searchPort:
|
||||||
print('DEBUG: Search for handle ' +
|
if debug:
|
||||||
str(searchNickname) + '@' + str(searchDomain) + ':' +
|
print('DEBUG: Search for handle ' +
|
||||||
str(searchPort))
|
str(searchNickname) + '@' + str(searchDomain) + ':' +
|
||||||
|
str(searchPort))
|
||||||
else:
|
else:
|
||||||
print('DEBUG: Search for handle ' +
|
if debug:
|
||||||
str(searchNickname) + '@' + str(searchDomain))
|
print('DEBUG: Search for handle ' +
|
||||||
|
str(searchNickname) + '@' + str(searchDomain))
|
||||||
if not searchNickname:
|
if not searchNickname:
|
||||||
print('DEBUG: No nickname found in ' + profileHandle)
|
if debug:
|
||||||
|
print('DEBUG: No nickname found in ' + profileHandle)
|
||||||
return None
|
return None
|
||||||
if not searchDomain:
|
if not searchDomain:
|
||||||
print('DEBUG: No domain found in ' + profileHandle)
|
if debug:
|
||||||
|
print('DEBUG: No domain found in ' + profileHandle)
|
||||||
return None
|
return None
|
||||||
|
|
||||||
searchDomainFull = getFullDomain(searchDomain, searchPort)
|
searchDomainFull = getFullDomain(searchDomain, searchPort)
|
||||||
|
@ -117,17 +123,19 @@ def htmlProfileAfterSearch(cssCache: {},
|
||||||
httpPrefix, cachedWebfingers,
|
httpPrefix, cachedWebfingers,
|
||||||
domain, projectVersion, debug)
|
domain, projectVersion, debug)
|
||||||
if not wf:
|
if not wf:
|
||||||
print('DEBUG: Unable to webfinger ' +
|
if debug:
|
||||||
searchNickname + '@' + searchDomainFull)
|
print('DEBUG: Unable to webfinger ' +
|
||||||
print('DEBUG: cachedWebfingers ' + str(cachedWebfingers))
|
searchNickname + '@' + searchDomainFull)
|
||||||
print('DEBUG: httpPrefix ' + httpPrefix)
|
print('DEBUG: cachedWebfingers ' + str(cachedWebfingers))
|
||||||
print('DEBUG: domain ' + domain)
|
print('DEBUG: httpPrefix ' + httpPrefix)
|
||||||
|
print('DEBUG: domain ' + domain)
|
||||||
return None
|
return None
|
||||||
if not isinstance(wf, dict):
|
if not isinstance(wf, dict):
|
||||||
print('WARN: Webfinger search for ' +
|
if debug:
|
||||||
searchNickname + '@' + searchDomainFull +
|
print('WARN: Webfinger search for ' +
|
||||||
' did not return a dict. ' +
|
searchNickname + '@' + searchDomainFull +
|
||||||
str(wf))
|
' did not return a dict. ' +
|
||||||
|
str(wf))
|
||||||
return None
|
return None
|
||||||
|
|
||||||
personUrl = None
|
personUrl = None
|
||||||
|
@ -140,7 +148,7 @@ def htmlProfileAfterSearch(cssCache: {},
|
||||||
'Accept': 'application/activity+json; profile="' + profileStr + '"'
|
'Accept': 'application/activity+json; profile="' + profileStr + '"'
|
||||||
}
|
}
|
||||||
if not personUrl:
|
if not personUrl:
|
||||||
personUrl = getUserUrl(wf)
|
personUrl = getUserUrl(wf, 0, debug)
|
||||||
if not personUrl:
|
if not personUrl:
|
||||||
# try single user instance
|
# try single user instance
|
||||||
asHeader = {
|
asHeader = {
|
||||||
|
|
Loading…
Reference in New Issue