diff --git a/blog.py b/blog.py index 2101c8e3..e41aacdf 100644 --- a/blog.py +++ b/blog.py @@ -170,8 +170,10 @@ def htmlBlogPostContent(authorized: bool, # get the handle of the author if postJsonObject['object'].get('attributedTo'): - actor = postJsonObject['object']['attributedTo'] - authorNickname = getNicknameFromActor(actor) + authorNickname = None + if isinstance(postJsonObject['object']['attributedTo'], str): + actor = postJsonObject['object']['attributedTo'] + authorNickname = getNicknameFromActor(actor) if authorNickname: authorDomain, authorPort = getDomainFromActor(actor) if authorDomain: diff --git a/git.py b/git.py index ffe8e131..68680e33 100644 --- a/git.py +++ b/git.py @@ -126,6 +126,8 @@ def convertPostToPatch(baseDir: str, nickname: str, domain: str, return False if not postJsonObject['object'].get('attributedTo'): return False + if not isinstance(postJsonObject['object']['attributedTo'], str): + return False if not isGitPatch(baseDir, nickname, domain, postJsonObject['object']['type'], postJsonObject['object']['summary'], diff --git a/inbox.py b/inbox.py index 2a9dfae1..15bf74a2 100644 --- a/inbox.py +++ b/inbox.py @@ -1422,12 +1422,15 @@ def receiveAnnounce(recentPostsCache: {}, # so that their avatar can be shown lookupActor = None if postJsonObject.get('attributedTo'): - lookupActor = postJsonObject['attributedTo'] + if isinstance(postJsonObject['attributedTo'], str): + lookupActor = postJsonObject['attributedTo'] else: if postJsonObject.get('object'): if isinstance(postJsonObject['object'], dict): if postJsonObject['object'].get('attributedTo'): - lookupActor = postJsonObject['object']['attributedTo'] + attrib = postJsonObject['object']['attributedTo'] + if isinstance(attrib, str): + lookupActor = attrib if lookupActor: if '/users/' in lookupActor or \ '/channel/' in lookupActor or \ @@ -2190,24 +2193,25 @@ def inboxAfterCapabilities(recentPostsCache: {}, maxRecentPosts: int, postJsonObject['object'].get('summary') and \ postJsonObject['object'].get('attributedTo'): attributedTo = postJsonObject['object']['attributedTo'] - fromNickname = getNicknameFromActor(attributedTo) - fromDomain, fromPort = getDomainFromActor(attributedTo) - if fromPort: - if fromPort != 80 and fromPort != 443: - fromDomain += ':' + str(fromPort) - if receiveGitPatch(baseDir, nickname, domain, - postJsonObject['object']['type'], - postJsonObject['object']['summary'], - postJsonObject['object']['content'], - fromNickname, fromDomain): - gitPatchNotify(baseDir, handle, - postJsonObject['object']['summary'], - postJsonObject['object']['content'], - fromNickname, fromDomain) - elif '[PATCH]' in postJsonObject['object']['content']: - print('WARN: git patch not accepted - ' + - postJsonObject['object']['summary']) - return False + if isinstance(attributedTo, str): + fromNickname = getNicknameFromActor(attributedTo) + fromDomain, fromPort = getDomainFromActor(attributedTo) + if fromPort: + if fromPort != 80 and fromPort != 443: + fromDomain += ':' + str(fromPort) + if receiveGitPatch(baseDir, nickname, domain, + postJsonObject['object']['type'], + postJsonObject['object']['summary'], + postJsonObject['object']['content'], + fromNickname, fromDomain): + gitPatchNotify(baseDir, handle, + postJsonObject['object']['summary'], + postJsonObject['object']['content'], + fromNickname, fromDomain) + elif '[PATCH]' in postJsonObject['object']['content']: + print('WARN: git patch not accepted - ' + + postJsonObject['object']['summary']) + return False # replace YouTube links, so they get less tracking data replaceYouTube(postJsonObject, YTReplacementDomain) diff --git a/webinterface.py b/webinterface.py index 4ebf561b..fbb1d826 100644 --- a/webinterface.py +++ b/webinterface.py @@ -3813,8 +3813,9 @@ def individualPostAsHtml(recentPostsCache: {}, maxRecentPosts: int, if showIcons: replyToLink = postJsonObject['object']['id'] if postJsonObject['object'].get('attributedTo'): - replyToLink += \ - '?mention=' + postJsonObject['object']['attributedTo'] + if isinstance(postJsonObject['object']['attributedTo'], str): + replyToLink += \ + '?mention=' + postJsonObject['object']['attributedTo'] if postJsonObject['object'].get('content'): mentionedActors = \ getMentionsFromHtml(postJsonObject['object']['content']) @@ -3985,7 +3986,9 @@ def individualPostAsHtml(recentPostsCache: {}, maxRecentPosts: int, if showRepeatIcon: if isAnnounced: if postJsonObject['object'].get('attributedTo'): - attributedTo = postJsonObject['object']['attributedTo'] + attributedTo = '' + if isinstance(postJsonObject['object']['attributedTo'], str): + attributedTo = postJsonObject['object']['attributedTo'] if attributedTo.startswith(postActor): titleStr += \ ' \n' else: - announceNickname = \ - getNicknameFromActor(attributedTo) + announceNickname = None + if attributedTo: + announceNickname = getNicknameFromActor(attributedTo) if announceNickname: announceDomain, announcePort = \ getDomainFromActor(attributedTo)