Snake case

merge-requests/30/head
Bob Mottram 2021-12-26 19:36:40 +00:00
parent 413bd33613
commit 8b6dc582fa
3 changed files with 26 additions and 26 deletions

View File

@ -90,7 +90,7 @@ from utils import updateAnnounceCollection
from utils import undoAnnounceCollectionEntry from utils import undoAnnounceCollectionEntry
from utils import dangerousMarkup from utils import dangerousMarkup
from utils import isDM from utils import isDM
from utils import isReply from utils import is_reply
from utils import has_actor from utils import has_actor
from httpsig import messageContentDigest from httpsig import messageContentDigest
from posts import editedPostFilename from posts import editedPostFilename
@ -3079,13 +3079,13 @@ def _createReplyNotificationFile(base_dir: str, nickname: str, domain: str,
The file can then be used by other systems to create a notification The file can then be used by other systems to create a notification
xmpp, matrix, email, etc xmpp, matrix, email, etc
""" """
isReplyToMutedPost = False is_replyToMutedPost = False
if postIsDM: if postIsDM:
return isReplyToMutedPost return is_replyToMutedPost
if not isReply(post_json_object, actor): if not is_reply(post_json_object, actor):
return isReplyToMutedPost return is_replyToMutedPost
if nickname == 'inbox': if nickname == 'inbox':
return isReplyToMutedPost return is_replyToMutedPost
# replies index will be updated # replies index will be updated
updateIndexList.append('tlreplies') updateIndexList.append('tlreplies')
@ -3094,12 +3094,12 @@ def _createReplyNotificationFile(base_dir: str, nickname: str, domain: str,
conversationId = post_json_object['object']['conversation'] conversationId = post_json_object['object']['conversation']
if not post_json_object['object'].get('inReplyTo'): if not post_json_object['object'].get('inReplyTo'):
return isReplyToMutedPost return is_replyToMutedPost
inReplyTo = post_json_object['object']['inReplyTo'] inReplyTo = post_json_object['object']['inReplyTo']
if not inReplyTo: if not inReplyTo:
return isReplyToMutedPost return is_replyToMutedPost
if not isinstance(inReplyTo, str): if not isinstance(inReplyTo, str):
return isReplyToMutedPost return is_replyToMutedPost
if not isMuted(base_dir, nickname, domain, inReplyTo, conversationId): if not isMuted(base_dir, nickname, domain, inReplyTo, conversationId):
# check if the reply is within the allowed time period # check if the reply is within the allowed time period
# after publication # after publication
@ -3117,8 +3117,8 @@ def _createReplyNotificationFile(base_dir: str, nickname: str, domain: str,
' hours') ' hours')
return False return False
else: else:
isReplyToMutedPost = True is_replyToMutedPost = True
return isReplyToMutedPost return is_replyToMutedPost
def _lowFrequencyPostNotification(base_dir: str, http_prefix: str, def _lowFrequencyPostNotification(base_dir: str, http_prefix: str,
@ -3474,7 +3474,7 @@ def _inboxAfterInitial(recentPostsCache: {}, max_recent_posts: int,
max_like_count, max_like_count,
cw_lists, lists_enabled) cw_lists, lists_enabled)
isReplyToMutedPost = False is_replyToMutedPost = False
if not isGroup: if not isGroup:
# create a DM notification file if needed # create a DM notification file if needed
@ -3498,7 +3498,7 @@ def _inboxAfterInitial(recentPostsCache: {}, max_recent_posts: int,
actor = local_actor_url(http_prefix, nickname, domain_full) actor = local_actor_url(http_prefix, nickname, domain_full)
# create a reply notification file if needed # create a reply notification file if needed
isReplyToMutedPost = \ is_replyToMutedPost = \
_createReplyNotificationFile(base_dir, nickname, domain, _createReplyNotificationFile(base_dir, nickname, domain,
handle, debug, postIsDM, handle, debug, postIsDM,
post_json_object, actor, post_json_object, actor,
@ -3533,7 +3533,7 @@ def _inboxAfterInitial(recentPostsCache: {}, max_recent_posts: int,
# If this is a reply to a muted post then also mute it. # If this is a reply to a muted post then also mute it.
# This enables you to ignore a threat that's getting boring # This enables you to ignore a threat that's getting boring
if isReplyToMutedPost: if is_replyToMutedPost:
print('MUTE REPLY: ' + destinationFilename) print('MUTE REPLY: ' + destinationFilename)
destinationFilenameMuted = destinationFilename + '.muted' destinationFilenameMuted = destinationFilename + '.muted'
try: try:

View File

@ -13,7 +13,7 @@ import random
import urllib.parse import urllib.parse
from utils import removeIdEnding from utils import removeIdEnding
from utils import isDM from utils import isDM
from utils import isReply from utils import is_reply
from utils import camelCaseSplit from utils import camelCaseSplit
from utils import getDomainFromActor from utils import getDomainFromActor
from utils import getNicknameFromActor from utils import getNicknameFromActor
@ -455,7 +455,7 @@ def _postToSpeakerJson(base_dir: str, http_prefix: str,
isDirect = isDM(post_json_object) isDirect = isDM(post_json_object)
actor = local_actor_url(http_prefix, nickname, domain_full) actor = local_actor_url(http_prefix, nickname, domain_full)
replyToYou = isReply(post_json_object, actor) replyToYou = is_reply(post_json_object, actor)
published = '' published = ''
if post_json_object['object'].get('published'): if post_json_object['object'].get('published'):

View File

@ -1506,8 +1506,8 @@ def removeModerationPostFromIndex(base_dir: str, postUrl: str,
' from moderation index') ' from moderation index')
def _isReplyToBlogPost(base_dir: str, nickname: str, domain: str, def _is_reply_to_blog_post(base_dir: str, nickname: str, domain: str,
post_json_object: str): post_json_object: str):
"""Is the given post a reply to a blog post? """Is the given post a reply to a blog post?
""" """
if not has_object_dict(post_json_object): if not has_object_dict(post_json_object):
@ -1516,13 +1516,13 @@ def _isReplyToBlogPost(base_dir: str, nickname: str, domain: str,
return False return False
if not isinstance(post_json_object['object']['inReplyTo'], str): if not isinstance(post_json_object['object']['inReplyTo'], str):
return False return False
blogsIndexFilename = \ blogs_index_filename = \
acct_dir(base_dir, nickname, domain) + '/tlblogs.index' acct_dir(base_dir, nickname, domain) + '/tlblogs.index'
if not os.path.isfile(blogsIndexFilename): if not os.path.isfile(blogs_index_filename):
return False return False
postId = removeIdEnding(post_json_object['object']['inReplyTo']) post_id = removeIdEnding(post_json_object['object']['inReplyTo'])
postId = postId.replace('/', '#') post_id = post_id.replace('/', '#')
if postId in open(blogsIndexFilename).read(): if post_id in open(blogs_index_filename).read():
return True return True
return False return False
@ -1736,8 +1736,8 @@ def deletePost(base_dir: str, http_prefix: str,
return return
# don't remove replies to blog posts # don't remove replies to blog posts
if _isReplyToBlogPost(base_dir, nickname, domain, if _is_reply_to_blog_post(base_dir, nickname, domain,
post_json_object): post_json_object):
return return
# remove from recent posts cache in memory # remove from recent posts cache in memory
@ -2613,7 +2613,7 @@ def isDM(post_json_object: {}) -> bool:
return True return True
def isReply(post_json_object: {}, actor: str) -> bool: def is_reply(post_json_object: {}, actor: str) -> bool:
"""Returns true if the given post is a reply to the given actor """Returns true if the given post is a reply to the given actor
""" """
if post_json_object['type'] != 'Create': if post_json_object['type'] != 'Create':