diff --git a/acceptreject.py b/acceptreject.py index 9617901c4..a2b05a5ff 100644 --- a/acceptreject.py +++ b/acceptreject.py @@ -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: diff --git a/announce.py b/announce.py index e093c7cda..8177a8574 100644 --- a/announce.py +++ b/announce.py @@ -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 diff --git a/availability.py b/availability.py index 99295fb54..ed259ff0c 100644 --- a/availability.py +++ b/availability.py @@ -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 diff --git a/blocking.py b/blocking.py index fc109e2c1..b3a9f7d53 100644 --- a/blocking.py +++ b/blocking.py @@ -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): diff --git a/bookmarks.py b/bookmarks.py index 26cb560f6..2e2304a00 100644 --- a/bookmarks.py +++ b/bookmarks.py @@ -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: diff --git a/daemon.py b/daemon.py index 7f79348fa..40e03570e 100644 --- a/daemon.py +++ b/daemon.py @@ -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 diff --git a/inbox.py b/inbox.py index ac83039d0..f3415b571 100644 --- a/inbox.py +++ b/inbox.py @@ -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: diff --git a/outbox.py b/outbox.py index a8a0c7034..b2874a506 100644 --- a/outbox.py +++ b/outbox.py @@ -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: diff --git a/skills.py b/skills.py index 4eb355207..c88a0490e 100644 --- a/skills.py +++ b/skills.py @@ -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 diff --git a/utils.py b/utils.py index 90773aeca..9a142165e 100644 --- a/utils.py +++ b/utils.py @@ -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'):