mirror of https://gitlab.com/bashrc2/epicyon
Change paths for avatars and backgrounds to be similar to Mastodon icon/image
parent
c2ed66e81d
commit
4d849f33a8
12
daemon.py
12
daemon.py
|
@ -1267,7 +1267,9 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
self.authorizedNickname = None
|
self.authorizedNickname = None
|
||||||
|
|
||||||
notAuthPaths = (
|
notAuthPaths = (
|
||||||
'/icons/', '/avatars/', '/favicon.ico', '/newswire.xml',
|
'/icons/', '/avatars/',
|
||||||
|
'/accounts/avatars/', '/accounts/headers/',
|
||||||
|
'/favicon.ico', '/newswire.xml',
|
||||||
'/newswire_favicon.ico', '/categories.xml'
|
'/newswire_favicon.ico', '/categories.xml'
|
||||||
)
|
)
|
||||||
for notAuthStr in notAuthPaths:
|
for notAuthStr in notAuthPaths:
|
||||||
|
@ -9902,6 +9904,7 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
'/emoji/' not in path and \
|
'/emoji/' not in path and \
|
||||||
'/tags/' not in path and \
|
'/tags/' not in path and \
|
||||||
'/avatars/' not in path and \
|
'/avatars/' not in path and \
|
||||||
|
'/headers/' not in path and \
|
||||||
'/fonts/' not in path and \
|
'/fonts/' not in path and \
|
||||||
'/icons/' not in path:
|
'/icons/' not in path:
|
||||||
divertToLoginScreen = True
|
divertToLoginScreen = True
|
||||||
|
@ -10199,9 +10202,16 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
"""Shows an avatar or banner or profile background image
|
"""Shows an avatar or banner or profile background image
|
||||||
"""
|
"""
|
||||||
if '/users/' not in path:
|
if '/users/' not in path:
|
||||||
|
if '/accounts/avatars/' not in path:
|
||||||
|
if '/accounts/headers/' not in path:
|
||||||
return False
|
return False
|
||||||
if not pathIsImage(path):
|
if not pathIsImage(path):
|
||||||
return False
|
return False
|
||||||
|
if '/accounts/avatars/' in path:
|
||||||
|
avatarStr = path.split('/accounts/avatars/')[1]
|
||||||
|
elif '/accounts/headers/' in path:
|
||||||
|
avatarStr = path.split('/accounts/headers/')[1]
|
||||||
|
else:
|
||||||
avatarStr = path.split('/users/')[1]
|
avatarStr = path.split('/users/')[1]
|
||||||
if not ('/' in avatarStr and '.temp.' not in path):
|
if not ('/' in avatarStr and '.temp.' not in path):
|
||||||
return False
|
return False
|
||||||
|
|
|
@ -162,13 +162,17 @@ def randomizeActorImages(personJson: {}) -> None:
|
||||||
# NOTE: these files don't need to have cryptographically
|
# NOTE: these files don't need to have cryptographically
|
||||||
# secure names
|
# secure names
|
||||||
randStr = str(randint(10000000000000, 99999999999999)) # nosec
|
randStr = str(randint(10000000000000, 99999999999999)) # nosec
|
||||||
|
baseUrl = personId.split('/users/')[0]
|
||||||
|
nickname = personJson['preferredUsername']
|
||||||
personJson['icon']['url'] = \
|
personJson['icon']['url'] = \
|
||||||
personId + '/avatar' + randStr + '.' + existingExtension
|
baseUrl + '/accounts/avatars/' + nickname + \
|
||||||
|
'/avatar' + randStr + '.' + existingExtension
|
||||||
lastPartOfFilename = personJson['image']['url'].split('/')[-1]
|
lastPartOfFilename = personJson['image']['url'].split('/')[-1]
|
||||||
existingExtension = lastPartOfFilename.split('.')[1]
|
existingExtension = lastPartOfFilename.split('.')[1]
|
||||||
randStr = str(randint(10000000000000, 99999999999999)) # nosec
|
randStr = str(randint(10000000000000, 99999999999999)) # nosec
|
||||||
personJson['image']['url'] = \
|
personJson['image']['url'] = \
|
||||||
personId + '/image' + randStr + '.' + existingExtension
|
baseUrl + '/accounts/headers/' + nickname + \
|
||||||
|
'/image' + randStr + '.' + existingExtension
|
||||||
|
|
||||||
|
|
||||||
def getDefaultPersonContext() -> str:
|
def getDefaultPersonContext() -> str:
|
||||||
|
|
3
utils.py
3
utils.py
|
@ -1434,7 +1434,8 @@ def _isReservedName(nickname: str) -> bool:
|
||||||
'activity', 'undo', 'pinned',
|
'activity', 'undo', 'pinned',
|
||||||
'reply', 'replies', 'question', 'like',
|
'reply', 'replies', 'question', 'like',
|
||||||
'likes', 'users', 'statuses', 'tags',
|
'likes', 'users', 'statuses', 'tags',
|
||||||
'accounts', 'channels', 'profile', 'u',
|
'accounts', 'headers',
|
||||||
|
'channels', 'profile', 'u',
|
||||||
'updates', 'repeat', 'announce',
|
'updates', 'repeat', 'announce',
|
||||||
'shares', 'fonts', 'icons', 'avatars',
|
'shares', 'fonts', 'icons', 'avatars',
|
||||||
'welcome', 'helpimages',
|
'welcome', 'helpimages',
|
||||||
|
|
Loading…
Reference in New Issue