Change avatar path

merge-requests/8/head
Bob Mottram 2020-12-18 23:38:15 +00:00
parent 30d95182d3
commit 9dd5ac532f
1 changed files with 3 additions and 1 deletions

View File

@ -148,13 +148,15 @@ def randomizeActorImages(personJson: {}) -> None:
This causes other instances to update their cached avatar image
"""
personId = personJson['id']
nickname = personId.split('/users/')[1]
lastPartOfFilename = personJson['icon']['url'].split('/')[-1]
existingExtension = lastPartOfFilename.split('.')[1]
# NOTE: these files don't need to have cryptographically
# secure names
randStr = str(randint(10000000000000, 99999999999999)) # nosec
personJson['icon']['url'] = \
'/accounts/avatars/avatar' + randStr + '.' + existingExtension
'/accounts/avatars/' + nickname + \
'/avatar' + randStr + '.' + existingExtension
lastPartOfFilename = personJson['image']['url'].split('/')[-1]
existingExtension = lastPartOfFilename.split('.')[1]
randStr = str(randint(10000000000000, 99999999999999)) # nosec