mirror of https://gitlab.com/bashrc2/epicyon
Randomize avatar image and background on edit
parent
86de874ac0
commit
048086e600
|
@ -36,6 +36,7 @@ from matrix import getMatrixAddress
|
|||
from matrix import setMatrixAddress
|
||||
from donate import getDonationUrl
|
||||
from donate import setDonationUrl
|
||||
from person import randomizeActorImages
|
||||
from person import personUpgradeActor
|
||||
from person import activateAccount
|
||||
from person import deactivateAccount
|
||||
|
@ -4295,6 +4296,7 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
os.remove(allowedInstancesFilename)
|
||||
# save actor json file within accounts
|
||||
if actorChanged:
|
||||
randomizeActorImages(actorJson)
|
||||
saveJson(actorJson,actorFilename)
|
||||
# also copy to the actors cache and personCache in memory
|
||||
storePersonInCache(self.server.baseDir, \
|
||||
|
|
15
person.py
15
person.py
|
@ -12,6 +12,7 @@ import os
|
|||
import fileinput
|
||||
import subprocess
|
||||
import shutil
|
||||
from random import randint
|
||||
from pathlib import Path
|
||||
from Crypto.PublicKey import RSA
|
||||
from shutil import copyfile
|
||||
|
@ -34,7 +35,7 @@ from utils import loadJson
|
|||
from utils import saveJson
|
||||
from auth import createPassword
|
||||
from config import setConfigParam
|
||||
from config import getConfigParam
|
||||
from config import getConfigParam
|
||||
|
||||
def generateRSAKey() -> (str,str):
|
||||
key = RSA.generate(2048)
|
||||
|
@ -131,6 +132,14 @@ def accountExists(baseDir: str,nickname: str,domain: str) -> bool:
|
|||
return os.path.isdir(baseDir+'/accounts/'+nickname+'@'+domain) or \
|
||||
os.path.isdir(baseDir+'/deactivated/'+nickname+'@'+domain)
|
||||
|
||||
def randomizeActorImages(personJson: {}) -> None:
|
||||
"""Randomizes the filenames for avatar image and background
|
||||
This causes other instances to update their cached avatar image
|
||||
"""
|
||||
personId=personJson['id']
|
||||
personJson['icon']['url']=personId+'/avatar'+str(randint(10000000000000,99999999999999))+'.png'
|
||||
personJson['image']['url']=personId+'/image'+str(randint(10000000000000,99999999999999))+'.png'
|
||||
|
||||
def createPersonBase(baseDir: str,nickname: str,domain: str,port: int, \
|
||||
httpPrefix: str, saveToFile: bool,password=None) -> (str,str,{},{}):
|
||||
"""Returns the private key, public key, actor and webfinger endpoint
|
||||
|
@ -192,11 +201,11 @@ def createPersonBase(baseDir: str,nickname: str,domain: str,port: int, \
|
|||
'availability': None,
|
||||
'icon': {'mediaType': 'image/png',
|
||||
'type': 'Image',
|
||||
'url': personId+'/avatar.png'},
|
||||
'url': personId+'/avatar'+str(randint(10000000000000,99999999999999))+'.png'},
|
||||
'id': personId,
|
||||
'image': {'mediaType': 'image/png',
|
||||
'type': 'Image',
|
||||
'url': personId+'/image.png'},
|
||||
'url': personId+'/image'+str(randint(10000000000000,99999999999999))+'.png'},
|
||||
'inbox': inboxStr,
|
||||
'manuallyApprovesFollowers': approveFollowers,
|
||||
'name': personName,
|
||||
|
|
Loading…
Reference in New Issue