forked from indymedia/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 matrix import setMatrixAddress
|
||||||
from donate import getDonationUrl
|
from donate import getDonationUrl
|
||||||
from donate import setDonationUrl
|
from donate import setDonationUrl
|
||||||
|
from person import randomizeActorImages
|
||||||
from person import personUpgradeActor
|
from person import personUpgradeActor
|
||||||
from person import activateAccount
|
from person import activateAccount
|
||||||
from person import deactivateAccount
|
from person import deactivateAccount
|
||||||
|
@ -4295,6 +4296,7 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
os.remove(allowedInstancesFilename)
|
os.remove(allowedInstancesFilename)
|
||||||
# save actor json file within accounts
|
# save actor json file within accounts
|
||||||
if actorChanged:
|
if actorChanged:
|
||||||
|
randomizeActorImages(actorJson)
|
||||||
saveJson(actorJson,actorFilename)
|
saveJson(actorJson,actorFilename)
|
||||||
# also copy to the actors cache and personCache in memory
|
# also copy to the actors cache and personCache in memory
|
||||||
storePersonInCache(self.server.baseDir, \
|
storePersonInCache(self.server.baseDir, \
|
||||||
|
|
13
person.py
13
person.py
|
@ -12,6 +12,7 @@ import os
|
||||||
import fileinput
|
import fileinput
|
||||||
import subprocess
|
import subprocess
|
||||||
import shutil
|
import shutil
|
||||||
|
from random import randint
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from Crypto.PublicKey import RSA
|
from Crypto.PublicKey import RSA
|
||||||
from shutil import copyfile
|
from shutil import copyfile
|
||||||
|
@ -131,6 +132,14 @@ def accountExists(baseDir: str,nickname: str,domain: str) -> bool:
|
||||||
return os.path.isdir(baseDir+'/accounts/'+nickname+'@'+domain) or \
|
return os.path.isdir(baseDir+'/accounts/'+nickname+'@'+domain) or \
|
||||||
os.path.isdir(baseDir+'/deactivated/'+nickname+'@'+domain)
|
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, \
|
def createPersonBase(baseDir: str,nickname: str,domain: str,port: int, \
|
||||||
httpPrefix: str, saveToFile: bool,password=None) -> (str,str,{},{}):
|
httpPrefix: str, saveToFile: bool,password=None) -> (str,str,{},{}):
|
||||||
"""Returns the private key, public key, actor and webfinger endpoint
|
"""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,
|
'availability': None,
|
||||||
'icon': {'mediaType': 'image/png',
|
'icon': {'mediaType': 'image/png',
|
||||||
'type': 'Image',
|
'type': 'Image',
|
||||||
'url': personId+'/avatar.png'},
|
'url': personId+'/avatar'+str(randint(10000000000000,99999999999999))+'.png'},
|
||||||
'id': personId,
|
'id': personId,
|
||||||
'image': {'mediaType': 'image/png',
|
'image': {'mediaType': 'image/png',
|
||||||
'type': 'Image',
|
'type': 'Image',
|
||||||
'url': personId+'/image.png'},
|
'url': personId+'/image'+str(randint(10000000000000,99999999999999))+'.png'},
|
||||||
'inbox': inboxStr,
|
'inbox': inboxStr,
|
||||||
'manuallyApprovesFollowers': approveFollowers,
|
'manuallyApprovesFollowers': approveFollowers,
|
||||||
'name': personName,
|
'name': personName,
|
||||||
|
|
Loading…
Reference in New Issue