mirror of https://gitlab.com/bashrc2/epicyon
Better support for alternative users paths
parent
4e30a17d83
commit
3b94048e28
|
@ -28,7 +28,6 @@ from utils import saveJson
|
|||
from utils import isAccountDir
|
||||
from utils import getUserPaths
|
||||
from utils import acctDir
|
||||
from utils import getUsersPaths
|
||||
from acceptreject import createAccept
|
||||
from acceptreject import createReject
|
||||
from webfinger import webfingerHandle
|
||||
|
@ -109,12 +108,11 @@ def _removeFromFollowBase(baseDir: str,
|
|||
acceptDenyDomain = acceptOrDenyHandle.split('@')[1]
|
||||
# for each possible users path construct an actor and
|
||||
# check if it exists in teh file
|
||||
usersPaths = getUsersPaths()
|
||||
usersPaths = getUserPaths()
|
||||
actorFound = False
|
||||
for usersName in usersPaths:
|
||||
acceptDenyActor = \
|
||||
'://' + acceptDenyDomain + '/' + \
|
||||
usersName + '/' + acceptDenyNickname
|
||||
'://' + acceptDenyDomain + usersName + acceptDenyNickname
|
||||
if acceptDenyActor in open(approveFollowsFilename).read():
|
||||
actorFound = True
|
||||
break
|
||||
|
|
|
@ -51,9 +51,8 @@ from utils import getProtocolPrefixes
|
|||
from utils import hasUsersPath
|
||||
from utils import getImageExtensions
|
||||
from utils import isImageFile
|
||||
from utils import getUserPaths
|
||||
from utils import acctDir
|
||||
from utils import getUsersPaths
|
||||
from utils import getUserPaths
|
||||
from session import createSession
|
||||
from session import getJson
|
||||
from webfinger import webfingerHandle
|
||||
|
@ -1194,10 +1193,10 @@ def _detectUsersPath(url: str) -> str:
|
|||
"""
|
||||
if '/' not in url:
|
||||
return '/users/'
|
||||
usersPaths = getUsersPaths()
|
||||
usersPaths = getUserPaths()
|
||||
for possibleUsersPath in usersPaths:
|
||||
if '/' + possibleUsersPath + '/' in url:
|
||||
return '/' + possibleUsersPath + '/'
|
||||
if possibleUsersPath in url:
|
||||
return possibleUsersPath
|
||||
return '/users/'
|
||||
|
||||
|
||||
|
|
14
utils.py
14
utils.py
|
@ -28,13 +28,6 @@ invalidCharacters = (
|
|||
)
|
||||
|
||||
|
||||
def getUsersPaths() -> []:
|
||||
"""Returns the possible paths for users accounts
|
||||
e.g. /users/nickname, /channel/nickname
|
||||
"""
|
||||
return ('users', 'profile', 'channel', 'accounts', 'u', 'c')
|
||||
|
||||
|
||||
def getActorLanguagesList(actorJson: {}) -> []:
|
||||
"""Returns a list containing languages used by the given actor
|
||||
"""
|
||||
|
@ -166,9 +159,9 @@ def getLockedAccount(actorJson: {}) -> bool:
|
|||
def hasUsersPath(pathStr: str) -> bool:
|
||||
"""Whether there is a /users/ path (or equivalent) in the given string
|
||||
"""
|
||||
usersList = getUsersPaths()
|
||||
usersList = getUserPaths()
|
||||
for usersStr in usersList:
|
||||
if '/' + usersStr + '/' in pathStr:
|
||||
if usersStr in pathStr:
|
||||
return True
|
||||
if '://' in pathStr:
|
||||
domain = pathStr.split('://')[1]
|
||||
|
@ -981,8 +974,9 @@ def getNicknameFromActor(actor: str) -> str:
|
|||
|
||||
def getUserPaths() -> []:
|
||||
"""Returns possible user paths
|
||||
e.g. /users/nickname, /channel/nickname
|
||||
"""
|
||||
return ('/users/', '/profile/', '/accounts/', '/channel/', '/u/')
|
||||
return ('/users/', '/profile/', '/accounts/', '/channel/', '/u/', '/c/')
|
||||
|
||||
|
||||
def getDomainFromActor(actor: str) -> (str, int):
|
||||
|
|
Loading…
Reference in New Issue