diff --git a/announce.py b/announce.py index 68529de2..4dc0f74e 100644 --- a/announce.py +++ b/announce.py @@ -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' diff --git a/availability.py b/availability.py index a59d4cc4..e1415d12 100644 --- a/availability.py +++ b/availability.py @@ -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' diff --git a/bookmarks.py b/bookmarks.py index 526fe491..0039a6d8 100644 --- a/bookmarks.py +++ b/bookmarks.py @@ -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' diff --git a/delete.py b/delete.py index 6b1d6e71..5c966784 100644 --- a/delete.py +++ b/delete.py @@ -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' diff --git a/epicyon.py b/epicyon.py index 6082e5ad..376e33c9 100644 --- a/epicyon.py +++ b/epicyon.py @@ -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) diff --git a/follow.py b/follow.py index 923dee0b..b3963654 100644 --- a/follow.py +++ b/follow.py @@ -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' diff --git a/like.py b/like.py index 248d4de8..dde8bd8b 100644 --- a/like.py +++ b/like.py @@ -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' diff --git a/posts.py b/posts.py index b56777f7..0269e8b3 100644 --- a/posts.py +++ b/posts.py @@ -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' diff --git a/roles.py b/roles.py index 0d460243..967997b0 100644 --- a/roles.py +++ b/roles.py @@ -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' diff --git a/shares.py b/shares.py index 92d1bc84..a20fb805 100644 --- a/shares.py +++ b/shares.py @@ -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' diff --git a/skills.py b/skills.py index 52c3f3c9..c50931a7 100644 --- a/skills.py +++ b/skills.py @@ -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' diff --git a/webfinger.py b/webfinger.py index dbff7b61..c1ecdfc1 100644 --- a/webfinger.py +++ b/webfinger.py @@ -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') diff --git a/webinterface.py b/webinterface.py index 7627f60b..fabe2485 100644 --- a/webinterface.py +++ b/webinterface.py @@ -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'):