Fix actor upgrades

main
Bob Mottram 2021-05-08 18:13:46 +01:00
parent 8623be6939
commit 89a15fdc73
1 changed files with 13 additions and 4 deletions

View File

@ -35,6 +35,7 @@ from auth import storeBasicCredentials
from auth import removePassword from auth import removePassword
from roles import setRole from roles import setRole
from media import removeMetaData from media import removeMetaData
from utils import getStatusNumber
from utils import getFullDomain from utils import getFullDomain
from utils import validNickname from utils import validNickname
from utils import loadJson from utils import loadJson
@ -272,12 +273,14 @@ def _createPersonBase(baseDir: str, nickname: str, domain: str, port: int,
personId + '/avatar' + \ personId + '/avatar' + \
str(randint(10000000000000, 99999999999999)) + '.png' # nosec str(randint(10000000000000, 99999999999999)) + '.png' # nosec
statusNumber, published = getStatusNumber()
newPerson = { newPerson = {
'@context': [ '@context': [
'https://www.w3.org/ns/activitystreams', 'https://www.w3.org/ns/activitystreams',
'https://w3id.org/security/v1', 'https://w3id.org/security/v1',
getDefaultPersonContext() getDefaultPersonContext()
], ],
'published': published,
'alsoKnownAs': [], 'alsoKnownAs': [],
'attachment': [], 'attachment': [],
'devices': personId + '/collections/devices', 'devices': personId + '/collections/devices',
@ -563,11 +566,17 @@ def personUpgradeActor(baseDir: str, personJson: {},
if not personJson: if not personJson:
personJson = loadJson(filename) personJson = loadJson(filename)
if updateActor: # add a speaker endpoint
# add a speaker endpoint if not personJson.get('tts'):
if not personJson.get('tts'): personJson['tts'] = personJson['id'] + '/speaker'
personJson['tts'] = personJson['id'] + '/speaker' updateActor = True
if not personJson.get('published'):
statusNumber, published = getStatusNumber()
personJson['published'] = published
updateActor = True
if updateActor:
saveJson(personJson, filename) saveJson(personJson, filename)
# also update the actor within the cache # also update the actor within the cache