mirror of https://gitlab.com/bashrc2/epicyon
Option to set availability
parent
f5b926482e
commit
873b4953a7
12
epicyon.py
12
epicyon.py
|
@ -16,6 +16,7 @@ from person import validNickname
|
|||
from person import setProfileImage
|
||||
from person import setSkillLevel
|
||||
from person import setRole
|
||||
from person import setAvailability
|
||||
from webfinger import webfingerHandle
|
||||
from posts import getPosts
|
||||
from posts import createPublicPost
|
||||
|
@ -181,6 +182,8 @@ parser.add_argument('--skill', dest='skill', type=str,default=None, \
|
|||
help='Set a skill for a person')
|
||||
parser.add_argument('--level', dest='skillLevelPercent', type=int,default=None, \
|
||||
help='Set a skill level for a person as a percentage, or zero to remove')
|
||||
parser.add_argument('--status','--availability', dest='availability', type=str,default=None, \
|
||||
help='Set an availability status')
|
||||
args = parser.parse_args()
|
||||
|
||||
debug=False
|
||||
|
@ -536,6 +539,14 @@ if args.backgroundImage:
|
|||
print('Background image was not added for '+args.nickname)
|
||||
sys.exit()
|
||||
|
||||
if args.availability:
|
||||
if not nickname:
|
||||
print('No nickname given')
|
||||
sys.exit()
|
||||
if setAvailability(baseDir,nickname,domain,args.availability):
|
||||
print('Availablity set to '+args.availability)
|
||||
sys.exit()
|
||||
|
||||
if args.project:
|
||||
if not nickname:
|
||||
print('No nickname given')
|
||||
|
@ -584,6 +595,7 @@ if args.testdata:
|
|||
setRole(baseDir,nickname,domain,'epicyon','tester')
|
||||
setRole(baseDir,nickname,domain,'epicyon','hacker')
|
||||
setRole(baseDir,nickname,domain,'someproject','assistant')
|
||||
setAvailability(baseDir,nickname,domain,'busy')
|
||||
deleteAllPosts(baseDir,nickname,domain,'inbox')
|
||||
deleteAllPosts(baseDir,nickname,domain,'outbox')
|
||||
followPerson(baseDir,nickname,domain,'admin',domain,federationList,True)
|
||||
|
|
16
person.py
16
person.py
|
@ -137,6 +137,21 @@ def setRole(baseDir: str,nickname: str,domain: str, \
|
|||
commentjson.dump(actorJson, fp, indent=4, sort_keys=False)
|
||||
return True
|
||||
|
||||
def setAvailability(baseDir: str,nickname: str,domain: str, \
|
||||
status: str) -> bool:
|
||||
"""Set an availability status
|
||||
"""
|
||||
# avoid giant strings
|
||||
if len(status)>128:
|
||||
return False
|
||||
actorFilename=baseDir+'/accounts/'+nickname+'@'+domain+'.json'
|
||||
if not os.path.isfile(actorFilename):
|
||||
return False
|
||||
with open(actorFilename, 'r') as fp:
|
||||
actorJson=commentjson.load(fp)
|
||||
actorJson['availability']=status
|
||||
return True
|
||||
|
||||
def createPersonBase(baseDir: str,nickname: str,domain: str,port: int, \
|
||||
httpPrefix: str, saveToFile: bool,password=None) -> (str,str,{},{}):
|
||||
"""Returns the private key, public key, actor and webfinger endpoint
|
||||
|
@ -177,6 +192,7 @@ def createPersonBase(baseDir: str,nickname: str,domain: str,port: int, \
|
|||
'following': httpPrefix+'://'+domain+'/users/'+nickname+'/following',
|
||||
'skills': {},
|
||||
'roles': {},
|
||||
'availability': None,
|
||||
'icon': {'mediaType': 'image/png',
|
||||
'type': 'Image',
|
||||
'url': httpPrefix+'://'+domain+'/users/'+nickname+'/icon.png'},
|
||||
|
|
Loading…
Reference in New Issue