diff --git a/announce.py b/announce.py index 814728c15..92c412c5c 100644 --- a/announce.py +++ b/announce.py @@ -77,7 +77,7 @@ def outboxAnnounce(recentPostsCache: {}, nickname, domain, debug) return True elif messageJson['type'] == 'Undo': - if not isinstance(messageJson['object'], dict): + if not hasObjectDict(messageJson): return False if not messageJson['object'].get('type'): return False diff --git a/inbox.py b/inbox.py index d1f6d2450..8fbaccf50 100644 --- a/inbox.py +++ b/inbox.py @@ -298,7 +298,7 @@ def inboxMessageHasParams(messageJson: {}) -> bool: return False # object should be a dict or a string - if not isinstance(messageJson['object'], dict): + if not hasObjectDict(messageJson): if not isinstance(messageJson['object'], str): print('WARN: object from ' + str(messageJson['actor']) + ' should be a dict or string, but is actually: ' + diff --git a/media.py b/media.py index 2f788117e..0206a10ba 100644 --- a/media.py +++ b/media.py @@ -18,6 +18,7 @@ from utils import getImageExtensions from utils import getVideoExtensions from utils import getAudioExtensions from utils import getMediaExtensions +from utils import hasObjectDict from shutil import copyfile from shutil import rmtree from shutil import move @@ -30,7 +31,7 @@ def replaceYouTube(postJsonObject: {}, replacementDomain: str) -> None: """ if not replacementDomain: return - if not isinstance(postJsonObject['object'], dict): + if not hasObjectDict(postJsonObject): return if not postJsonObject['object'].get('content'): return diff --git a/posts.py b/posts.py index a213f7444..0dc9e7179 100644 --- a/posts.py +++ b/posts.py @@ -1296,7 +1296,7 @@ def _postIsAddressedToFollowers(baseDir: str, toList = [] ccList = [] if postJsonObject['type'] != 'Update' and \ - isinstance(postJsonObject['object'], dict): + hasObjectDict(postJsonObject): if postJsonObject['object'].get('to'): toList = postJsonObject['object']['to'] if postJsonObject['object'].get('cc'): @@ -2169,7 +2169,7 @@ def _addFollowersToPublicPost(postJsonObject: {}) -> None: if postJsonObject.get('cc'): return postJsonObject['cc'] = postJsonObject['actor'] + '/followers' - elif isinstance(postJsonObject['object'], dict): + elif hasObjectDict(postJsonObject): if not postJsonObject['object'].get('to'): return if len(postJsonObject['object']['to']) > 1: @@ -2433,7 +2433,7 @@ def sendToNamedAddresses(session, baseDir: str, if not postJsonObject.get('object'): return isProfileUpdate = False - if isinstance(postJsonObject['object'], dict): + if hasObjectDict(postJsonObject): if _isProfileUpdate(postJsonObject): # use the original object, which has a 'to' recipientsObject = postJsonObject diff --git a/question.py b/question.py index 9008cbd56..60deecdc4 100644 --- a/question.py +++ b/question.py @@ -126,7 +126,7 @@ def isQuestion(postObjectJson: {}) -> bool: if postObjectJson['type'] != 'Create' and \ postObjectJson['type'] != 'Update': return False - if not isinstance(postObjectJson['object'], dict): + if not hasObjectDict(postObjectJson): return False if not postObjectJson['object'].get('type'): return False diff --git a/utils.py b/utils.py index 0d85039cb..9d21085f2 100644 --- a/utils.py +++ b/utils.py @@ -1401,7 +1401,7 @@ def deletePost(baseDir: str, httpPrefix: str, # remove from moderation index file if hasObject: - if isinstance(postJsonObject['object'], dict): + if hasObjectDict(postJsonObject): if postJsonObject['object'].get('moderationStatus'): if postJsonObject.get('id'): postId = removeIdEnding(postJsonObject['id']) diff --git a/webapp_person_options.py b/webapp_person_options.py index 6b55aafd8..3c3309196 100644 --- a/webapp_person_options.py +++ b/webapp_person_options.py @@ -398,9 +398,10 @@ def htmlPersonOptions(defaultTimeline: str, 'accesskey="' + accessKeys['enterNotes'] + '">' + \ personNotes + '\n' - optionsStr += ' \n' - optionsStr += '\n' - optionsStr += '\n' - optionsStr += '\n' + optionsStr += \ + ' \n' + \ + '\n' + \ + '\n' + \ + '\n' optionsStr += htmlFooter() return optionsStr diff --git a/webapp_post.py b/webapp_post.py index fa1317344..3d3ff9941 100644 --- a/webapp_post.py +++ b/webapp_post.py @@ -22,6 +22,7 @@ from posts import postIsMuted from posts import getPersonBox from posts import downloadAnnounce from posts import populateRepliesJson +from utils import hasObjectDict from utils import updateAnnounceCollection from utils import isPGPEncrypted from utils import isDM @@ -840,8 +841,7 @@ def _getPostTitleAnnounceHtml(baseDir: str, postJsonObject) else: titleStr += \ - _announceUnattributedHtml(translate, - postJsonObject) + _announceUnattributedHtml(translate, postJsonObject) else: titleStr += \ _announceUnattributedHtml(translate, postJsonObject) @@ -1339,7 +1339,7 @@ def individualPostAsHtml(allowDownloads: bool, _logPostTiming(enableTimingLog, postStartTime, '8') - if not isinstance(postJsonObject['object'], dict): + if not hasObjectDict(postJsonObject): return '' # if this post should be public then check its recipients @@ -1762,7 +1762,7 @@ def htmlIndividualPost(cssCache: {}, messageId = removeIdEnding(postJsonObject['id']) # show the previous posts - if isinstance(postJsonObject['object'], dict): + if hasObjectDict(postJsonObject): while postJsonObject['object'].get('inReplyTo'): postFilename = \ locatePost(baseDir, nickname, domain,