mirror of https://gitlab.com/bashrc2/epicyon
Check for dictionary objects
parent
457004794c
commit
06eb2b96a3
|
@ -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
|
||||
|
|
2
inbox.py
2
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: ' +
|
||||
|
|
3
media.py
3
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
|
||||
|
|
6
posts.py
6
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
|
||||
|
|
|
@ -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
|
||||
|
|
2
utils.py
2
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'])
|
||||
|
|
|
@ -398,9 +398,10 @@ def htmlPersonOptions(defaultTimeline: str,
|
|||
'accesskey="' + accessKeys['enterNotes'] + '">' + \
|
||||
personNotes + '</textarea>\n'
|
||||
|
||||
optionsStr += ' </form>\n'
|
||||
optionsStr += '</center>\n'
|
||||
optionsStr += '</div>\n'
|
||||
optionsStr += '</div>\n'
|
||||
optionsStr += \
|
||||
' </form>\n' + \
|
||||
'</center>\n' + \
|
||||
'</div>\n' + \
|
||||
'</div>\n'
|
||||
optionsStr += htmlFooter()
|
||||
return optionsStr
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Reference in New Issue