Check that webfinger returns a dict

main
Bob Mottram 2020-06-23 11:41:12 +01:00
parent 976ee3a89d
commit ee70877aeb
13 changed files with 93 additions and 5 deletions

View File

@ -374,6 +374,10 @@ def sendAnnounceViaServer(baseDir: str, session,
if debug:
print('DEBUG: announce webfinger failed for ' + handle)
return 1
if not isinstance(wfRequest, dict):
print('WARN: Webfinger for ' + handle + ' did not return a dict. ' +
str(wfRequest))
return 1
postToBox = 'outbox'

View File

@ -113,6 +113,10 @@ def sendAvailabilityViaServer(baseDir: str, session,
if debug:
print('DEBUG: announce webfinger failed for ' + handle)
return 1
if not isinstance(wfRequest, dict):
print('WARN: Webfinger for ' + handle + ' did not return a dict. ' +
str(wfRequest))
return 1
postToBox = 'outbox'

View File

@ -445,6 +445,10 @@ def sendBookmarkViaServer(baseDir: str, session,
if debug:
print('DEBUG: announce webfinger failed for ' + handle)
return 1
if not isinstance(wfRequest, dict):
print('WARN: Webfinger for ' + handle + ' did not return a dict. ' +
str(wfRequest))
return 1
postToBox = 'outbox'
@ -523,6 +527,10 @@ def sendUndoBookmarkViaServer(baseDir: str, session,
if debug:
print('DEBUG: announce webfinger failed for ' + handle)
return 1
if not isinstance(wfRequest, dict):
print('WARN: Webfinger for ' + handle + ' did not return a dict. ' +
str(wfRequest))
return 1
postToBox = 'outbox'

View File

@ -126,6 +126,10 @@ def sendDeleteViaServer(baseDir: str, session,
if debug:
print('DEBUG: announce webfinger failed for ' + handle)
return 1
if not isinstance(wfRequest, dict):
print('WARN: Webfinger for ' + handle + ' did not return a dict. ' +
str(wfRequest))
return 1
postToBox = 'outbox'

View File

@ -1095,11 +1095,16 @@ if args.actor:
if nickname == 'inbox':
nickname = domain
wfRequest = webfingerHandle(session, nickname + '@' + domain,
handle = nickname + '@' + domain
wfRequest = webfingerHandle(session, handle,
httpPrefix, cachedWebfingers,
None, __version__)
if not wfRequest:
print('Unable to webfinger ' + nickname + '@' + domain)
print('Unable to webfinger ' + handle)
sys.exit()
if not isinstance(wfRequest, dict):
print('Webfinger for ' + handle + ' did not return a dict. ' +
str(wfRequest))
sys.exit()
pprint(wfRequest)

View File

@ -925,6 +925,10 @@ def sendFollowRequestViaServer(baseDir: str, session,
if debug:
print('DEBUG: announce webfinger failed for ' + handle)
return 1
if not isinstance(wfRequest, dict):
print('WARN: Webfinger for ' + handle + ' did not return a dict. ' +
str(wfRequest))
return 1
postToBox = 'outbox'
@ -1019,6 +1023,10 @@ def sendUnfollowRequestViaServer(baseDir: str, session,
if debug:
print('DEBUG: announce webfinger failed for ' + handle)
return 1
if not isinstance(wfRequest, dict):
print('WARN: Webfinger for ' + handle + ' did not return a dict. ' +
str(wfRequest))
return 1
postToBox = 'outbox'

View File

@ -256,6 +256,10 @@ def sendLikeViaServer(baseDir: str, session,
if debug:
print('DEBUG: announce webfinger failed for ' + handle)
return 1
if not isinstance(wfRequest, dict):
print('WARN: Webfinger for ' + handle + ' did not return a dict. ' +
str(wfRequest))
return 1
postToBox = 'outbox'
@ -337,6 +341,10 @@ def sendUndoLikeViaServer(baseDir: str, session,
if debug:
print('DEBUG: announce webfinger failed for ' + handle)
return 1
if not isinstance(wfRequest, dict):
print('WARN: Webfinger for ' + handle + ' did not return a dict. ' +
str(wfRequest))
return 1
postToBox = 'outbox'

View File

@ -1368,6 +1368,10 @@ def sendPost(projectVersion: str,
domain, projectVersion)
if not wfRequest:
return 1
if not isinstance(wfRequest, dict):
print('WARN: Webfinger for ' + handle + ' did not return a dict. ' +
str(wfRequest))
return 1
if not clientToServer:
postToBox = 'inbox'
@ -1488,6 +1492,10 @@ def sendPostViaServer(projectVersion: str,
if debug:
print('DEBUG: webfinger failed for ' + handle)
return 1
if not isinstance(wfRequest, dict):
print('WARN: Webfinger for ' + handle + ' did not return a dict. ' +
str(wfRequest))
return 1
postToBox = 'outbox'
if isArticle:
@ -1670,6 +1678,7 @@ def sendSignedJson(postJsonObject: {}, session, baseDir: str,
if not siteIsActive(toDomainUrl):
print('Domain is inactive: ' + toDomainUrl)
return 9
print('Domain is active: ' + toDomainUrl)
handleBase = toDomainUrl + '/@'
if toNickname:
handle = handleBase + toNickname
@ -1687,6 +1696,10 @@ def sendSignedJson(postJsonObject: {}, session, baseDir: str,
if debug:
print('DEBUG: webfinger for ' + handle + ' failed')
return 1
if not isinstance(wfRequest, dict):
print('WARN: Webfinger for ' + handle + ' did not return a dict. ' +
str(wfRequest))
return 1
if wfRequest.get('errors'):
if debug:
@ -1986,8 +1999,9 @@ def hasSharedInbox(session, httpPrefix: str, domain: str) -> bool:
httpPrefix, {},
None, __version__)
if wfRequest:
if not wfRequest.get('errors'):
return True
if isinstance(wfRequest, dict):
if not wfRequest.get('errors'):
return True
return False
@ -2877,6 +2891,10 @@ def getPublicPostsOfPerson(baseDir: str, nickname: str, domain: str,
domain, projectVersion)
if not wfRequest:
sys.exit()
if not isinstance(wfRequest, dict):
print('Webfinger for ' + handle + ' did not return a dict. ' +
str(wfRequest))
sys.exit()
(personUrl, pubKeyId, pubKey,
personId, shaedInbox,
@ -3257,6 +3275,10 @@ def sendBlockViaServer(baseDir: str, session,
if debug:
print('DEBUG: announce webfinger failed for ' + handle)
return 1
if not isinstance(wfRequest, dict):
print('WARN: Webfinger for ' + handle + ' did not return a dict. ' +
str(wfRequest))
return 1
postToBox = 'outbox'
@ -3342,6 +3364,10 @@ def sendUndoBlockViaServer(baseDir: str, session,
if debug:
print('DEBUG: announce webfinger failed for ' + handle)
return 1
if not isinstance(wfRequest, dict):
print('WARN: Webfinger for ' + handle + ' did not return a dict. ' +
str(wfRequest))
return 1
postToBox = 'outbox'

View File

@ -281,6 +281,10 @@ def sendRoleViaServer(baseDir: str, session,
if debug:
print('DEBUG: announce webfinger failed for ' + handle)
return 1
if not isinstance(wfRequest, dict):
print('WARN: Webfinger for ' + handle + ' did not return a dict. ' +
str(wfRequest))
return 1
postToBox = 'outbox'

View File

@ -392,6 +392,10 @@ def sendShareViaServer(baseDir, session,
if debug:
print('DEBUG: announce webfinger failed for ' + handle)
return 1
if not isinstance(wfRequest, dict):
print('WARN: Webfinger for ' + handle + ' did not return a dict. ' +
str(wfRequest))
return 1
postToBox = 'outbox'
@ -491,6 +495,10 @@ def sendUndoShareViaServer(baseDir: str, session,
if debug:
print('DEBUG: announce webfinger failed for ' + handle)
return 1
if not isinstance(wfRequest, dict):
print('WARN: Webfinger for ' + handle + ' did not return a dict. ' +
str(wfRequest))
return 1
postToBox = 'outbox'

View File

@ -142,6 +142,10 @@ def sendSkillViaServer(baseDir: str, session, nickname: str, password: str,
if debug:
print('DEBUG: announce webfinger failed for ' + handle)
return 1
if not isinstance(wfRequest, dict):
print('WARN: Webfinger for ' + handle + ' did not return a dict. ' +
str(wfRequest))
return 1
postToBox = 'outbox'

View File

@ -47,7 +47,7 @@ def parseHandle(handle: str) -> (str, str):
def webfingerHandle(session, handle: str, httpPrefix: str,
cachedWebfingers: {},
fromDomain: str, projectVersion: str) -> {}:
"""
"""Gets webfinger result for the given ActivityPub handle
"""
if not session:
print('WARN: No session specified for webfingerHandle')

View File

@ -6003,6 +6003,11 @@ def htmlProfileAfterSearch(recentPostsCache: {}, maxRecentPosts: int,
print('DEBUG: httpPrefix ' + httpPrefix)
print('DEBUG: domain ' + domain)
return None
if not isinstance(wf, dict):
print('WARN: Webfinger for ' + handle +
' did not return a dict. ' +
str(wf))
return None
personUrl = None
if wf.get('errors'):