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 acct_dir
from utils import hasGroupType from utils import hasGroupType
from utils import local_actor_url from utils import local_actor_url
from utils import hasActor from utils import has_actor
from utils import has_object_stringType 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': if message_json['type'] != 'Accept' and message_json['type'] != 'Reject':
return False return False
if not hasActor(message_json, debug): if not has_actor(message_json, debug):
return False return False
if not has_users_path(message_json['actor']): if not has_users_path(message_json['actor']):
if debug: if debug:

View File

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

View File

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

View File

@ -32,7 +32,7 @@ from utils import getDomainFromActor
from utils import getNicknameFromActor from utils import getNicknameFromActor
from utils import acct_dir from utils import acct_dir
from utils import local_actor_url from utils import local_actor_url
from utils import hasActor from utils import has_actor
from conversation import muteConversation from conversation import muteConversation
from conversation import unmuteConversation from conversation import unmuteConversation
@ -776,7 +776,7 @@ def outboxMute(base_dir: str, http_prefix: str,
""" """
if not message_json.get('type'): if not message_json.get('type'):
return return
if not hasActor(message_json, debug): if not has_actor(message_json, debug):
return return
domain_full = get_full_domain(domain, port) domain_full = get_full_domain(domain, port)
if not message_json['actor'].endswith(domain_full + '/users/' + nickname): 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'): if not message_json.get('type'):
return return
if not hasActor(message_json, debug): if not has_actor(message_json, debug):
return return
domain_full = get_full_domain(domain, port) domain_full = get_full_domain(domain, port)
if not message_json['actor'].endswith(domain_full + '/users/' + nickname): 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 has_object_dict
from utils import acct_dir from utils import acct_dir
from utils import local_actor_url from utils import local_actor_url
from utils import hasActor from utils import has_actor
from utils import has_object_stringType from utils import has_object_stringType
from posts import getPersonBox from posts import getPersonBox
from session import postJson from session import postJson
@ -560,7 +560,7 @@ def outboxBookmark(recentPostsCache: {},
return return
if message_json['type'] != 'Add': if message_json['type'] != 'Add':
return return
if not hasActor(message_json, debug): if not has_actor(message_json, debug):
return return
if not message_json.get('target'): if not message_json.get('target'):
if debug: if debug:
@ -616,7 +616,7 @@ def outboxUndoBookmark(recentPostsCache: {},
return return
if message_json['type'] != 'Remove': if message_json['type'] != 'Remove':
return return
if not hasActor(message_json, debug): if not has_actor(message_json, debug):
return return
if not message_json.get('target'): if not message_json.get('target'):
if debug: if debug:

View File

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

View File

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

View File

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

View File

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

View File

@ -3151,15 +3151,15 @@ def getSharesFilesList() -> []:
def replaceUsersWithAt(actor: str) -> str: def replaceUsersWithAt(actor: str) -> str:
""" https://domain/users/nick becomes https://domain/@nick """ https://domain/users/nick becomes https://domain/@nick
""" """
uPaths = get_user_paths() u_paths = get_user_paths()
for path in uPaths: for path in u_paths:
if path in actor: if path in actor:
actor = actor.replace(path, '/@') actor = actor.replace(path, '/@')
break break
return actor 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? """Does the given post have an actor?
""" """
if post_json_object.get('actor'): if post_json_object.get('actor'):