diff --git a/follow.py b/follow.py index 0ef1c5ce6..76129fe55 100644 --- a/follow.py +++ b/follow.py @@ -26,6 +26,7 @@ from posts import getPersonBox from utils import loadJson from utils import saveJson from utils import isAccountDir +from utils import getUserPaths from acceptreject import createAccept from acceptreject import createReject from webfinger import webfingerHandle @@ -221,7 +222,7 @@ def isFollowerOfPerson(baseDir: str, nickname: str, domain: str, if handle in followersStr: alreadyFollowing = True else: - paths = ('/profile/', '/channel/', '/accounts/', '/u/') + paths = getUserPaths() for userPath in paths: url = '://' + followerDomain + userPath + followerNickname if url in followersStr: diff --git a/manualapprove.py b/manualapprove.py index c915683ef..968b016e3 100644 --- a/manualapprove.py +++ b/manualapprove.py @@ -14,6 +14,7 @@ from follow import removeFromFollowRequests from utils import loadJson from utils import removeDomainPort from utils import getPortFromDomain +from utils import getUserPaths def manualDenyFollowRequest(session, baseDir: str, @@ -111,7 +112,7 @@ def manualApproveFollowRequest(session, baseDir: str, reqNick = approveHandle.split('@')[0] reqDomain = approveHandle.split('@')[1].strip() reqPrefix = httpPrefix + '://' + reqDomain - paths = ('/profile/', '/channel/', '/accounts/', '/u/') + paths = getUserPaths() for userPath in paths: if reqPrefix + userPath + reqNick in approveFollowsStr: exists = True diff --git a/person.py b/person.py index c6fd12e49..1f9d3cd12 100644 --- a/person.py +++ b/person.py @@ -50,6 +50,7 @@ from utils import getProtocolPrefixes from utils import hasUsersPath from utils import getImageExtensions from utils import isImageFile +from utils import getUserPaths from session import createSession from session import getJson from webfinger import webfingerHandle @@ -1211,9 +1212,7 @@ def getActorJson(hostDomain: str, handle: str, http: bool, gnunet: bool, for prefix in prefixes: handle = handle.replace(prefix, '') handle = handle.replace('/@', '/users/') - paths = ( - '/users/', '/profile/', '/channel/', '/accounts/', '/u/' - ) + paths = getUserPaths() userPathFound = False for userPath in paths: if userPath in handle: @@ -1302,9 +1301,7 @@ def getActorJson(hostDomain: str, handle: str, http: bool, gnunet: bool, if not personUrl: personUrl = getUserUrl(wfRequest, 0, debug) if nickname == domain: - paths = ( - '/users/', '/accounts/', '/channel/', '/profile/', '/u/' - ) + paths = getUserPaths() for userPath in paths: personUrl = personUrl.replace(userPath, '/actor/') if not personUrl: diff --git a/utils.py b/utils.py index 70b036cac..5aafb559c 100644 --- a/utils.py +++ b/utils.py @@ -842,7 +842,7 @@ def getNicknameFromActor(actor: str) -> str: """ if actor.startswith('@'): actor = actor[1:] - usersPaths = ('/users/', '/profile/', '/channel/', '/accounts/', '/u/') + usersPaths = getUserPaths() for possiblePath in usersPaths: if possiblePath in actor: nickStr = actor.split(possiblePath)[1].replace('@', '') @@ -872,6 +872,12 @@ def getNicknameFromActor(actor: str) -> str: return None +def getUserPaths() -> []: + """Returns possible user paths + """ + return ('/users/', '/profile/', '/accounts/', '/channel/', '/u/') + + def getDomainFromActor(actor: str) -> (str, int): """Returns the domain name from an actor url """ @@ -879,7 +885,7 @@ def getDomainFromActor(actor: str) -> (str, int): actor = actor[1:] port = None prefixes = getProtocolPrefixes() - usersPaths = ('/users/', '/profile/', '/accounts/', '/channel/', '/u/') + usersPaths = getUserPaths() for possiblePath in usersPaths: if possiblePath in actor: domain = actor.split(possiblePath)[0]