Fix removals from moderation index

main
Bob Mottram 2019-11-16 22:09:54 +00:00
parent cb97b5ceb2
commit 26d561d4d7
2 changed files with 34 additions and 31 deletions

View File

@ -1001,31 +1001,31 @@ def createReportPost(baseDir: str,
postCc=None
postJsonObject=None
for toUrl in postTo:
postJsonObject= \
createPostBase(baseDir,nickname, domain, port, \
toUrl,postCc, \
httpPrefix, content, followersOnly, saveToFile, \
clientToServer, \
attachImageFilename,mediaType, \
imageDescription,useBlurhash, \
True,None, None, subject, \
None,None,None)
if not postJsonObject:
continue
# who is this report going to?
toNickname=toUrl.split('/users/')[1]
handle=toNickname+'@'+domain
postJsonObject= \
createPostBase(baseDir,nickname,domain,port, \
toUrl,postCc, \
httpPrefix,content,followersOnly,saveToFile, \
clientToServer, \
attachImageFilename,mediaType, \
imageDescription,useBlurhash, \
True,None,None,subject, \
None,None,None)
if not postJsonObject:
continue
# update the inbox index with the report filename
indexFilename=baseDir+'/accounts/'+handle+'/inbox.index'
indexEntry=postJsonObject['id'].replace('/activity','').replace('/','#')+'.json'
if indexEntry not in open(indexFilename).read():
try:
with open(indexFilename, 'a+') as fp:
fp.write(indexEntry)
except:
pass
#indexFilename=baseDir+'/accounts/'+handle+'/inbox.index'
#indexEntry=postJsonObject['id'].replace('/activity','').replace('/','#')+'.json'
#if indexEntry not in open(indexFilename).read():
# try:
# with open(indexFilename, 'a+') as fp:
# fp.write(indexEntry)
# except:
# pass
# save a notification file so that the moderator
# knows something new has appeared

View File

@ -315,18 +315,21 @@ def deletePost(baseDir: str,httpPrefix: str,nickname: str,domain: str,postFilena
# remove any attachment
removeAttachment(baseDir,httpPrefix,domain,postJsonObject)
hasObject=False
if postJsonObject.get('object'):
hasObject=True
# remove from moderation index file
if postJsonObject.get('moderationStatus'):
if postJsonObject.get('object'):
if isinstance(postJsonObject['object'], dict):
if postJsonObject['object'].get('id'):
postId=postJsonObject['object']['id'].replace('/activity','')
removeModerationPostFromIndex(baseDir,postId,debug)
if hasObject:
if postJsonObject['object'].get('moderationStatus'):
if postJsonObject.get('id'):
postId=postJsonObject['id'].replace('/activity','')
removeModerationPostFromIndex(baseDir,postId,debug)
# remove any hashtags index entries
removeHashtagIndex=False
if postJsonObject.get('object'):
if isinstance(postJsonObject['object'], dict):
if hasObject:
if hasObject and isinstance(postJsonObject['object'], dict):
if postJsonObject['object'].get('content'):
if '#' in postJsonObject['object']['content']:
removeHashtagIndex=True