From d30d519d2247ddc2a5860caeccc2d63ee3d82b94 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Sun, 19 Jan 2020 20:29:39 +0000 Subject: [PATCH] Upgrade actor with nomadic locations --- person.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/person.py b/person.py index 1303969b..276d61c2 100644 --- a/person.py +++ b/person.py @@ -372,7 +372,21 @@ def createCapabilitiesInbox(baseDir: str,nickname: str,domain: str,port: int, \ """Generates the capabilities inbox to sign requests """ return createPersonBase(baseDir,nickname,domain,port,httpPrefix,True,None) - + +def personUpgradeActor(personJson: {},handle: str,filename: str) -> None: + """Alter the actor to add any new properties + """ + if not personJson.get('nomadicLocations'): + personJson['nomadicLocations']=[{ + 'id': personJson['id'], + 'type': 'nomadicLocation', + 'locationAddress':'acct:'+handle, + 'locationPrimary':True, + 'locationDeleted':False + }] + saveJson(personJson,filename) + print('Nomadic locations added to to actor '+handle) + def personLookup(domain: str,path: str,baseDir: str) -> {}: """Lookup the person for an given nickname """ @@ -407,6 +421,7 @@ def personLookup(domain: str,path: str,baseDir: str) -> {}: if not os.path.isfile(filename): return None personJson=loadJson(filename) + personUpgradeActor(personJson,handle,filename) #if not personJson: # personJson={"user": "unknown"} return personJson