Snake case

merge-requests/30/head
Bob Mottram 2021-12-26 17:15:04 +00:00
parent b71d662d8e
commit 73bd65b8a9
10 changed files with 36 additions and 36 deletions

View File

@ -19,7 +19,7 @@ from utils import followPerson
from utils import acct_dir
from utils import hasGroupType
from utils import local_actor_url
from utils import hasActor
from utils import has_actor
from utils import has_object_stringType
@ -194,7 +194,7 @@ def receiveAcceptReject(session, base_dir: str,
"""
if message_json['type'] != 'Accept' and message_json['type'] != 'Reject':
return False
if not hasActor(message_json, debug):
if not has_actor(message_json, debug):
return False
if not has_users_path(message_json['actor']):
if debug:

View File

@ -24,7 +24,7 @@ from utils import undoAnnounceCollectionEntry
from utils import updateAnnounceCollection
from utils import local_actor_url
from utils import replaceUsersWithAt
from utils import hasActor
from utils import has_actor
from utils import has_object_stringType
from posts import sendSignedJson
from posts import getPersonBox
@ -56,7 +56,7 @@ def outboxAnnounce(recentPostsCache: {},
""" Adds or removes announce entries from the shares collection
within a given post
"""
if not hasActor(message_json, debug):
if not has_actor(message_json, debug):
return False
if not isinstance(message_json['actor'], str):
return False

View File

@ -20,7 +20,7 @@ from utils import load_json
from utils import save_json
from utils import acct_dir
from utils import local_actor_url
from utils import hasActor
from utils import has_actor
def setAvailability(base_dir: str, nickname: str, domain: str,
@ -62,7 +62,7 @@ def outboxAvailability(base_dir: str, nickname: str, message_json: {},
return False
if not message_json['type'] == 'Availability':
return False
if not hasActor(message_json, debug):
if not has_actor(message_json, debug):
return False
if not has_object_string(message_json, debug):
return False

View File

@ -32,7 +32,7 @@ from utils import getDomainFromActor
from utils import getNicknameFromActor
from utils import acct_dir
from utils import local_actor_url
from utils import hasActor
from utils import has_actor
from conversation import muteConversation
from conversation import unmuteConversation
@ -776,7 +776,7 @@ def outboxMute(base_dir: str, http_prefix: str,
"""
if not message_json.get('type'):
return
if not hasActor(message_json, debug):
if not has_actor(message_json, debug):
return
domain_full = get_full_domain(domain, port)
if not message_json['actor'].endswith(domain_full + '/users/' + nickname):
@ -825,7 +825,7 @@ def outboxUndoMute(base_dir: str, http_prefix: str,
"""
if not message_json.get('type'):
return
if not hasActor(message_json, debug):
if not has_actor(message_json, debug):
return
domain_full = get_full_domain(domain, port)
if not message_json['actor'].endswith(domain_full + '/users/' + nickname):

View File

@ -26,7 +26,7 @@ from utils import save_json
from utils import has_object_dict
from utils import acct_dir
from utils import local_actor_url
from utils import hasActor
from utils import has_actor
from utils import has_object_stringType
from posts import getPersonBox
from session import postJson
@ -560,7 +560,7 @@ def outboxBookmark(recentPostsCache: {},
return
if message_json['type'] != 'Add':
return
if not hasActor(message_json, debug):
if not has_actor(message_json, debug):
return
if not message_json.get('target'):
if debug:
@ -616,7 +616,7 @@ def outboxUndoBookmark(recentPostsCache: {},
return
if message_json['type'] != 'Remove':
return
if not hasActor(message_json, debug):
if not has_actor(message_json, debug):
return
if not message_json.get('target'):
if debug:

View File

@ -245,7 +245,7 @@ from like import updateLikesCollection
from reaction import updateReactionCollection
from utils import undoReactionCollectionEntry
from utils import get_new_post_endpoints
from utils import hasActor
from utils import has_actor
from utils import setReplyIntervalHours
from utils import canReplyTo
from utils import isDM
@ -1382,7 +1382,7 @@ class PubServer(BaseHTTPRequestHandler):
# check for blocked domains so that they can be rejected early
messageDomain = None
if not hasActor(message_json, self.server.debug):
if not has_actor(message_json, self.server.debug):
print('Message arriving at inbox queue has no actor')
self._400()
self.server.POSTbusy = False

View File

@ -91,7 +91,7 @@ from utils import undoAnnounceCollectionEntry
from utils import dangerousMarkup
from utils import isDM
from utils import isReply
from utils import hasActor
from utils import has_actor
from httpsig import messageContentDigest
from posts import editedPostFilename
from posts import savePostToBox
@ -422,7 +422,7 @@ def inboxPermittedMessage(domain: str, message_json: {},
federation_list: []) -> bool:
""" check that we are receiving from a permitted domain
"""
if not hasActor(message_json, False):
if not has_actor(message_json, False):
return False
actor = message_json['actor']
@ -805,7 +805,7 @@ def _receiveUndo(session, base_dir: str, http_prefix: str,
return False
if debug:
print('DEBUG: Undo activity received')
if not hasActor(message_json, debug):
if not has_actor(message_json, debug):
return False
if not has_users_path(message_json['actor']):
if debug:
@ -906,7 +906,7 @@ def _receiveUpdateToQuestion(recentPostsCache: {}, message_json: {},
# message url of the question
if not message_json.get('id'):
return
if not hasActor(message_json, False):
if not has_actor(message_json, False):
return
messageId = removeIdEnding(message_json['id'])
if '#' in messageId:
@ -949,7 +949,7 @@ def _receiveUpdate(recentPostsCache: {}, session, base_dir: str,
"""
if message_json['type'] != 'Update':
return False
if not hasActor(message_json, debug):
if not has_actor(message_json, debug):
return False
if not has_object_stringType(message_json, debug):
return False
@ -1013,7 +1013,7 @@ def _receiveLike(recentPostsCache: {},
"""
if message_json['type'] != 'Like':
return False
if not hasActor(message_json, debug):
if not has_actor(message_json, debug):
return False
if not has_object_string(message_json, debug):
return False
@ -1135,7 +1135,7 @@ def _receiveUndoLike(recentPostsCache: {},
"""
if message_json['type'] != 'Undo':
return False
if not hasActor(message_json, debug):
if not has_actor(message_json, debug):
return False
if not has_object_stringType(message_json, debug):
return False
@ -1247,7 +1247,7 @@ def _receiveReaction(recentPostsCache: {},
"""
if message_json['type'] != 'EmojiReact':
return False
if not hasActor(message_json, debug):
if not has_actor(message_json, debug):
return False
if not has_object_string(message_json, debug):
return False
@ -1396,7 +1396,7 @@ def _receiveUndoReaction(recentPostsCache: {},
"""
if message_json['type'] != 'Undo':
return False
if not hasActor(message_json, debug):
if not has_actor(message_json, debug):
return False
if not has_object_stringType(message_json, debug):
return False
@ -1524,7 +1524,7 @@ def _receiveBookmark(recentPostsCache: {},
return False
if message_json['type'] != 'Add':
return False
if not hasActor(message_json, debug):
if not has_actor(message_json, debug):
return False
if not message_json.get('target'):
if debug:
@ -1636,7 +1636,7 @@ def _receiveUndoBookmark(recentPostsCache: {},
return False
if message_json['type'] != 'Remove':
return False
if not hasActor(message_json, debug):
if not has_actor(message_json, debug):
return False
if not message_json.get('target'):
if debug:
@ -1735,7 +1735,7 @@ def _receiveDelete(session, handle: str, isGroup: bool, base_dir: str,
"""
if message_json['type'] != 'Delete':
return False
if not hasActor(message_json, debug):
if not has_actor(message_json, debug):
return False
if debug:
print('DEBUG: Delete activity arrived')
@ -1825,7 +1825,7 @@ def _receiveAnnounce(recentPostsCache: {},
if debug:
print('DEBUG: bad handle ' + handle)
return False
if not hasActor(message_json, debug):
if not has_actor(message_json, debug):
return False
if debug:
print('DEBUG: receiving announce on ' + handle)
@ -2040,7 +2040,7 @@ def _receiveUndoAnnounce(recentPostsCache: {},
"""
if message_json['type'] != 'Undo':
return False
if not hasActor(message_json, debug):
if not has_actor(message_json, debug):
return False
if not has_object_dict(message_json):
return False
@ -3866,7 +3866,7 @@ def _receiveFollowRequest(session, base_dir: str, http_prefix: str,
if not message_json['type'].startswith('Join'):
return False
print('Receiving follow request')
if not hasActor(message_json, debug):
if not has_actor(message_json, debug):
return False
if not has_users_path(message_json['actor']):
if debug:

View File

@ -29,7 +29,7 @@ from utils import load_json
from utils import save_json
from utils import acct_dir
from utils import local_actor_url
from utils import hasActor
from utils import has_actor
from blocking import isBlockedDomain
from blocking import outboxBlock
from blocking import outboxUndoBlock
@ -90,7 +90,7 @@ def _outboxPersonReceiveUpdate(recentPostsCache: {},
if debug:
print('DEBUG: c2s actor update has no "to" field')
return
if not hasActor(message_json, debug):
if not has_actor(message_json, debug):
return
if not message_json.get('id'):
if debug:

View File

@ -21,7 +21,7 @@ from utils import getOccupationSkills
from utils import setOccupationSkillsList
from utils import acct_dir
from utils import local_actor_url
from utils import hasActor
from utils import has_actor
def setSkillsFromDict(actor_json: {}, skillsDict: {}) -> []:
@ -152,7 +152,7 @@ def outboxSkills(base_dir: str, nickname: str, message_json: {},
return False
if not message_json['type'] == 'Skill':
return False
if not hasActor(message_json, debug):
if not has_actor(message_json, debug):
return False
if not has_object_string(message_json, debug):
return False

View File

@ -3151,15 +3151,15 @@ def getSharesFilesList() -> []:
def replaceUsersWithAt(actor: str) -> str:
""" https://domain/users/nick becomes https://domain/@nick
"""
uPaths = get_user_paths()
for path in uPaths:
u_paths = get_user_paths()
for path in u_paths:
if path in actor:
actor = actor.replace(path, '/@')
break
return actor
def hasActor(post_json_object: {}, debug: bool) -> bool:
def has_actor(post_json_object: {}, debug: bool) -> bool:
"""Does the given post have an actor?
"""
if post_json_object.get('actor'):