mirror of https://gitlab.com/bashrc2/epicyon
Add muted parameter to recent posts cache
parent
7bbd67bc9d
commit
c125d4dc69
19
posts.py
19
posts.py
|
@ -2660,8 +2660,15 @@ def mutePost(baseDir: str,nickname: str,domain: str,postId: str, \
|
||||||
getCachedPostFilename(baseDir,nickname,domain,postJsonObject)
|
getCachedPostFilename(baseDir,nickname,domain,postJsonObject)
|
||||||
if cachedPostFilename:
|
if cachedPostFilename:
|
||||||
if os.path.isfile(cachedPostFilename):
|
if os.path.isfile(cachedPostFilename):
|
||||||
os.remove(cachedPostFilename)
|
os.remove(cachedPostFilename)
|
||||||
removePostFromCache(postJsonObject,recentPostsCache)
|
|
||||||
|
# if the post is in the recent posts cache then mark it as muted
|
||||||
|
postId=postJsonObject['id'].replace('/activity','').replace('/','#')
|
||||||
|
if postId in recentPostsCache['index']:
|
||||||
|
print('MUTE: '+postId+' is in recent posts cache')
|
||||||
|
if recentPostsCache['json'].get(postId):
|
||||||
|
recentPostsCache['json'][postId]['muted']=True
|
||||||
|
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:
|
||||||
|
@ -2685,4 +2692,10 @@ def unmutePost(baseDir: str,nickname: str,domain: str,postId: str, \
|
||||||
if cachedPostFilename:
|
if cachedPostFilename:
|
||||||
if os.path.isfile(cachedPostFilename):
|
if os.path.isfile(cachedPostFilename):
|
||||||
os.remove(cachedPostFilename)
|
os.remove(cachedPostFilename)
|
||||||
removePostFromCache(postJsonObject,recentPostsCache)
|
# if the post is in the recent posts cache then mark it as not muted
|
||||||
|
postId=postJsonObject['id'].replace('/activity','').replace('/','#')
|
||||||
|
if postId in recentPostsCache['index']:
|
||||||
|
print('UNMUTE: '+postId+' is in recent posts cache')
|
||||||
|
if recentPostsCache['json'].get(postId):
|
||||||
|
recentPostsCache['json'][postId]['muted']=False
|
||||||
|
print('UNMUTE: '+postId+' marked as not muted in recent posts cache')
|
||||||
|
|
|
@ -1995,20 +1995,19 @@ def preparePostFromHtmlCache(postHtml: str,boxName: str,pageNumber: int) -> str:
|
||||||
postHtml=postHtml.replace('?tl=inbox','?tl=tlbookmarks')
|
postHtml=postHtml.replace('?tl=inbox','?tl=tlbookmarks')
|
||||||
return postHtml.replace(';-999;',';'+str(pageNumber)+';').replace('?page=-999','?page='+str(pageNumber))
|
return postHtml.replace(';-999;',';'+str(pageNumber)+';').replace('?page=-999','?page='+str(pageNumber))
|
||||||
|
|
||||||
def postIsMuted(baseDir: str,nickname: str,domain: str, messageId: str) -> bool:
|
def postIsMuted(baseDir: str,nickname: str,domain: str, postJsonObject: {},messageId: str) -> bool:
|
||||||
""" Returns true if the given post is muted
|
""" Returns true if the given post is muted
|
||||||
"""
|
"""
|
||||||
|
if postJsonObject.get('muted'):
|
||||||
|
return True
|
||||||
postDir=baseDir+'/accounts/'+nickname+'@'+domain
|
postDir=baseDir+'/accounts/'+nickname+'@'+domain
|
||||||
muteFilename=postDir+'/inbox/'+messageId.replace('/','#')+'.json.muted'
|
muteFilename=postDir+'/inbox/'+messageId.replace('/','#')+'.json.muted'
|
||||||
print('TEST MUTE: '+muteFilename)
|
|
||||||
if os.path.isfile(muteFilename):
|
if os.path.isfile(muteFilename):
|
||||||
return True
|
return True
|
||||||
muteFilename=postDir+'/outbox/'+messageId.replace('/','#')+'.json.muted'
|
muteFilename=postDir+'/outbox/'+messageId.replace('/','#')+'.json.muted'
|
||||||
print('TEST MUTE: '+muteFilename)
|
|
||||||
if os.path.isfile(muteFilename):
|
if os.path.isfile(muteFilename):
|
||||||
return True
|
return True
|
||||||
muteFilename=baseDir+'/accounts/cache/announce/'+nickname+'/'+messageId.replace('/','#')+'.json.muted'
|
muteFilename=baseDir+'/accounts/cache/announce/'+nickname+'/'+messageId.replace('/','#')+'.json.muted'
|
||||||
print('TEST MUTE: '+muteFilename)
|
|
||||||
if os.path.isfile(muteFilename):
|
if os.path.isfile(muteFilename):
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
@ -2256,7 +2255,7 @@ def individualPostAsHtml(recentPostsCache: {},maxRecentPosts: int, \
|
||||||
'?tl='+boxName+'" title="'+bookmarkTitle+'">'
|
'?tl='+boxName+'" title="'+bookmarkTitle+'">'
|
||||||
bookmarkStr+='<img loading="lazy" title="'+bookmarkTitle+' |" alt="'+bookmarkTitle+' |" src="/'+iconsDir+'/'+bookmarkIcon+'"/></a>'
|
bookmarkStr+='<img loading="lazy" title="'+bookmarkTitle+' |" alt="'+bookmarkTitle+' |" src="/'+iconsDir+'/'+bookmarkIcon+'"/></a>'
|
||||||
|
|
||||||
isMuted=postIsMuted(baseDir,nickname,domain,messageId)
|
isMuted=postIsMuted(baseDir,nickname,domain,postJsonObject,messageId)
|
||||||
|
|
||||||
deleteStr=''
|
deleteStr=''
|
||||||
muteStr=''
|
muteStr=''
|
||||||
|
@ -2804,10 +2803,11 @@ def htmlTimeline(defaultTimeline: str, \
|
||||||
if boxName!='tlmedia' and recentPostsCache.get('index'):
|
if boxName!='tlmedia' and recentPostsCache.get('index'):
|
||||||
postId=item['id'].replace('/activity','').replace('/','#')
|
postId=item['id'].replace('/activity','').replace('/','#')
|
||||||
if postId in recentPostsCache['index']:
|
if postId in recentPostsCache['index']:
|
||||||
if recentPostsCache['html'].get(postId):
|
if not item.get('muted'):
|
||||||
currTlStr=recentPostsCache['html'][postId]
|
if recentPostsCache['html'].get(postId):
|
||||||
currTlStr= \
|
currTlStr=recentPostsCache['html'][postId]
|
||||||
preparePostFromHtmlCache(currTlStr,boxName,pageNumber)
|
currTlStr= \
|
||||||
|
preparePostFromHtmlCache(currTlStr,boxName,pageNumber)
|
||||||
if not currTlStr:
|
if not currTlStr:
|
||||||
# read the post from disk
|
# read the post from disk
|
||||||
currTlStr= \
|
currTlStr= \
|
||||||
|
|
Loading…
Reference in New Issue