Replies to muted posts are also muted

main
Bob Mottram 2020-08-27 18:40:09 +01:00
parent 7db274b57a
commit cabdc9c3c5
2 changed files with 30 additions and 3 deletions

View File

@ -55,6 +55,7 @@ from posts import validContentWarning
from posts import downloadAnnounce from posts import downloadAnnounce
from posts import isDM from posts import isDM
from posts import isReply from posts import isReply
from posts import isMuted
from posts import isImageMedia from posts import isImageMedia
from posts import sendSignedJson from posts import sendSignedJson
from posts import sendToFollowersThread from posts import sendToFollowersThread
@ -2302,6 +2303,8 @@ def inboxAfterCapabilities(recentPostsCache: {}, maxRecentPosts: int,
postJsonObject, debug, postJsonObject, debug,
__version__) __version__)
isReplyToMutedPost = False
if not isGroup: if not isGroup:
# create a DM notification file if needed # create a DM notification file if needed
postIsDM = isDM(postJsonObject) postIsDM = isDM(postJsonObject)
@ -2352,9 +2355,13 @@ def inboxAfterCapabilities(recentPostsCache: {}, maxRecentPosts: int,
if nickname != 'inbox': if nickname != 'inbox':
# replies index will be updated # replies index will be updated
updateIndexList.append('tlreplies') updateIndexList.append('tlreplies')
replyNotify(baseDir, handle, if not isMuted(baseDir, nickname, domain,
httpPrefix + '://' + domain + postJsonObject['object']['inReplyTo']):
'/users/' + nickname + '/tlreplies') replyNotify(baseDir, handle,
httpPrefix + '://' + domain +
'/users/' + nickname + '/tlreplies')
else:
isReplyToMutedPost = True
if isImageMedia(session, baseDir, httpPrefix, if isImageMedia(session, baseDir, httpPrefix,
nickname, domain, postJsonObject, nickname, domain, postJsonObject,
@ -2375,6 +2382,15 @@ def inboxAfterCapabilities(recentPostsCache: {}, maxRecentPosts: int,
# save the post to file # save the post to file
if saveJson(postJsonObject, destinationFilename): if saveJson(postJsonObject, destinationFilename):
# If this is a reply to a muted post then also mute it.
# This enables you to ignore a threat that's getting boring
if isReplyToMutedPost:
print('MUTE REPLY: ' + destinationFilename)
muteFile = open(destinationFilename + '.muted', "w")
if muteFile:
muteFile.write('\n')
muteFile.close()
# update the indexes for different timelines # update the indexes for different timelines
for boxname in updateIndexList: for boxname in updateIndexList:
if not inboxUpdateIndex(boxname, baseDir, handle, if not inboxUpdateIndex(boxname, baseDir, handle,

View File

@ -3509,6 +3509,17 @@ def downloadAnnounce(session, baseDir: str, httpPrefix: str,
return None return None
def isMuted(baseDir: str, nickname: str, domain: str, postId: str) -> bool:
"""Returns true if the given post is muted
"""
postFilename = locatePost(baseDir, nickname, domain, postId)
if not postFilename:
return False
if os.path.isfile(postFilename + '.muted'):
return True
return False
def mutePost(baseDir: str, nickname: str, domain: str, postId: str, def mutePost(baseDir: str, nickname: str, domain: str, postId: str,
recentPostsCache: {}) -> None: recentPostsCache: {}) -> None:
""" Mutes the given post """ Mutes the given post