mirror of https://gitlab.com/bashrc2/epicyon
Set person bio
parent
7cd716ddab
commit
21a64bb21b
|
@ -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()
|
||||
|
|
22
person.py
22
person.py
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in New Issue