Snake case

main
Bob Mottram 2021-12-26 12:19:00 +00:00
parent 65e42a7c12
commit 8f97b42fd4
15 changed files with 54 additions and 54 deletions

View File

@ -9,7 +9,7 @@ __module_group__ = "ActivityPub"
import os
from utils import hasObjectStringObject
from utils import hasUsersPath
from utils import has_users_path
from utils import getFullDomain
from utils import urlPermitted
from utils import getDomainFromActor
@ -196,7 +196,7 @@ def receiveAcceptReject(session, base_dir: str,
return False
if not hasActor(message_json, debug):
return False
if not hasUsersPath(message_json['actor']):
if not has_users_path(message_json['actor']):
if debug:
print('DEBUG: "users" or "profile" missing from actor in ' +
message_json['type'] + '. Assuming single user instance.')

View File

@ -11,7 +11,7 @@ from utils import hasObjectStringObject
from utils import hasGroupType
from utils import removeDomainPort
from utils import removeIdEnding
from utils import hasUsersPath
from utils import has_users_path
from utils import getFullDomain
from utils import getStatusNumber
from utils import createOutboxDir
@ -164,7 +164,7 @@ def createAnnounce(session, base_dir: str, federation_list: [],
announceDomain = None
announcePort = None
group_account = False
if hasUsersPath(objectUrl):
if has_users_path(objectUrl):
announceNickname = getNicknameFromActor(objectUrl)
announceDomain, announcePort = getDomainFromActor(objectUrl)
if '/' + str(announceNickname) + '/' in objectUrl:

View File

@ -14,7 +14,7 @@ import os
import secrets
import datetime
from utils import isSystemAccount
from utils import hasUsersPath
from utils import has_users_path
def _hashPassword(password: str) -> str:
@ -92,7 +92,7 @@ def authorizeBasic(base_dir: str, path: str, authHeader: str,
print('DEBUG: basic auth - Authorisation header does not ' +
'contain a space character')
return False
if not hasUsersPath(path):
if not has_users_path(path):
if debug:
print('DEBUG: basic auth - ' +
'path for Authorization does not contain a user')

View File

@ -22,7 +22,7 @@ from utils import loadJson
from utils import saveJson
from utils import fileLastModified
from utils import setConfigParam
from utils import hasUsersPath
from utils import has_users_path
from utils import getFullDomain
from utils import removeIdEnding
from utils import isEvil
@ -437,7 +437,7 @@ def outboxBlock(base_dir: str, http_prefix: str,
if debug:
print('DEBUG: c2s block object is not a status')
return False
if not hasUsersPath(messageId):
if not has_users_path(messageId):
if debug:
print('DEBUG: c2s block object has no nickname')
return False
@ -493,7 +493,7 @@ def outboxUndoBlock(base_dir: str, http_prefix: str,
if debug:
print('DEBUG: c2s undo block object is not a status')
return
if not hasUsersPath(messageId):
if not has_users_path(messageId):
if debug:
print('DEBUG: c2s undo block object has no nickname')
return
@ -793,7 +793,7 @@ def outboxMute(base_dir: str, http_prefix: str,
if debug:
print('DEBUG: c2s mute object is not a status')
return
if not hasUsersPath(messageId):
if not has_users_path(messageId):
if debug:
print('DEBUG: c2s mute object has no nickname')
return
@ -848,7 +848,7 @@ def outboxUndoMute(base_dir: str, http_prefix: str,
if debug:
print('DEBUG: c2s undo mute object is not a status')
return
if not hasUsersPath(messageId):
if not has_users_path(messageId):
if debug:
print('DEBUG: c2s undo mute object has no nickname')
return

View File

@ -12,7 +12,7 @@ from pprint import pprint
from webfinger import webfingerHandle
from auth import createBasicAuthHeader
from utils import removeDomainPort
from utils import hasUsersPath
from utils import has_users_path
from utils import getFullDomain
from utils import removeIdEnding
from utils import removePostFromCache
@ -286,7 +286,7 @@ def bookmark(recentPostsCache: {},
bookmarkedPostNickname = getNicknameFromActor(acBm)
bookmarkedPostDomain, bookmarkedPostPort = getDomainFromActor(acBm)
else:
if hasUsersPath(objectUrl):
if has_users_path(objectUrl):
ou = objectUrl
bookmarkedPostNickname = getNicknameFromActor(ou)
bookmarkedPostDomain, bookmarkedPostPort = getDomainFromActor(ou)
@ -350,7 +350,7 @@ def undoBookmark(recentPostsCache: {},
bookmarkedPostNickname = getNicknameFromActor(acBm)
bookmarkedPostDomain, bookmarkedPostPort = getDomainFromActor(acBm)
else:
if hasUsersPath(objectUrl):
if has_users_path(objectUrl):
ou = objectUrl
bookmarkedPostNickname = getNicknameFromActor(ou)
bookmarkedPostDomain, bookmarkedPostPort = getDomainFromActor(ou)

View File

@ -271,7 +271,7 @@ from utils import getLocalNetworkAddresses
from utils import decodedHost
from utils import isPublicPost
from utils import get_locked_account
from utils import hasUsersPath
from utils import has_users_path
from utils import getFullDomain
from utils import removeHtml
from utils import isEditor
@ -3489,7 +3489,7 @@ class PubServer(BaseHTTPRequestHandler):
return
elif ('@' in searchStr or
('://' in searchStr and
hasUsersPath(searchStr))):
has_users_path(searchStr))):
if searchStr.endswith(':') or \
searchStr.endswith(';') or \
searchStr.endswith('.'):
@ -3508,7 +3508,7 @@ class PubServer(BaseHTTPRequestHandler):
# are we already following the searched for handle?
if isFollowingActor(base_dir, nickname, domain, searchStr):
if not hasUsersPath(searchStr):
if not has_users_path(searchStr):
searchNickname = getNicknameFromActor(searchStr)
searchDomain, searchPort = \
getDomainFromActor(searchStr)
@ -14807,7 +14807,7 @@ class PubServer(BaseHTTPRequestHandler):
if '/ontologies/' in self.path or \
'/data/' in self.path:
if not hasUsersPath(self.path):
if not has_users_path(self.path):
self._getOntology(callingDomain,
self.path, self.server.base_dir,
GETstartTime)

View File

@ -11,7 +11,7 @@ import os
from datetime import datetime
from utils import hasObjectString
from utils import removeDomainPort
from utils import hasUsersPath
from utils import has_users_path
from utils import getFullDomain
from utils import removeIdEnding
from utils import getNicknameFromActor
@ -143,7 +143,7 @@ def outboxDelete(base_dir: str, http_prefix: str,
if debug:
print('DEBUG: c2s delete object is not a status')
return
if not hasUsersPath(messageId):
if not has_users_path(messageId):
if debug:
print('DEBUG: c2s delete object has no nickname')
return

View File

@ -67,7 +67,7 @@ from auth import storeBasicCredentials
from auth import createPassword
from utils import removeDomainPort
from utils import getPortFromDomain
from utils import hasUsersPath
from utils import has_users_path
from utils import getFullDomain
from utils import setConfigParam
from utils import getConfigParam
@ -2129,7 +2129,7 @@ if args.followers:
for prefix in prefixes:
args.followers = args.followers.replace(prefix, '')
args.followers = args.followers.replace('/@', '/users/')
if not hasUsersPath(args.followers):
if not has_users_path(args.followers):
print('Expected actor format: ' +
'https://domain/@nick or https://domain/users/nick')
sys.exit()
@ -2212,7 +2212,7 @@ if args.followers:
personUrl = None
if wfRequest.get('errors'):
print('wfRequest error: ' + str(wfRequest['errors']))
if hasUsersPath(args.followers):
if has_users_path(args.followers):
personUrl = originalActor
else:
sys.exit()

View File

@ -12,7 +12,7 @@ import os
from utils import hasObjectStringObject
from utils import hasObjectStringType
from utils import removeDomainPort
from utils import hasUsersPath
from utils import has_users_path
from utils import getFullDomain
from utils import getFollowersList
from utils import validNickname
@ -409,7 +409,7 @@ def _getNoOfFollows(base_dir: str, nickname: str, domain: str,
ctr += 1
elif ((line.startswith('http') or
line.startswith('hyper')) and
hasUsersPath(line)):
has_users_path(line)):
ctr += 1
return ctr
@ -536,7 +536,7 @@ def getFollowingFeed(base_dir: str, domain: str, port: int, path: str,
following['orderedItems'].append(url)
elif ((line.startswith('http') or
line.startswith('hyper')) and
hasUsersPath(line)):
has_users_path(line)):
# https://domain/users/nickname
pageCtr += 1
totalCtr += 1

View File

@ -36,7 +36,7 @@ from utils import has_object_dict
from utils import dmAllowedFromDomain
from utils import isRecentPost
from utils import getConfigParam
from utils import hasUsersPath
from utils import has_users_path
from utils import validPostDate
from utils import getFullDomain
from utils import removeIdEnding
@ -746,7 +746,7 @@ def _receiveUndoFollow(session, base_dir: str, http_prefix: str,
if debug:
print('DEBUG: follow request has no actor within object')
return False
if not hasUsersPath(message_json['object']['actor']):
if not has_users_path(message_json['object']['actor']):
if debug:
print('DEBUG: "users" or "profile" missing ' +
'from actor within object')
@ -807,7 +807,7 @@ def _receiveUndo(session, base_dir: str, http_prefix: str,
print('DEBUG: Undo activity received')
if not hasActor(message_json, debug):
return False
if not hasUsersPath(message_json['actor']):
if not has_users_path(message_json['actor']):
if debug:
print('DEBUG: "users" or "profile" missing from actor')
return False
@ -953,7 +953,7 @@ def _receiveUpdate(recentPostsCache: {}, session, base_dir: str,
return False
if not hasObjectStringType(message_json, debug):
return False
if not hasUsersPath(message_json['actor']):
if not has_users_path(message_json['actor']):
if debug:
print('DEBUG: "users" or "profile" missing from actor in ' +
message_json['type'])
@ -1021,7 +1021,7 @@ def _receiveLike(recentPostsCache: {},
if debug:
print('DEBUG: ' + message_json['type'] + ' has no "to" list')
return False
if not hasUsersPath(message_json['actor']):
if not has_users_path(message_json['actor']):
if debug:
print('DEBUG: "users" or "profile" missing from actor in ' +
message_json['type'])
@ -1143,7 +1143,7 @@ def _receiveUndoLike(recentPostsCache: {},
return False
if not hasObjectStringObject(message_json, debug):
return False
if not hasUsersPath(message_json['actor']):
if not has_users_path(message_json['actor']):
if debug:
print('DEBUG: "users" or "profile" missing from actor in ' +
message_json['type'] + ' like')
@ -1267,7 +1267,7 @@ def _receiveReaction(recentPostsCache: {},
print('_receiveReaction: Invalid emoji reaction: "' +
message_json['content'] + '" from ' + message_json['actor'])
return False
if not hasUsersPath(message_json['actor']):
if not has_users_path(message_json['actor']):
if debug:
print('DEBUG: "users" or "profile" missing from actor in ' +
message_json['type'])
@ -1412,7 +1412,7 @@ def _receiveUndoReaction(recentPostsCache: {},
if debug:
print('DEBUG: ' + message_json['type'] + ' content is not string')
return False
if not hasUsersPath(message_json['actor']):
if not has_users_path(message_json['actor']):
if debug:
print('DEBUG: "users" or "profile" missing from actor in ' +
message_json['type'] + ' reaction')
@ -1753,7 +1753,7 @@ def _receiveDelete(session, handle: str, isGroup: bool, base_dir: str,
if debug:
print('DEBUG: ' + message_json['type'] + ' has no "to" list')
return False
if not hasUsersPath(message_json['actor']):
if not has_users_path(message_json['actor']):
if debug:
print('DEBUG: ' +
'"users" or "profile" missing from actor in ' +
@ -1835,7 +1835,7 @@ def _receiveAnnounce(recentPostsCache: {},
if debug:
print('DEBUG: ' + message_json['type'] + ' has no "to" list')
return False
if not hasUsersPath(message_json['actor']):
if not has_users_path(message_json['actor']):
if debug:
print('DEBUG: ' +
'"users" or "profile" missing from actor in ' +
@ -1845,7 +1845,7 @@ def _receiveAnnounce(recentPostsCache: {},
if debug:
print('DEBUG: self-boost rejected')
return False
if not hasUsersPath(message_json['object']):
if not has_users_path(message_json['object']):
if debug:
print('DEBUG: ' +
'"users", "channel" or "profile" missing in ' +
@ -1984,7 +1984,7 @@ def _receiveAnnounce(recentPostsCache: {},
if isinstance(attrib, str):
lookupActor = attrib
if lookupActor:
if hasUsersPath(lookupActor):
if has_users_path(lookupActor):
if '/statuses/' in lookupActor:
lookupActor = lookupActor.split('/statuses/')[0]
@ -2048,7 +2048,7 @@ def _receiveUndoAnnounce(recentPostsCache: {},
return False
if message_json['object']['type'] != 'Announce':
return False
if not hasUsersPath(message_json['actor']):
if not has_users_path(message_json['actor']):
if debug:
print('DEBUG: "users" or "profile" missing from actor in ' +
message_json['type'] + ' announce')
@ -2318,7 +2318,7 @@ def _obtainAvatarForReplyPost(session, base_dir: str, http_prefix: str,
if not isinstance(lookupActor, str):
return
if not hasUsersPath(lookupActor):
if not has_users_path(lookupActor):
return
if '/statuses/' in lookupActor:
@ -3868,7 +3868,7 @@ def _receiveFollowRequest(session, base_dir: str, http_prefix: str,
print('Receiving follow request')
if not hasActor(message_json, debug):
return False
if not hasUsersPath(message_json['actor']):
if not has_users_path(message_json['actor']):
if debug:
print('DEBUG: users/profile/accounts/channel missing from actor')
return False
@ -3890,7 +3890,7 @@ def _receiveFollowRequest(session, base_dir: str, http_prefix: str,
'nickname. Assuming single user instance.')
if not message_json.get('to'):
message_json['to'] = message_json['object']
if not hasUsersPath(message_json['object']):
if not has_users_path(message_json['object']):
if debug:
print('DEBUG: users/profile/channel/accounts ' +
'not found within object')

View File

@ -14,7 +14,7 @@ from utils import hasObjectStringObject
from utils import hasObjectStringType
from utils import removeDomainPort
from utils import has_object_dict
from utils import hasUsersPath
from utils import has_users_path
from utils import getFullDomain
from utils import removeIdEnding
from utils import urlPermitted
@ -108,7 +108,7 @@ def _like(recentPostsCache: {},
likedPostDomain, likedPostPort = getDomainFromActor(actorLiked)
group_account = hasGroupType(base_dir, actorLiked, person_cache)
else:
if hasUsersPath(objectUrl):
if has_users_path(objectUrl):
likedPostNickname = getNicknameFromActor(objectUrl)
likedPostDomain, likedPostPort = getDomainFromActor(objectUrl)
if '/' + str(likedPostNickname) + '/' in objectUrl:

View File

@ -52,7 +52,7 @@ from utils import setConfigParam
from utils import getConfigParam
from utils import refresh_newswire
from utils import getProtocolPrefixes
from utils import hasUsersPath
from utils import has_users_path
from utils import getImageExtensions
from utils import isImageFile
from utils import acct_dir
@ -1450,7 +1450,7 @@ def getActorJson(hostDomain: str, handle: str, http: bool, gnunet: bool,
group_account = True
# format: https://domain/@nick
originalHandle = handle
if not hasUsersPath(originalHandle):
if not has_users_path(originalHandle):
if not quiet or debug:
print('getActorJson: Expected actor format: ' +
'https://domain/@nick or https://domain' +
@ -1556,7 +1556,7 @@ def getActorJson(hostDomain: str, handle: str, http: bool, gnunet: bool,
if not quiet or debug:
print('getActorJson wfRequest error: ' +
str(wfRequest['errors']))
if hasUsersPath(handle):
if has_users_path(handle):
personUrl = originalActor
else:
if debug:

View File

@ -46,7 +46,7 @@ from utils import rejectPostId
from utils import removeInvalidChars
from utils import fileLastModified
from utils import isPublicPost
from utils import hasUsersPath
from utils import has_users_path
from utils import validPostDate
from utils import getFullDomain
from utils import getFollowersList
@ -216,7 +216,7 @@ def getUserUrl(wfRequest: {}, sourceId: int, debug: bool) -> str:
if link['type'] != 'application/activity+json':
continue
if '/@' not in link['href']:
if debug and not hasUsersPath(link['href']):
if debug and not has_users_path(link['href']):
print('getUserUrl webfinger activity+json ' +
'contains single user instance actor ' +
str(sourceId) + ' ' + str(link))
@ -4636,7 +4636,7 @@ def downloadAnnounce(session, base_dir: str, http_prefix: str,
base_dir, nickname, domain, postId,
recentPostsCache)
return None
if not hasUsersPath(announcedJson['id']):
if not has_users_path(announcedJson['id']):
_rejectAnnounce(announceFilename,
base_dir, nickname, domain, postId,
recentPostsCache)
@ -5299,7 +5299,7 @@ def getOriginalPostFromAnnounceUrl(announceUrl: str, base_dir: str,
url = origPostId
else:
# we don't have the original post
if hasUsersPath(origPostId):
if has_users_path(origPostId):
# get the actor from the original post url
origNick = getNicknameFromActor(origPostId)
origDomain, origPort = getDomainFromActor(origPostId)

View File

@ -16,7 +16,7 @@ from utils import hasObjectStringObject
from utils import hasObjectStringType
from utils import removeDomainPort
from utils import has_object_dict
from utils import hasUsersPath
from utils import has_users_path
from utils import getFullDomain
from utils import removeIdEnding
from utils import urlPermitted
@ -106,7 +106,7 @@ def _reaction(recentPostsCache: {},
getDomainFromActor(actorReaction)
group_account = hasGroupType(base_dir, actorReaction, person_cache)
else:
if hasUsersPath(objectUrl):
if has_users_path(objectUrl):
reactionPostNickname = getNicknameFromActor(objectUrl)
reactionPostDomain, reactionPostPort = \
getDomainFromActor(objectUrl)

View File

@ -191,7 +191,7 @@ def get_locked_account(actor_json: {}) -> bool:
return False
def hasUsersPath(pathStr: str) -> bool:
def has_users_path(pathStr: str) -> bool:
"""Whether there is a /users/ path (or equivalent) in the given string
"""
usersList = getUserPaths()