mirror of https://gitlab.com/bashrc2/epicyon
Function to return user paths
parent
b870a69545
commit
0335e52458
|
@ -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:
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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:
|
||||
|
|
10
utils.py
10
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]
|
||||
|
|
Loading…
Reference in New Issue