forked from indymedia/epicyon
Fix removals from moderation index
parent
cb97b5ceb2
commit
26d561d4d7
24
posts.py
24
posts.py
|
@ -1001,6 +1001,10 @@ def createReportPost(baseDir: str,
|
||||||
postCc=None
|
postCc=None
|
||||||
postJsonObject=None
|
postJsonObject=None
|
||||||
for toUrl in postTo:
|
for toUrl in postTo:
|
||||||
|
# who is this report going to?
|
||||||
|
toNickname=toUrl.split('/users/')[1]
|
||||||
|
handle=toNickname+'@'+domain
|
||||||
|
|
||||||
postJsonObject= \
|
postJsonObject= \
|
||||||
createPostBase(baseDir,nickname,domain,port, \
|
createPostBase(baseDir,nickname,domain,port, \
|
||||||
toUrl,postCc, \
|
toUrl,postCc, \
|
||||||
|
@ -1013,19 +1017,15 @@ def createReportPost(baseDir: str,
|
||||||
if not postJsonObject:
|
if not postJsonObject:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# who is this report going to?
|
|
||||||
toNickname=toUrl.split('/users/')[1]
|
|
||||||
handle=toNickname+'@'+domain
|
|
||||||
|
|
||||||
# update the inbox index with the report filename
|
# update the inbox index with the report filename
|
||||||
indexFilename=baseDir+'/accounts/'+handle+'/inbox.index'
|
#indexFilename=baseDir+'/accounts/'+handle+'/inbox.index'
|
||||||
indexEntry=postJsonObject['id'].replace('/activity','').replace('/','#')+'.json'
|
#indexEntry=postJsonObject['id'].replace('/activity','').replace('/','#')+'.json'
|
||||||
if indexEntry not in open(indexFilename).read():
|
#if indexEntry not in open(indexFilename).read():
|
||||||
try:
|
# try:
|
||||||
with open(indexFilename, 'a+') as fp:
|
# with open(indexFilename, 'a+') as fp:
|
||||||
fp.write(indexEntry)
|
# fp.write(indexEntry)
|
||||||
except:
|
# except:
|
||||||
pass
|
# pass
|
||||||
|
|
||||||
# save a notification file so that the moderator
|
# save a notification file so that the moderator
|
||||||
# knows something new has appeared
|
# knows something new has appeared
|
||||||
|
|
17
utils.py
17
utils.py
|
@ -315,18 +315,21 @@ def deletePost(baseDir: str,httpPrefix: str,nickname: str,domain: str,postFilena
|
||||||
# remove any attachment
|
# remove any attachment
|
||||||
removeAttachment(baseDir,httpPrefix,domain,postJsonObject)
|
removeAttachment(baseDir,httpPrefix,domain,postJsonObject)
|
||||||
|
|
||||||
# remove from moderation index file
|
hasObject=False
|
||||||
if postJsonObject.get('moderationStatus'):
|
|
||||||
if postJsonObject.get('object'):
|
if postJsonObject.get('object'):
|
||||||
if isinstance(postJsonObject['object'], dict):
|
hasObject=True
|
||||||
if postJsonObject['object'].get('id'):
|
|
||||||
postId=postJsonObject['object']['id'].replace('/activity','')
|
# remove from moderation index file
|
||||||
|
if hasObject:
|
||||||
|
if postJsonObject['object'].get('moderationStatus'):
|
||||||
|
if postJsonObject.get('id'):
|
||||||
|
postId=postJsonObject['id'].replace('/activity','')
|
||||||
removeModerationPostFromIndex(baseDir,postId,debug)
|
removeModerationPostFromIndex(baseDir,postId,debug)
|
||||||
|
|
||||||
# remove any hashtags index entries
|
# remove any hashtags index entries
|
||||||
removeHashtagIndex=False
|
removeHashtagIndex=False
|
||||||
if postJsonObject.get('object'):
|
if hasObject:
|
||||||
if isinstance(postJsonObject['object'], dict):
|
if hasObject and isinstance(postJsonObject['object'], dict):
|
||||||
if postJsonObject['object'].get('content'):
|
if postJsonObject['object'].get('content'):
|
||||||
if '#' in postJsonObject['object']['content']:
|
if '#' in postJsonObject['object']['content']:
|
||||||
removeHashtagIndex=True
|
removeHashtagIndex=True
|
||||||
|
|
Loading…
Reference in New Issue