Only store webfinger in cache if returned

main
Bob Mottram 2020-05-07 14:21:58 +01:00
parent 0f1ad061ec
commit 959c1080c7
3 changed files with 10 additions and 9 deletions

View File

@ -6004,8 +6004,7 @@ class PubServer(BaseHTTPRequestHandler):
searchStr = searchStr.replace('+', ' ') searchStr = searchStr.replace('+', ' ')
searchStr = \ searchStr = \
urllib.parse.unquote(searchStr.strip()) urllib.parse.unquote(searchStr.strip())
if self.server.debug: print('searchStr: ' + searchStr)
print('searchStr: ' + searchStr)
if searchForEmoji: if searchForEmoji:
searchStr = ':' + searchStr + ':' searchStr = ':' + searchStr + ':'
if searchStr.startswith('#'): if searchStr.startswith('#'):

View File

@ -44,6 +44,8 @@ def parseHandle(handle: str) -> (str, str):
def webfingerHandle(session, handle: str, httpPrefix: str, def webfingerHandle(session, handle: str, httpPrefix: str,
cachedWebfingers: {}, cachedWebfingers: {},
fromDomain: str, projectVersion: str) -> {}: fromDomain: str, projectVersion: str) -> {}:
"""
"""
if not session: if not session:
print('WARN: No session specified for webfingerHandle') print('WARN: No session specified for webfingerHandle')
return None return None
@ -81,8 +83,10 @@ def webfingerHandle(session, handle: str, httpPrefix: str,
print('params: ' + str(par)) print('params: ' + str(par))
print(e) print(e)
return None return None
storeWebfingerInCache(nickname + '@' + wfDomain,
result, cachedWebfingers) if result:
storeWebfingerInCache(nickname + '@' + wfDomain,
result, cachedWebfingers)
return result return result

View File

@ -5846,9 +5846,8 @@ def htmlProfileAfterSearch(recentPostsCache: {}, maxRecentPosts: int,
httpPrefix, wfRequest, httpPrefix, wfRequest,
domain, projectVersion) domain, projectVersion)
if not wf: if not wf:
if debug: print('DEBUG: Unable to webfinger ' +
print('DEBUG: Unable to webfinger ' + searchNickname + '@' + searchDomainFull)
searchNickname + '@' + searchDomainFull)
return None return None
personUrl = None personUrl = None
if wf.get('errors'): if wf.get('errors'):
@ -5878,8 +5877,7 @@ def htmlProfileAfterSearch(recentPostsCache: {}, maxRecentPosts: int,
getJson(session, personUrl, asHeader, None, getJson(session, personUrl, asHeader, None,
projectVersion, httpPrefix, domain) projectVersion, httpPrefix, domain)
if not profileJson: if not profileJson:
if debug: print('DEBUG: No actor returned from ' + personUrl)
print('DEBUG: No actor returned from ' + personUrl)
return None return None
avatarUrl = '' avatarUrl = ''
if profileJson.get('icon'): if profileJson.get('icon'):