Snake case

main
Bob Mottram 2021-12-26 10:57:03 +00:00
parent 23af1b48ef
commit 594b3beb55
20 changed files with 102 additions and 102 deletions

View File

@ -15,7 +15,7 @@ from utils import hasObjectString
from utils import hasObjectStringObject
from utils import hasObjectStringType
from utils import removeDomainPort
from utils import hasObjectDict
from utils import has_object_dict
from utils import isAccountDir
from utils import getCachedPostFilename
from utils import loadJson
@ -537,7 +537,7 @@ def mutePost(base_dir: str, nickname: str, domain: str, port: int,
postJsonObj = post_json_object
alsoUpdatePostId = None
if hasObjectDict(post_json_object):
if has_object_dict(post_json_object):
postJsonObj = post_json_object['object']
else:
if hasObjectString(post_json_object, debug):
@ -676,7 +676,7 @@ def unmutePost(base_dir: str, nickname: str, domain: str, port: int,
postJsonObj = post_json_object
alsoUpdatePostId = None
if hasObjectDict(post_json_object):
if has_object_dict(post_json_object):
postJsonObj = post_json_object['object']
else:
if hasObjectString(post_json_object, debug):

View File

@ -23,7 +23,7 @@ from utils import locatePost
from utils import getCachedPostFilename
from utils import loadJson
from utils import saveJson
from utils import hasObjectDict
from utils import has_object_dict
from utils import acctDir
from utils import local_actor_url
from utils import hasActor
@ -87,7 +87,7 @@ def undoBookmarksCollectionEntry(recentPostsCache: {},
return
if post_json_object['type'] != 'Create':
return
if not hasObjectDict(post_json_object):
if not has_object_dict(post_json_object):
if debug:
print('DEBUG: bookmarked post has no object ' +
str(post_json_object))
@ -141,7 +141,7 @@ def bookmarkedByPerson(post_json_object: {},
def _noOfBookmarks(post_json_object: {}) -> int:
"""Returns the number of bookmarks ona given post
"""
if not hasObjectDict(post_json_object):
if not has_object_dict(post_json_object):
return 0
if not post_json_object['object'].get('bookmarks'):
return 0

View File

@ -8,7 +8,7 @@ __status__ = "Production"
__module_group__ = "Timeline"
import os
from utils import hasObjectDict
from utils import has_object_dict
from utils import acctDir
from utils import removeIdEnding
@ -17,7 +17,7 @@ def _getConversationFilename(base_dir: str, nickname: str, domain: str,
post_json_object: {}) -> str:
"""Returns the conversation filename
"""
if not hasObjectDict(post_json_object):
if not has_object_dict(post_json_object):
return None
if not post_json_object['object'].get('conversation'):
return None

View File

@ -258,7 +258,7 @@ from utils import getBaseContentFromPost
from utils import acctDir
from utils import getImageExtensionFromMimeType
from utils import getImageMimeType
from utils import hasObjectDict
from utils import has_object_dict
from utils import userAgentDomain
from utils import isLocalNetworkAddress
from utils import permittedDir
@ -1414,7 +1414,7 @@ class PubServer(BaseHTTPRequestHandler):
self.server.POSTbusy = False
return 3
if hasObjectDict(message_json):
if has_object_dict(message_json):
stringFields = (
'id', 'actor', 'type', 'content', 'published',
'summary', 'url', 'attributedTo'
@ -10018,7 +10018,7 @@ class PubServer(BaseHTTPRequestHandler):
if self._secure_mode():
if not includeCreateWrapper and \
post_json_object['type'] == 'Create' and \
hasObjectDict(post_json_object):
has_object_dict(post_json_object):
unwrappedJson = post_json_object['object']
unwrappedJson['@context'] = \
getIndividualPostContext()

View File

@ -17,7 +17,7 @@ import urllib.parse
from pathlib import Path
from random import randint
from utils import getBaseContentFromPost
from utils import hasObjectDict
from utils import has_object_dict
from utils import getFullDomain
from utils import isDM
from utils import loadTranslationsFromFile
@ -210,7 +210,7 @@ def _postIsToYou(actor: str, post_json_object: {}) -> bool:
if not toYourActor and post_json_object.get('cc'):
if actor in post_json_object['cc']:
toYourActor = True
if not toYourActor and hasObjectDict(post_json_object):
if not toYourActor and has_object_dict(post_json_object):
if post_json_object['object'].get('to'):
if actor in post_json_object['object']['to']:
toYourActor = True
@ -621,7 +621,7 @@ def _getImageDescription(post_json_object: {}) -> str:
def _showLikesOnPost(post_json_object: {}, maxLikes: int) -> None:
"""Shows the likes on a post
"""
if not hasObjectDict(post_json_object):
if not has_object_dict(post_json_object):
return
if not post_json_object['object'].get('likes'):
return
@ -644,7 +644,7 @@ def _showLikesOnPost(post_json_object: {}, maxLikes: int) -> None:
def _showRepliesOnPost(post_json_object: {}, max_replies: int) -> None:
"""Shows the replies on a post
"""
if not hasObjectDict(post_json_object):
if not has_object_dict(post_json_object):
return
if not post_json_object['object'].get('replies'):
return
@ -715,7 +715,7 @@ def _readLocalBoxPost(session, nickname: str, domain: str,
signing_priv_key_pem,
blockedCache)
if post_json_object2:
if hasObjectDict(post_json_object2):
if has_object_dict(post_json_object2):
if post_json_object2['object'].get('attributedTo') and \
post_json_object2['object'].get('content'):
attributedTo = post_json_object2['object']['attributedTo']
@ -916,7 +916,7 @@ def _desktopGetBoxPostObject(boxJson: {}, index: int) -> {}:
if ctr == index:
return post_json_object
continue
if not hasObjectDict(post_json_object):
if not has_object_dict(post_json_object):
continue
if not post_json_object['object'].get('published'):
continue
@ -1028,7 +1028,7 @@ def _desktopShowBox(indent: str,
ctr += 1
continue
if not hasObjectDict(post_json_object):
if not has_object_dict(post_json_object):
continue
if not post_json_object['object'].get('published'):
continue
@ -1973,7 +1973,7 @@ def runDesktopClient(base_dir: str, proxy_type: str, http_prefix: str,
if post_json_object:
if post_json_object.get('id') and \
post_json_object.get('object'):
if hasObjectDict(post_json_object):
if has_object_dict(post_json_object):
if post_json_object['object'].get('attributedTo'):
blockActor = \
post_json_object['object']['attributedTo']
@ -2019,7 +2019,7 @@ def runDesktopClient(base_dir: str, proxy_type: str, http_prefix: str,
if post_json_object and not blockActor:
if post_json_object.get('id') and \
post_json_object.get('object'):
if hasObjectDict(post_json_object):
if has_object_dict(post_json_object):
if post_json_object['object'].get('attributedTo'):
blockActor = \
post_json_object['object']['attributedTo']

View File

@ -16,7 +16,7 @@ from utils import isPublicPost
from utils import loadJson
from utils import saveJson
from utils import locatePost
from utils import hasObjectDict
from utils import has_object_dict
from utils import acctDir
@ -166,7 +166,7 @@ def _isHappeningPost(post_json_object: {}) -> bool:
"""
if not post_json_object:
return False
if not hasObjectDict(post_json_object):
if not has_object_dict(post_json_object):
return False
if not post_json_object['object'].get('tag'):
return False

View File

@ -32,7 +32,7 @@ from utils import getBaseContentFromPost
from utils import acctDir
from utils import removeDomainPort
from utils import getPortFromDomain
from utils import hasObjectDict
from utils import has_object_dict
from utils import dmAllowedFromDomain
from utils import isRecentPost
from utils import getConfigParam
@ -133,7 +133,7 @@ def _storeLastPostId(base_dir: str, nickname: str, domain: str,
source but we don't live in that ideal world.
"""
actor = postId = None
if hasObjectDict(post_json_object):
if has_object_dict(post_json_object):
if post_json_object['object'].get('attributedTo'):
if isinstance(post_json_object['object']['attributedTo'], str):
actor = post_json_object['object']['attributedTo']
@ -207,7 +207,7 @@ def storeHashTags(base_dir: str, nickname: str, domain: str,
"""
if not isPublicPost(post_json_object):
return
if not hasObjectDict(post_json_object):
if not has_object_dict(post_json_object):
return
if not post_json_object['object'].get('tag'):
return
@ -402,7 +402,7 @@ def inboxMessageHasParams(message_json: {}) -> bool:
return False
# object should be a dict or a string
if not hasObjectDict(message_json):
if not has_object_dict(message_json):
if not isinstance(message_json['object'], str):
print('WARN: object from ' + str(message_json['actor']) +
' should be a dict or string, but is actually: ' +
@ -437,7 +437,7 @@ def inboxPermittedMessage(domain: str, message_json: {},
'Follow', 'Join', 'Like', 'EmojiReact', 'Delete', 'Announce'
)
if message_json['type'] not in alwaysAllowedTypes:
if not hasObjectDict(message_json):
if not has_object_dict(message_json):
return True
if message_json['object'].get('inReplyTo'):
inReplyTo = message_json['object']['inReplyTo']
@ -493,7 +493,7 @@ def savePostToInboxQueue(base_dir: str, http_prefix: str,
return None
postDomain = getFullDomain(postDomain, postPort)
if hasObjectDict(post_json_object):
if has_object_dict(post_json_object):
if post_json_object['object'].get('inReplyTo'):
if isinstance(post_json_object['object']['inReplyTo'], str):
inReplyTo = \
@ -653,7 +653,7 @@ def _inboxPostRecipients(base_dir: str, post_json_object: {},
# first get any specific people which the post is addressed to
followerRecipients = False
if hasObjectDict(post_json_object):
if has_object_dict(post_json_object):
if post_json_object['object'].get('to'):
if isinstance(post_json_object['object']['to'], list):
recipientsList = post_json_object['object']['to']
@ -1978,7 +1978,7 @@ def _receiveAnnounce(recentPostsCache: {},
if isinstance(post_json_object['attributedTo'], str):
lookupActor = post_json_object['attributedTo']
else:
if hasObjectDict(post_json_object):
if has_object_dict(post_json_object):
if post_json_object['object'].get('attributedTo'):
attrib = post_json_object['object']['attributedTo']
if isinstance(attrib, str):
@ -2042,7 +2042,7 @@ def _receiveUndoAnnounce(recentPostsCache: {},
return False
if not hasActor(message_json, debug):
return False
if not hasObjectDict(message_json):
if not has_object_dict(message_json):
return False
if not hasObjectStringObject(message_json, debug):
return False
@ -2095,7 +2095,7 @@ def jsonPostAllowsComments(post_json_object: {}) -> bool:
if 'rejectReplies' in post_json_object:
return not post_json_object['rejectReplies']
if post_json_object.get('object'):
if not hasObjectDict(post_json_object):
if not has_object_dict(post_json_object):
return False
elif 'commentsEnabled' in post_json_object['object']:
return post_json_object['object']['commentsEnabled']
@ -2120,7 +2120,7 @@ def populateReplies(base_dir: str, http_prefix: str, domain: str,
"""
if not message_json.get('id'):
return False
if not hasObjectDict(message_json):
if not has_object_dict(message_json):
return False
if not message_json['object'].get('inReplyTo'):
return False
@ -2206,7 +2206,7 @@ def _validPostContent(base_dir: str, nickname: str, domain: str,
Check if it's a git patch
Check number of tags and mentions is reasonable
"""
if not hasObjectDict(message_json):
if not has_object_dict(message_json):
return True
if not message_json['object'].get('content'):
return True
@ -2305,7 +2305,7 @@ def _obtainAvatarForReplyPost(session, base_dir: str, http_prefix: str,
"""Tries to obtain the actor for the person being replied to
so that their avatar can later be shown
"""
if not hasObjectDict(post_json_object):
if not has_object_dict(post_json_object):
return
if not post_json_object['object'].get('inReplyTo'):
@ -2370,7 +2370,7 @@ def _alreadyLiked(base_dir: str, nickname: str, domain: str,
post_json_object = loadJson(postFilename, 1)
if not post_json_object:
return False
if not hasObjectDict(post_json_object):
if not has_object_dict(post_json_object):
return False
if not post_json_object['object'].get('likes'):
return False
@ -2400,7 +2400,7 @@ def _alreadyReacted(base_dir: str, nickname: str, domain: str,
post_json_object = loadJson(postFilename, 1)
if not post_json_object:
return False
if not hasObjectDict(post_json_object):
if not has_object_dict(post_json_object):
return False
if not post_json_object['object'].get('reactions'):
return False
@ -2646,7 +2646,7 @@ def _sendToGroupMembers(session, base_dir: str, handle: str, port: int,
return
if not post_json_object.get('object'):
return
if not hasObjectDict(post_json_object):
if not has_object_dict(post_json_object):
return
nickname = handle.split('@')[0].replace('!', '')
domain = handle.split('@')[1]
@ -2693,7 +2693,7 @@ def _inboxUpdateCalendar(base_dir: str, handle: str,
"""
if not post_json_object.get('actor'):
return
if not hasObjectDict(post_json_object):
if not has_object_dict(post_json_object):
return
if not post_json_object['object'].get('tag'):
return

View File

@ -12,7 +12,7 @@ import json
from urllib import request, parse
from utils import get_actor_languages_list
from utils import removeHtml
from utils import hasObjectDict
from utils import has_object_dict
from utils import getConfigParam
from utils import local_actor_url
from cache import getPersonFromCache
@ -98,7 +98,7 @@ def understoodPostLanguage(base_dir: str, nickname: str, domain: str,
understood by this account
"""
msgObject = message_json
if hasObjectDict(message_json):
if has_object_dict(message_json):
msgObject = message_json['object']
if not msgObject.get('contentMap'):
return True
@ -278,7 +278,7 @@ def autoTranslatePost(base_dir: str, post_json_object: {},
system_language: str, translate: {}) -> str:
"""Tries to automatically translate the given post
"""
if not hasObjectDict(post_json_object):
if not has_object_dict(post_json_object):
return ''
msgObject = post_json_object['object']
if not msgObject.get('contentMap'):

View File

@ -13,7 +13,7 @@ from utils import hasObjectString
from utils import hasObjectStringObject
from utils import hasObjectStringType
from utils import removeDomainPort
from utils import hasObjectDict
from utils import has_object_dict
from utils import hasUsersPath
from utils import getFullDomain
from utils import removeIdEnding
@ -39,7 +39,7 @@ def noOfLikes(post_json_object: {}) -> int:
"""Returns the number of likes ona given post
"""
obj = post_json_object
if hasObjectDict(post_json_object):
if has_object_dict(post_json_object):
obj = post_json_object['object']
if not obj.get('likes'):
return 0
@ -59,7 +59,7 @@ def likedByPerson(post_json_object: {}, nickname: str, domain: str) -> bool:
actorMatch = domain + '/users/' + nickname
obj = post_json_object
if hasObjectDict(post_json_object):
if has_object_dict(post_json_object):
obj = post_json_object['object']
for item in obj['likes']['items']:
@ -436,7 +436,7 @@ def updateLikesCollection(recentPostsCache: {},
cachedPostFilename)
obj = post_json_object
if hasObjectDict(post_json_object):
if has_object_dict(post_json_object):
obj = post_json_object['object']
if not objectUrl.endswith('/likes'):

View File

@ -21,7 +21,7 @@ from utils import getImageExtensions
from utils import getVideoExtensions
from utils import getAudioExtensions
from utils import getMediaExtensions
from utils import hasObjectDict
from utils import has_object_dict
from utils import acctDir
from shutil import copyfile
from shutil import rmtree
@ -59,7 +59,7 @@ def _replaceSiloDomain(post_json_object: {},
"""
if not replacementDomain:
return
if not hasObjectDict(post_json_object):
if not has_object_dict(post_json_object):
return
if not post_json_object['object'].get('content'):
return

View File

@ -21,7 +21,7 @@ from categories import setHashtagCategory
from utils import dangerousSVG
from utils import getFavFilenameFromUrl
from utils import getBaseContentFromPost
from utils import hasObjectDict
from utils import has_object_dict
from utils import firstParagraphFromString
from utils import isPublicPost
from utils import locatePost
@ -970,7 +970,7 @@ def _isNewswireBlogPost(post_json_object: {}) -> bool:
"""
if not post_json_object:
return False
if not hasObjectDict(post_json_object):
if not has_object_dict(post_json_object):
return False
if post_json_object['object'].get('summary') and \
post_json_object['object'].get('url') and \
@ -983,7 +983,7 @@ def _isNewswireBlogPost(post_json_object: {}) -> bool:
def _getHashtagsFromPost(post_json_object: {}) -> []:
"""Returns a list of any hashtags within a post
"""
if not hasObjectDict(post_json_object):
if not has_object_dict(post_json_object):
return []
if not post_json_object['object'].get('tag'):
return []

View File

@ -18,7 +18,7 @@ from posts import sendToFollowersThread
from posts import sendToNamedAddressesThread
from utils import hasObjectStringType
from utils import getBaseContentFromPost
from utils import hasObjectDict
from utils import has_object_dict
from utils import getLocalNetworkAddresses
from utils import getFullDomain
from utils import removeIdEnding
@ -222,7 +222,7 @@ def postMessageToOutbox(session, translate: {},
# check that the outgoing post doesn't contain any markup
# which can be used to implement exploits
if hasObjectDict(message_json):
if has_object_dict(message_json):
contentStr = getBaseContentFromPost(message_json, system_language)
if contentStr:
if dangerousMarkup(contentStr, allow_local_network_access):
@ -365,7 +365,7 @@ def postMessageToOutbox(session, translate: {},
# if this is a blog post or an event then save to its own box
if message_json['type'] == 'Create':
if hasObjectDict(message_json):
if has_object_dict(message_json):
if message_json['object'].get('type'):
if message_json['object']['type'] == 'Article':
outboxName = 'tlblogs'

View File

@ -41,7 +41,7 @@ from utils import hasGroupType
from utils import getBaseContentFromPost
from utils import removeDomainPort
from utils import getPortFromDomain
from utils import hasObjectDict
from utils import has_object_dict
from utils import rejectPostId
from utils import removeInvalidChars
from utils import fileLastModified
@ -782,7 +782,7 @@ def getPostDomains(session, outboxUrl: str, maxPosts: int,
i += 1
if i > maxPosts:
break
if not hasObjectDict(item):
if not has_object_dict(item):
continue
contentStr = getBaseContentFromPost(item, system_language)
if contentStr:
@ -847,7 +847,7 @@ def _getPostsForBlockedDomains(base_dir: str,
i += 1
if i > maxPosts:
break
if not hasObjectDict(item):
if not has_object_dict(item):
continue
if item['object'].get('inReplyTo'):
if isinstance(item['object']['inReplyTo'], str):
@ -924,7 +924,7 @@ def savePostToBox(base_dir: str, http_prefix: str, postId: str,
local_actor_url(http_prefix, nickname, originalDomain) + \
'/statuses/' + statusNumber
post_json_object['id'] = postId + '/activity'
if hasObjectDict(post_json_object):
if has_object_dict(post_json_object):
post_json_object['object']['id'] = postId
post_json_object['object']['atomUri'] = postId
@ -1611,7 +1611,7 @@ def _postIsAddressedToFollowers(base_dir: str,
toList = []
ccList = []
if post_json_object['type'] != 'Update' and \
hasObjectDict(post_json_object):
has_object_dict(post_json_object):
if post_json_object['object'].get('to'):
toList = post_json_object['object']['to']
if post_json_object['object'].get('cc'):
@ -2595,7 +2595,7 @@ def _addFollowersToPublicPost(post_json_object: {}) -> None:
if post_json_object.get('cc'):
return
post_json_object['cc'] = post_json_object['actor'] + '/followers'
elif hasObjectDict(post_json_object):
elif has_object_dict(post_json_object):
if not post_json_object['object'].get('to'):
return
if len(post_json_object['object']['to']) > 1:
@ -2808,7 +2808,7 @@ def addToField(activityType: str, post_json_object: {},
toAddress = toAddress.split('/statuses/')[0]
post_json_object['to'] = [toAddress]
toFieldAdded = True
elif hasObjectDict(post_json_object):
elif has_object_dict(post_json_object):
# add a to field to bookmark add or remove
if post_json_object.get('type') and \
post_json_object.get('actor') and \
@ -2879,7 +2879,7 @@ def _sendToNamedAddresses(session, base_dir: str,
if not post_json_object.get('object'):
return
isProfileUpdate = False
if hasObjectDict(post_json_object):
if has_object_dict(post_json_object):
if _isProfileUpdate(post_json_object):
# use the original object, which has a 'to'
recipientsObject = post_json_object
@ -3486,7 +3486,7 @@ def isImageMedia(session, base_dir: str, http_prefix: str,
post_json_object = postJsonAnnounce
if post_json_object['type'] != 'Create':
return False
if not hasObjectDict(post_json_object):
if not has_object_dict(post_json_object):
return False
if post_json_object['object'].get('moderationStatus'):
return False
@ -3572,7 +3572,7 @@ def removePostInteractions(post_json_object: {}, force: bool) -> bool:
Returns False if this is a private post
"""
hasObject = False
if hasObjectDict(post_json_object):
if has_object_dict(post_json_object):
hasObject = True
if hasObject:
postObj = post_json_object['object']
@ -5188,7 +5188,7 @@ def editedPostFilename(base_dir: str, nickname: str, domain: str,
maxTimeDiffSeconds: int) -> str:
"""Returns the filename of the edited post
"""
if not hasObjectDict(post_json_object):
if not has_object_dict(post_json_object):
return ''
if not post_json_object.get('type'):
return ''
@ -5289,7 +5289,7 @@ def getOriginalPostFromAnnounceUrl(announceUrl: str, base_dir: str,
# we have the original post
origPostJson = loadJson(origFilename, 0, 1)
if origPostJson:
if hasObjectDict(origPostJson):
if has_object_dict(origPostJson):
if origPostJson['object'].get('attributedTo'):
if isinstance(origPostJson['object']['attributedTo'], str):
actor = origPostJson['object']['attributedTo']

View File

@ -11,7 +11,7 @@ import os
from utils import locatePost
from utils import loadJson
from utils import saveJson
from utils import hasObjectDict
from utils import has_object_dict
def questionUpdateVotes(base_dir: str, nickname: str, domain: str,
@ -19,7 +19,7 @@ def questionUpdateVotes(base_dir: str, nickname: str, domain: str,
""" For a given reply update the votes on a question
Returns the question json object if the vote totals were changed
"""
if not hasObjectDict(replyJson):
if not has_object_dict(replyJson):
return None, None
if not replyJson['object'].get('inReplyTo'):
return None, None
@ -36,7 +36,7 @@ def questionUpdateVotes(base_dir: str, nickname: str, domain: str,
questionJson = loadJson(questionPostFilename)
if not questionJson:
return None, None
if not hasObjectDict(questionJson):
if not has_object_dict(questionJson):
return None, None
if not questionJson['object'].get('type'):
return None, None
@ -126,7 +126,7 @@ def isQuestion(postObjectJson: {}) -> bool:
if postObjectJson['type'] != 'Create' and \
postObjectJson['type'] != 'Update':
return False
if not hasObjectDict(postObjectJson):
if not has_object_dict(postObjectJson):
return False
if not postObjectJson['object'].get('type'):
return False

View File

@ -15,7 +15,7 @@ from utils import hasObjectString
from utils import hasObjectStringObject
from utils import hasObjectStringType
from utils import removeDomainPort
from utils import hasObjectDict
from utils import has_object_dict
from utils import hasUsersPath
from utils import getFullDomain
from utils import removeIdEnding
@ -466,7 +466,7 @@ def updateReactionCollection(recentPostsCache: {},
cachedPostFilename)
obj = post_json_object
if hasObjectDict(post_json_object):
if has_object_dict(post_json_object):
obj = post_json_object['object']
if not objectUrl.endswith('/reactions'):
@ -519,7 +519,7 @@ def htmlEmojiReactions(post_json_object: {}, interactive: bool,
"""html containing row of emoji reactions
displayed at the bottom of posts, above the icons
"""
if not hasObjectDict(post_json_object):
if not has_object_dict(post_json_object):
return ''
if not post_json_object.get('actor'):
return ''

View File

@ -10,7 +10,7 @@ __module_group__ = "Calendar"
import os
import time
import datetime
from utils import hasObjectDict
from utils import has_object_dict
from utils import getStatusNumber
from utils import loadJson
from utils import isAccountDir
@ -85,7 +85,7 @@ def _updatePostSchedule(base_dir: str, handle: str, httpd,
statusNumber, published = getStatusNumber()
if post_json_object.get('published'):
post_json_object['published'] = published
if hasObjectDict(post_json_object):
if has_object_dict(post_json_object):
if post_json_object['object'].get('published'):
post_json_object['published'] = published

View File

@ -23,7 +23,7 @@ from utils import removeHtml
from utils import loadJson
from utils import saveJson
from utils import isPGPEncrypted
from utils import hasObjectDict
from utils import has_object_dict
from utils import acctDir
from utils import local_actor_url
from content import htmlReplaceQuoteMarks
@ -412,7 +412,7 @@ def _postToSpeakerJson(base_dir: str, http_prefix: str,
NOTE: There currently appears to be no standardized json
format for speech synthesis
"""
if not hasObjectDict(post_json_object):
if not has_object_dict(post_json_object):
return
if not post_json_object['object'].get('content'):
return

View File

@ -83,7 +83,7 @@ def get_content_from_post(post_json_object: {}, system_language: str,
including searching for a matching entry within contentMap
"""
this_post_json = post_json_object
if hasObjectDict(post_json_object):
if has_object_dict(post_json_object):
this_post_json = post_json_object['object']
if not this_post_json.get('content'):
return ''
@ -110,7 +110,7 @@ def getBaseContentFromPost(post_json_object: {}, system_language: str) -> str:
"""Returns the content from the post in the given language
"""
this_post_json = post_json_object
if hasObjectDict(post_json_object):
if has_object_dict(post_json_object):
this_post_json = post_json_object['object']
if not this_post_json.get('content'):
return ''
@ -1366,7 +1366,7 @@ def _getPublishedDate(post_json_object: {}) -> str:
published = None
if post_json_object.get('published'):
published = post_json_object['published']
elif hasObjectDict(post_json_object):
elif has_object_dict(post_json_object):
if post_json_object['object'].get('published'):
published = post_json_object['object']['published']
if not published:
@ -1506,7 +1506,7 @@ def _isReplyToBlogPost(base_dir: str, nickname: str, domain: str,
post_json_object: str):
"""Is the given post a reply to a blog post?
"""
if not hasObjectDict(post_json_object):
if not has_object_dict(post_json_object):
return False
if not post_json_object['object'].get('inReplyTo'):
return False
@ -1614,7 +1614,7 @@ def _deleteHashtagsOnPost(base_dir: str, post_json_object: {}) -> None:
"""Removes hashtags when a post is deleted
"""
removeHashtagIndex = False
if hasObjectDict(post_json_object):
if has_object_dict(post_json_object):
if post_json_object['object'].get('content'):
if '#' in post_json_object['object']['content']:
removeHashtagIndex = True
@ -1668,7 +1668,7 @@ def _deleteConversationPost(base_dir: str, nickname: str, domain: str,
post_json_object: {}) -> None:
"""Deletes a post from a conversation
"""
if not hasObjectDict(post_json_object):
if not has_object_dict(post_json_object):
return False
if not post_json_object['object'].get('conversation'):
return False
@ -1763,7 +1763,7 @@ def deletePost(base_dir: str, http_prefix: str,
# remove from moderation index file
if hasObject:
if hasObjectDict(post_json_object):
if has_object_dict(post_json_object):
if post_json_object['object'].get('moderationStatus'):
if post_json_object.get('id'):
postId = removeIdEnding(post_json_object['id'])
@ -1957,7 +1957,7 @@ def isPublicPost(post_json_object: {}) -> bool:
return False
if post_json_object['type'] != 'Create':
return False
if not hasObjectDict(post_json_object):
if not has_object_dict(post_json_object):
return False
if not post_json_object['object'].get('to'):
return False
@ -2077,7 +2077,7 @@ def isBlogPost(post_json_object: {}) -> bool:
"""
if post_json_object['type'] != 'Create':
return False
if not hasObjectDict(post_json_object):
if not has_object_dict(post_json_object):
return False
if not hasObjectStringType(post_json_object, False):
return False
@ -2232,7 +2232,7 @@ def undoLikesCollectionEntry(recentPostsCache: {},
if post_json_object['type'] != 'Create':
return
obj = post_json_object
if hasObjectDict(post_json_object):
if has_object_dict(post_json_object):
obj = post_json_object['object']
if not obj.get('likes'):
return
@ -2297,7 +2297,7 @@ def undoReactionCollectionEntry(recentPostsCache: {},
if post_json_object['type'] != 'Create':
return
obj = post_json_object
if hasObjectDict(post_json_object):
if has_object_dict(post_json_object):
obj = post_json_object['object']
if not obj.get('reactions'):
return
@ -2362,7 +2362,7 @@ def undoAnnounceCollectionEntry(recentPostsCache: {},
return
if post_json_object['type'] != 'Create':
return
if not hasObjectDict(post_json_object):
if not has_object_dict(post_json_object):
if debug:
pprint(post_json_object)
print('DEBUG: post has no object')
@ -2425,7 +2425,7 @@ def updateAnnounceCollection(recentPostsCache: {},
str(cachedPostFilename))
removePostFromCache(post_json_object, recentPostsCache)
if not hasObjectDict(post_json_object):
if not has_object_dict(post_json_object):
if debug:
pprint(post_json_object)
print('DEBUG: post ' + postFilename + ' has no object')
@ -2509,7 +2509,7 @@ def mediaFileMimeType(filename: str) -> str:
def isRecentPost(post_json_object: {}, maxDays: int) -> bool:
""" Is the given post recent?
"""
if not hasObjectDict(post_json_object):
if not has_object_dict(post_json_object):
return False
if not post_json_object['object'].get('published'):
return False
@ -2586,7 +2586,7 @@ def isDM(post_json_object: {}) -> bool:
"""
if post_json_object['type'] != 'Create':
return False
if not hasObjectDict(post_json_object):
if not has_object_dict(post_json_object):
return False
if post_json_object['object']['type'] != 'Note' and \
post_json_object['object']['type'] != 'Page' and \
@ -2613,7 +2613,7 @@ def isReply(post_json_object: {}, actor: str) -> bool:
"""
if post_json_object['type'] != 'Create':
return False
if not hasObjectDict(post_json_object):
if not has_object_dict(post_json_object):
return False
if post_json_object['object'].get('moderationStatus'):
return False
@ -2845,7 +2845,7 @@ def userAgentDomain(userAgent: str, debug: bool) -> str:
return agentDomain
def hasObjectDict(post_json_object: {}) -> bool:
def has_object_dict(post_json_object: {}) -> bool:
"""Returns true if the given post has an object dict
"""
if post_json_object.get('object'):
@ -3173,7 +3173,7 @@ def hasActor(post_json_object: {}, debug: bool) -> bool:
def hasObjectStringType(post_json_object: {}, debug: bool) -> bool:
"""Does the given post have a type field within an object dict?
"""
if not hasObjectDict(post_json_object):
if not has_object_dict(post_json_object):
if debug:
print('hasObjectStringType no object found')
return False
@ -3192,7 +3192,7 @@ def hasObjectStringType(post_json_object: {}, debug: bool) -> bool:
def hasObjectStringObject(post_json_object: {}, debug: bool) -> bool:
"""Does the given post have an object string field within an object dict?
"""
if not hasObjectDict(post_json_object):
if not has_object_dict(post_json_object):
if debug:
print('hasObjectStringType no object found')
return False

View File

@ -28,7 +28,7 @@ from utils import removeHtml
from utils import get_actor_languages_list
from utils import getBaseContentFromPost
from utils import get_content_from_post
from utils import hasObjectDict
from utils import has_object_dict
from utils import updateAnnounceCollection
from utils import isPGPEncrypted
from utils import isDM
@ -93,7 +93,7 @@ def _htmlPostMetadataOpenGraph(domain: str, post_json_object: {}) -> str:
metadata += \
" <meta content=\"article\" property=\"og:type\" />\n"
objJson = post_json_object
if hasObjectDict(post_json_object):
if has_object_dict(post_json_object):
objJson = post_json_object['object']
if objJson.get('attributedTo'):
if isinstance(objJson['attributedTo'], str):
@ -1559,7 +1559,7 @@ def individualPostAsHtml(signing_priv_key_pem: str,
_logPostTiming(enableTimingLog, postStartTime, '8')
if not hasObjectDict(post_json_object):
if not has_object_dict(post_json_object):
return ''
# if this post should be public then check its recipients
@ -2076,7 +2076,7 @@ def htmlIndividualPost(cssCache: {},
messageId = removeIdEnding(post_json_object['id'])
# show the previous posts
if hasObjectDict(post_json_object):
if has_object_dict(post_json_object):
while post_json_object['object'].get('inReplyTo'):
postFilename = \
locatePost(base_dir, nickname, domain,

View File

@ -12,7 +12,7 @@ from pprint import pprint
from webfinger import webfingerHandle
from utils import getDisplayName
from utils import isGroupAccount
from utils import hasObjectDict
from utils import has_object_dict
from utils import getOccupationName
from utils import getLockedAccount
from utils import getFullDomain
@ -88,7 +88,7 @@ def _validProfilePreviewPost(post_json_object: {},
if not post_json_object.get('type'):
return False, None
if post_json_object['type'] == 'Create':
if not hasObjectDict(post_json_object):
if not has_object_dict(post_json_object):
return False, None
if post_json_object['type'] != 'Create' and \
post_json_object['type'] != 'Announce':