Set person bio

master
Bob Mottram 2019-06-28 21:00:25 +01:00
parent 7cd716ddab
commit 21a64bb21b
2 changed files with 23 additions and 1 deletions

View File

@ -8,6 +8,7 @@ __status__ = "Production"
from person import createPerson
from person import setPreferredUsername
from person import setBio
from webfinger import webfingerHandle
from posts import getUserPosts
from session import createSession
@ -29,6 +30,7 @@ session = createSession(useTor)
privateKeyPem,publicKeyPem,person,wfEndpoint=createPerson(username,domain,https,True)
setPreferredUsername(username,domain,'badger')
setBio(username,domain,'Some personal info')
runDaemon(domain,port,useTor)
#testHttpsig()

View File

@ -176,4 +176,24 @@ def setPreferredUsername(username: str, domain: str, preferredName: str) -> bool
with open(filename, 'w') as fp:
commentjson.dump(personJson, fp, indent=4, sort_keys=False)
return True
def setBio(username: str, domain: str, bio: str) -> bool:
if len(bio)>32:
return False
handle=username.lower()+'@'+domain.lower()
baseDir=os.getcwd()
filename=baseDir+'/accounts/'+handle.lower()+'.json'
if not os.path.isfile(filename):
return False
personJson=None
with open(filename, 'r') as fp:
personJson=commentjson.load(fp)
if not personJson:
return False
if not personJson.get('publicKey'):
return False
personJson['publicKey']['summary']=bio
with open(filename, 'w') as fp:
commentjson.dump(personJson, fp, indent=4, sort_keys=False)
return True