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 loadJson
|
||||||
from utils import saveJson
|
from utils import saveJson
|
||||||
from utils import isAccountDir
|
from utils import isAccountDir
|
||||||
|
from utils import getUserPaths
|
||||||
from acceptreject import createAccept
|
from acceptreject import createAccept
|
||||||
from acceptreject import createReject
|
from acceptreject import createReject
|
||||||
from webfinger import webfingerHandle
|
from webfinger import webfingerHandle
|
||||||
|
@ -221,7 +222,7 @@ def isFollowerOfPerson(baseDir: str, nickname: str, domain: str,
|
||||||
if handle in followersStr:
|
if handle in followersStr:
|
||||||
alreadyFollowing = True
|
alreadyFollowing = True
|
||||||
else:
|
else:
|
||||||
paths = ('/profile/', '/channel/', '/accounts/', '/u/')
|
paths = getUserPaths()
|
||||||
for userPath in paths:
|
for userPath in paths:
|
||||||
url = '://' + followerDomain + userPath + followerNickname
|
url = '://' + followerDomain + userPath + followerNickname
|
||||||
if url in followersStr:
|
if url in followersStr:
|
||||||
|
|
|
@ -14,6 +14,7 @@ from follow import removeFromFollowRequests
|
||||||
from utils import loadJson
|
from utils import loadJson
|
||||||
from utils import removeDomainPort
|
from utils import removeDomainPort
|
||||||
from utils import getPortFromDomain
|
from utils import getPortFromDomain
|
||||||
|
from utils import getUserPaths
|
||||||
|
|
||||||
|
|
||||||
def manualDenyFollowRequest(session, baseDir: str,
|
def manualDenyFollowRequest(session, baseDir: str,
|
||||||
|
@ -111,7 +112,7 @@ def manualApproveFollowRequest(session, baseDir: str,
|
||||||
reqNick = approveHandle.split('@')[0]
|
reqNick = approveHandle.split('@')[0]
|
||||||
reqDomain = approveHandle.split('@')[1].strip()
|
reqDomain = approveHandle.split('@')[1].strip()
|
||||||
reqPrefix = httpPrefix + '://' + reqDomain
|
reqPrefix = httpPrefix + '://' + reqDomain
|
||||||
paths = ('/profile/', '/channel/', '/accounts/', '/u/')
|
paths = getUserPaths()
|
||||||
for userPath in paths:
|
for userPath in paths:
|
||||||
if reqPrefix + userPath + reqNick in approveFollowsStr:
|
if reqPrefix + userPath + reqNick in approveFollowsStr:
|
||||||
exists = True
|
exists = True
|
||||||
|
|
|
@ -50,6 +50,7 @@ from utils import getProtocolPrefixes
|
||||||
from utils import hasUsersPath
|
from utils import hasUsersPath
|
||||||
from utils import getImageExtensions
|
from utils import getImageExtensions
|
||||||
from utils import isImageFile
|
from utils import isImageFile
|
||||||
|
from utils import getUserPaths
|
||||||
from session import createSession
|
from session import createSession
|
||||||
from session import getJson
|
from session import getJson
|
||||||
from webfinger import webfingerHandle
|
from webfinger import webfingerHandle
|
||||||
|
@ -1211,9 +1212,7 @@ def getActorJson(hostDomain: str, handle: str, http: bool, gnunet: bool,
|
||||||
for prefix in prefixes:
|
for prefix in prefixes:
|
||||||
handle = handle.replace(prefix, '')
|
handle = handle.replace(prefix, '')
|
||||||
handle = handle.replace('/@', '/users/')
|
handle = handle.replace('/@', '/users/')
|
||||||
paths = (
|
paths = getUserPaths()
|
||||||
'/users/', '/profile/', '/channel/', '/accounts/', '/u/'
|
|
||||||
)
|
|
||||||
userPathFound = False
|
userPathFound = False
|
||||||
for userPath in paths:
|
for userPath in paths:
|
||||||
if userPath in handle:
|
if userPath in handle:
|
||||||
|
@ -1302,9 +1301,7 @@ def getActorJson(hostDomain: str, handle: str, http: bool, gnunet: bool,
|
||||||
if not personUrl:
|
if not personUrl:
|
||||||
personUrl = getUserUrl(wfRequest, 0, debug)
|
personUrl = getUserUrl(wfRequest, 0, debug)
|
||||||
if nickname == domain:
|
if nickname == domain:
|
||||||
paths = (
|
paths = getUserPaths()
|
||||||
'/users/', '/accounts/', '/channel/', '/profile/', '/u/'
|
|
||||||
)
|
|
||||||
for userPath in paths:
|
for userPath in paths:
|
||||||
personUrl = personUrl.replace(userPath, '/actor/')
|
personUrl = personUrl.replace(userPath, '/actor/')
|
||||||
if not personUrl:
|
if not personUrl:
|
||||||
|
|
10
utils.py
10
utils.py
|
@ -842,7 +842,7 @@ def getNicknameFromActor(actor: str) -> str:
|
||||||
"""
|
"""
|
||||||
if actor.startswith('@'):
|
if actor.startswith('@'):
|
||||||
actor = actor[1:]
|
actor = actor[1:]
|
||||||
usersPaths = ('/users/', '/profile/', '/channel/', '/accounts/', '/u/')
|
usersPaths = getUserPaths()
|
||||||
for possiblePath in usersPaths:
|
for possiblePath in usersPaths:
|
||||||
if possiblePath in actor:
|
if possiblePath in actor:
|
||||||
nickStr = actor.split(possiblePath)[1].replace('@', '')
|
nickStr = actor.split(possiblePath)[1].replace('@', '')
|
||||||
|
@ -872,6 +872,12 @@ def getNicknameFromActor(actor: str) -> str:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
def getUserPaths() -> []:
|
||||||
|
"""Returns possible user paths
|
||||||
|
"""
|
||||||
|
return ('/users/', '/profile/', '/accounts/', '/channel/', '/u/')
|
||||||
|
|
||||||
|
|
||||||
def getDomainFromActor(actor: str) -> (str, int):
|
def getDomainFromActor(actor: str) -> (str, int):
|
||||||
"""Returns the domain name from an actor url
|
"""Returns the domain name from an actor url
|
||||||
"""
|
"""
|
||||||
|
@ -879,7 +885,7 @@ def getDomainFromActor(actor: str) -> (str, int):
|
||||||
actor = actor[1:]
|
actor = actor[1:]
|
||||||
port = None
|
port = None
|
||||||
prefixes = getProtocolPrefixes()
|
prefixes = getProtocolPrefixes()
|
||||||
usersPaths = ('/users/', '/profile/', '/accounts/', '/channel/', '/u/')
|
usersPaths = getUserPaths()
|
||||||
for possiblePath in usersPaths:
|
for possiblePath in usersPaths:
|
||||||
if possiblePath in actor:
|
if possiblePath in actor:
|
||||||
domain = actor.split(possiblePath)[0]
|
domain = actor.split(possiblePath)[0]
|
||||||
|
|
Loading…
Reference in New Issue