Check for index

main
Bob Mottram 2019-12-01 14:43:09 +00:00
parent f3af1bb68d
commit 4d3dab83ae
1 changed files with 16 additions and 14 deletions

View File

@ -2663,13 +2663,14 @@ def mutePost(baseDir: str,nickname: str,domain: str,postId: str, \
os.remove(cachedPostFilename) os.remove(cachedPostFilename)
# if the post is in the recent posts cache then mark it as muted # if the post is in the recent posts cache then mark it as muted
postId=postJsonObject['id'].replace('/activity','').replace('/','#') if recentPostsCache.get('index'):
if postId in recentPostsCache['index']: postId=postJsonObject['id'].replace('/activity','').replace('/','#')
print('MUTE: '+postId+' is in recent posts cache') if postId in recentPostsCache['index']:
if recentPostsCache['json'].get(postId): print('MUTE: '+postId+' is in recent posts cache')
postJsonObject['muted']=True if recentPostsCache['json'].get(postId):
recentPostsCache['json'][postId]=json.dumps(postJsonObject) postJsonObject['muted']=True
print('MUTE: '+postId+' marked as muted in recent posts cache') recentPostsCache['json'][postId]=json.dumps(postJsonObject)
print('MUTE: '+postId+' marked as muted in recent posts cache')
def unmutePost(baseDir: str,nickname: str,domain: str,postId: str, \ def unmutePost(baseDir: str,nickname: str,domain: str,postId: str, \
recentPostsCache: {}) -> None: recentPostsCache: {}) -> None:
@ -2694,10 +2695,11 @@ def unmutePost(baseDir: str,nickname: str,domain: str,postId: str, \
if os.path.isfile(cachedPostFilename): if os.path.isfile(cachedPostFilename):
os.remove(cachedPostFilename) os.remove(cachedPostFilename)
# if the post is in the recent posts cache then mark it as not muted # if the post is in the recent posts cache then mark it as not muted
postId=postJsonObject['id'].replace('/activity','').replace('/','#') if recentPostsCache.get('index'):
if postId in recentPostsCache['index']: postId=postJsonObject['id'].replace('/activity','').replace('/','#')
print('UNMUTE: '+postId+' is in recent posts cache') if postId in recentPostsCache['index']:
if recentPostsCache['json'].get(postId): print('UNMUTE: '+postId+' is in recent posts cache')
postJsonObject['muted']=False if recentPostsCache['json'].get(postId):
recentPostsCache['json'][postId]=json.dumps(postJsonObject) postJsonObject['muted']=False
print('UNMUTE: '+postId+' marked as not muted in recent posts cache') recentPostsCache['json'][postId]=json.dumps(postJsonObject)
print('UNMUTE: '+postId+' marked as not muted in recent posts cache')