From 821af94f5929003e4c24d8ee3d80d5d464ba5b32 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Sun, 26 Dec 2021 17:53:07 +0000 Subject: [PATCH] Snake case --- acceptreject.py | 4 ++-- announce.py | 4 ++-- daemon.py | 8 ++++---- follow.py | 10 +++++----- inbox.py | 10 +++++----- like.py | 6 +++--- migrate.py | 4 ++-- person.py | 4 ++-- posts.py | 4 ++-- reaction.py | 6 +++--- utils.py | 14 +++++++------- webfinger.py | 4 ++-- 12 files changed, 39 insertions(+), 39 deletions(-) diff --git a/acceptreject.py b/acceptreject.py index a2b05a5ff..3ac42cc3b 100644 --- a/acceptreject.py +++ b/acceptreject.py @@ -17,7 +17,7 @@ from utils import getNicknameFromActor from utils import domainPermitted from utils import followPerson from utils import acct_dir -from utils import hasGroupType +from utils import has_group_type from utils import local_actor_url from utils import has_actor from utils import has_object_stringType @@ -163,7 +163,7 @@ def _accept_follow(base_dir: str, domain: str, message_json: {}, return # does the url path indicate that this is a group actor - group_account = hasGroupType(base_dir, followed_actor, None, debug) + group_account = has_group_type(base_dir, followed_actor, None, debug) if debug: print('Accepted follow is a group: ' + str(group_account) + ' ' + followed_actor + ' ' + base_dir) diff --git a/announce.py b/announce.py index 99af2a4df..71f1dae7b 100644 --- a/announce.py +++ b/announce.py @@ -8,7 +8,7 @@ __status__ = "Production" __module_group__ = "ActivityPub" from utils import has_object_string_object -from utils import hasGroupType +from utils import has_group_type from utils import removeDomainPort from utils import removeIdEnding from utils import has_users_path @@ -171,7 +171,7 @@ def createAnnounce(session, base_dir: str, federation_list: [], announceActor = \ objectUrl.split('/' + announceNickname + '/')[0] + \ '/' + announceNickname - if hasGroupType(base_dir, announceActor, person_cache): + if has_group_type(base_dir, announceActor, person_cache): group_account = True if announceNickname and announceDomain: diff --git a/daemon.py b/daemon.py index 7da5221b2..0144ee2d5 100644 --- a/daemon.py +++ b/daemon.py @@ -303,7 +303,7 @@ from utils import isSuspended from utils import dangerousMarkup from utils import refresh_newswire from utils import isImageFile -from utils import hasGroupType +from utils import has_group_type from manualapprove import manualDenyFollowRequestThread from manualapprove import manualApproveFollowRequestThread from announce import createAnnounce @@ -2957,9 +2957,9 @@ class PubServer(BaseHTTPRequestHandler): } pathUsersSection = path.split('/users/')[1] self.postToNickname = pathUsersSection.split('/')[0] - group_account = hasGroupType(self.server.base_dir, - followingActor, - self.server.person_cache) + group_account = has_group_type(self.server.base_dir, + followingActor, + self.server.person_cache) unfollowAccount(self.server.base_dir, self.postToNickname, self.server.domain, followingNickname, followingDomainFull, diff --git a/follow.py b/follow.py index e8084ca2c..4d8478e52 100644 --- a/follow.py +++ b/follow.py @@ -28,7 +28,7 @@ from utils import save_json from utils import isAccountDir from utils import get_user_paths from utils import acct_dir -from utils import hasGroupType +from utils import has_group_type from utils import local_actor_url from acceptreject import createAccept from acceptreject import createReject @@ -763,7 +763,7 @@ def followedAccountAccepts(session, base_dir: str, http_prefix: str, group_account = False if followJson: if followJson.get('actor'): - if hasGroupType(base_dir, followJson['actor'], person_cache): + if has_group_type(base_dir, followJson['actor'], person_cache): group_account = True return sendSignedJson(acceptJson, session, base_dir, @@ -822,7 +822,7 @@ def followedAccountRejects(session, base_dir: str, http_prefix: str, client_to_server = False denyHandle = get_full_domain(nickname + '@' + domain, fromPort) group_account = False - if hasGroupType(base_dir, personUrl, person_cache): + if has_group_type(base_dir, personUrl, person_cache): group_account = True # remove from the follow requests file removeFromFollowRequests(base_dir, nicknameToFollow, domainToFollow, @@ -874,7 +874,7 @@ def sendFollowRequest(session, base_dir: str, if followNickname: followedId = followedActor followHandle = followNickname + '@' + requestDomain - group_account = hasGroupType(base_dir, followedActor, person_cache) + group_account = has_group_type(base_dir, followedActor, person_cache) if group_account: followHandle = '!' + followHandle print('Follow request being sent to group account') @@ -1416,7 +1416,7 @@ def outboxUndoFollow(base_dir: str, message_json: {}, debug: bool) -> None: domainFollowingFull = get_full_domain(domainFollowing, portFollowing) group_account = \ - hasGroupType(base_dir, message_json['object']['object'], None) + has_group_type(base_dir, message_json['object']['object'], None) if unfollowAccount(base_dir, nicknameFollower, domainFollowerFull, nicknameFollowing, domainFollowingFull, debug, group_account): diff --git a/inbox.py b/inbox.py index bf49e526a..341e60627 100644 --- a/inbox.py +++ b/inbox.py @@ -58,7 +58,7 @@ from utils import load_json from utils import save_json from utils import undoLikesCollectionEntry from utils import undoReactionCollectionEntry -from utils import hasGroupType +from utils import has_group_type from utils import local_actor_url from utils import has_object_stringType from categories import getHashtagCategories @@ -777,7 +777,7 @@ def _receiveUndoFollow(session, base_dir: str, http_prefix: str, domainFollowingFull = get_full_domain(domainFollowing, portFollowing) group_account = \ - hasGroupType(base_dir, message_json['object']['actor'], None) + has_group_type(base_dir, message_json['object']['actor'], None) if unfollowerOfAccount(base_dir, nicknameFollowing, domainFollowingFull, nicknameFollower, domainFollowerFull, @@ -3985,7 +3985,7 @@ def _receiveFollowRequest(session, base_dir: str, http_prefix: str, message_json['actor']) group_account = \ - hasGroupType(base_dir, message_json['actor'], person_cache) + has_group_type(base_dir, message_json['actor'], person_cache) if group_account and is_group_account(base_dir, nickname, domain): print('Group cannot follow a group') return False @@ -4027,8 +4027,8 @@ def _receiveFollowRequest(session, base_dir: str, http_prefix: str, if os.path.isfile(followersFilename): if approveHandle not in open(followersFilename).read(): group_account = \ - hasGroupType(base_dir, - message_json['actor'], person_cache) + has_group_type(base_dir, + message_json['actor'], person_cache) if debug: print(approveHandle + ' / ' + message_json['actor'] + ' is Group: ' + str(group_account)) diff --git a/like.py b/like.py index f003f6ffe..c65925915 100644 --- a/like.py +++ b/like.py @@ -22,7 +22,7 @@ from utils import getNicknameFromActor from utils import getDomainFromActor from utils import locatePost from utils import undoLikesCollectionEntry -from utils import hasGroupType +from utils import has_group_type from utils import local_actor_url from utils import load_json from utils import save_json @@ -106,7 +106,7 @@ def _like(recentPostsCache: {}, if actorLiked: likedPostNickname = getNicknameFromActor(actorLiked) likedPostDomain, likedPostPort = getDomainFromActor(actorLiked) - group_account = hasGroupType(base_dir, actorLiked, person_cache) + group_account = has_group_type(base_dir, actorLiked, person_cache) else: if has_users_path(objectUrl): likedPostNickname = getNicknameFromActor(objectUrl) @@ -116,7 +116,7 @@ def _like(recentPostsCache: {}, objectUrl.split('/' + likedPostNickname + '/')[0] + \ '/' + likedPostNickname group_account = \ - hasGroupType(base_dir, actorLiked, person_cache) + has_group_type(base_dir, actorLiked, person_cache) if likedPostNickname: postFilename = locatePost(base_dir, nickname, domain, objectUrl) diff --git a/migrate.py b/migrate.py index 6e09fb1d3..036228f0c 100644 --- a/migrate.py +++ b/migrate.py @@ -12,7 +12,7 @@ from utils import isAccountDir from utils import getNicknameFromActor from utils import getDomainFromActor from utils import acct_dir -from utils import hasGroupType +from utils import has_group_type from webfinger import webfingerHandle from blocking import isBlocked from posts import getUserUrl @@ -106,7 +106,7 @@ def _updateMovedHandle(base_dir: str, nickname: str, domain: str, if movedToPort: if movedToPort != 80 and movedToPort != 443: movedToDomainFull = movedToDomain + ':' + str(movedToPort) - group_account = hasGroupType(base_dir, movedToUrl, None) + group_account = has_group_type(base_dir, movedToUrl, None) if isBlocked(base_dir, nickname, domain, movedToNickname, movedToDomain): # someone that you follow has moved to a blocked domain diff --git a/person.py b/person.py index 90e7d0af4..d4c6a44c3 100644 --- a/person.py +++ b/person.py @@ -57,7 +57,7 @@ from utils import get_image_extensions from utils import isImageFile from utils import acct_dir from utils import get_user_paths -from utils import getGroupPaths +from utils import get_group_paths from utils import local_actor_url from utils import dangerousSVG from session import createSession @@ -1445,7 +1445,7 @@ def getActorJson(hostDomain: str, handle: str, http: bool, gnunet: bool, detectedUsersPath in handle or \ handle.startswith('http') or \ handle.startswith('hyper'): - groupPaths = getGroupPaths() + groupPaths = get_group_paths() if detectedUsersPath in groupPaths: group_account = True # format: https://domain/@nick diff --git a/posts.py b/posts.py index 03d503bd1..595ecb1a9 100644 --- a/posts.py +++ b/posts.py @@ -37,7 +37,7 @@ from utils import invalidCiphertext from utils import has_object_stringType from utils import removeIdEnding from utils import replace_users_with_at -from utils import hasGroupType +from utils import has_group_type from utils import get_base_content_from_post from utils import removeDomainPort from utils import getPortFromDomain @@ -3000,7 +3000,7 @@ def _sendToNamedAddresses(session, base_dir: str, if sharedItemFederationTokens.get(fromDomainFull): sharedItemsToken = sharedItemFederationTokens[fromDomainFull] - group_account = hasGroupType(base_dir, address, person_cache) + group_account = has_group_type(base_dir, address, person_cache) sendSignedJson(post_json_object, session, base_dir, nickname, fromDomain, port, diff --git a/reaction.py b/reaction.py index ed91cf273..2300146c7 100644 --- a/reaction.py +++ b/reaction.py @@ -24,7 +24,7 @@ from utils import getNicknameFromActor from utils import getDomainFromActor from utils import locatePost from utils import undoReactionCollectionEntry -from utils import hasGroupType +from utils import has_group_type from utils import local_actor_url from utils import load_json from utils import save_json @@ -104,7 +104,7 @@ def _reaction(recentPostsCache: {}, reactionPostNickname = getNicknameFromActor(actorReaction) reactionPostDomain, reactionPostPort = \ getDomainFromActor(actorReaction) - group_account = hasGroupType(base_dir, actorReaction, person_cache) + group_account = has_group_type(base_dir, actorReaction, person_cache) else: if has_users_path(objectUrl): reactionPostNickname = getNicknameFromActor(objectUrl) @@ -115,7 +115,7 @@ def _reaction(recentPostsCache: {}, objectUrl.split('/' + reactionPostNickname + '/')[0] + \ '/' + reactionPostNickname group_account = \ - hasGroupType(base_dir, actorReaction, person_cache) + has_group_type(base_dir, actorReaction, person_cache) if reactionPostNickname: postFilename = locatePost(base_dir, nickname, domain, objectUrl) diff --git a/utils.py b/utils.py index fa8c083cb..85e56e61b 100644 --- a/utils.py +++ b/utils.py @@ -1063,7 +1063,7 @@ def get_user_paths() -> []: '/c/', '/video-channels/') -def getGroupPaths() -> []: +def get_group_paths() -> []: """Returns possible group paths e.g. https://lemmy/c/groupname """ @@ -2988,17 +2988,17 @@ def dateSecondsToString(dateSec: int) -> str: return thisDate.strftime("%Y-%m-%dT%H:%M:%SZ") -def hasGroupType(base_dir: str, actor: str, person_cache: {}, - debug: bool = False) -> bool: +def has_group_type(base_dir: str, actor: str, person_cache: {}, + debug: bool = False) -> bool: """Does the given actor url have a group type? """ # does the actor path clearly indicate that this is a group? # eg. https://lemmy/c/groupname - groupPaths = getGroupPaths() - for grpPath in groupPaths: - if grpPath in actor: + group_paths = get_group_paths() + for grp_path in group_paths: + if grp_path in actor: if debug: - print('grpPath ' + grpPath + ' in ' + actor) + print('grpPath ' + grp_path + ' in ' + actor) return True # is there a cached actor which can be examined for Group type? return is_group_actor(base_dir, actor, person_cache, debug) diff --git a/webfinger.py b/webfinger.py index 767bd4a40..976564d50 100644 --- a/webfinger.py +++ b/webfinger.py @@ -19,7 +19,7 @@ from utils import save_json from utils import getProtocolPrefixes from utils import removeDomainPort from utils import get_user_paths -from utils import getGroupPaths +from utils import get_group_paths from utils import local_actor_url @@ -49,7 +49,7 @@ def _parseHandle(handle: str) -> (str, str, bool): # try for different /users/ paths usersPaths = get_user_paths() - groupPaths = getGroupPaths() + groupPaths = get_group_paths() for possibleUsersPath in usersPaths: if possibleUsersPath in handle: if possibleUsersPath in groupPaths: