forked from indymedia/epicyon
When deleting a post also remove its replies
parent
20a5864a12
commit
3d6a363e6a
|
@ -17,6 +17,7 @@ from person import setProfileImage
|
||||||
from person import setSkillLevel
|
from person import setSkillLevel
|
||||||
from person import setRole
|
from person import setRole
|
||||||
from person import setAvailability
|
from person import setAvailability
|
||||||
|
from person import setOrganizationScheme
|
||||||
from webfinger import webfingerHandle
|
from webfinger import webfingerHandle
|
||||||
from posts import getPosts
|
from posts import getPosts
|
||||||
from posts import createPublicPost
|
from posts import createPublicPost
|
||||||
|
|
12
inbox.py
12
inbox.py
|
@ -534,6 +534,18 @@ def receiveDelete(session,handle: str,baseDir: str, \
|
||||||
print('DEBUG: delete post not found in inbox or outbox')
|
print('DEBUG: delete post not found in inbox or outbox')
|
||||||
print(messageJson['object'])
|
print(messageJson['object'])
|
||||||
return True
|
return True
|
||||||
|
repliesFilename=postFilename.replace('.json','.replies')
|
||||||
|
if os.path.isfile(repliesFilename):
|
||||||
|
if debug:
|
||||||
|
print('DEBUG: removing replies to '+postFilename)
|
||||||
|
with open(repliesFilename,'r') as f:
|
||||||
|
for replyId in f:
|
||||||
|
replyFile=locatePost(baseDir,handle.split('@')[0],handle.split('@')[1],replyId)
|
||||||
|
if replyFile:
|
||||||
|
if os.path.isfile(replyFile):
|
||||||
|
os.remove(replyFile)
|
||||||
|
# remove the replies file itself
|
||||||
|
os.remove(repliesFilename)
|
||||||
os.remove(postFilename)
|
os.remove(postFilename)
|
||||||
if debug:
|
if debug:
|
||||||
print('DEBUG: post deleted - '+postFilename)
|
print('DEBUG: post deleted - '+postFilename)
|
||||||
|
|
22
person.py
22
person.py
|
@ -137,6 +137,25 @@ def setRole(baseDir: str,nickname: str,domain: str, \
|
||||||
commentjson.dump(actorJson, fp, indent=4, sort_keys=False)
|
commentjson.dump(actorJson, fp, indent=4, sort_keys=False)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
def setOrganizationScheme(baseDir: str,nickname: str,domain: str, \
|
||||||
|
schema: str) -> bool:
|
||||||
|
"""Set the organization schema within which a person exists
|
||||||
|
This will define how roles, skills and availability are assembled
|
||||||
|
into organizations
|
||||||
|
"""
|
||||||
|
# avoid giant strings
|
||||||
|
if len(schema)>256:
|
||||||
|
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['orgSchema']=schema
|
||||||
|
with open(actorFilename, 'w') as fp:
|
||||||
|
commentjson.dump(actorJson, fp, indent=4, sort_keys=False)
|
||||||
|
return True
|
||||||
|
|
||||||
def setAvailability(baseDir: str,nickname: str,domain: str, \
|
def setAvailability(baseDir: str,nickname: str,domain: str, \
|
||||||
status: str) -> bool:
|
status: str) -> bool:
|
||||||
"""Set an availability status
|
"""Set an availability status
|
||||||
|
@ -150,6 +169,8 @@ def setAvailability(baseDir: str,nickname: str,domain: str, \
|
||||||
with open(actorFilename, 'r') as fp:
|
with open(actorFilename, 'r') as fp:
|
||||||
actorJson=commentjson.load(fp)
|
actorJson=commentjson.load(fp)
|
||||||
actorJson['availability']=status
|
actorJson['availability']=status
|
||||||
|
with open(actorFilename, 'w') as fp:
|
||||||
|
commentjson.dump(actorJson, fp, indent=4, sort_keys=False)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def createPersonBase(baseDir: str,nickname: str,domain: str,port: int, \
|
def createPersonBase(baseDir: str,nickname: str,domain: str,port: int, \
|
||||||
|
@ -190,6 +211,7 @@ def createPersonBase(baseDir: str,nickname: str,domain: str,port: int, \
|
||||||
'featured': httpPrefix+'://'+domain+'/users/'+nickname+'/collections/featured',
|
'featured': httpPrefix+'://'+domain+'/users/'+nickname+'/collections/featured',
|
||||||
'followers': httpPrefix+'://'+domain+'/users/'+nickname+'/followers',
|
'followers': httpPrefix+'://'+domain+'/users/'+nickname+'/followers',
|
||||||
'following': httpPrefix+'://'+domain+'/users/'+nickname+'/following',
|
'following': httpPrefix+'://'+domain+'/users/'+nickname+'/following',
|
||||||
|
'orgSchema': None,
|
||||||
'skills': {},
|
'skills': {},
|
||||||
'roles': {},
|
'roles': {},
|
||||||
'availability': None,
|
'availability': None,
|
||||||
|
|
Loading…
Reference in New Issue