mirror of https://gitlab.com/bashrc2/epicyon
Muting by conversation ID
parent
78fba638c3
commit
2a163cafd0
11
blocking.py
11
blocking.py
|
@ -28,6 +28,8 @@ from utils import evilIncarnate
|
|||
from utils import getDomainFromActor
|
||||
from utils import getNicknameFromActor
|
||||
from utils import acctDir
|
||||
from conversation import muteConversation
|
||||
from conversation import unmuteConversation
|
||||
|
||||
|
||||
def addGlobalBlock(baseDir: str,
|
||||
|
@ -468,6 +470,11 @@ def mutePost(baseDir: str, nickname: str, domain: str, port: int,
|
|||
if hasObjectDict(postJsonObject):
|
||||
domainFull = getFullDomain(domain, port)
|
||||
actor = httpPrefix + '://' + domainFull + '/users/' + nickname
|
||||
|
||||
if postJsonObject['object'].get('conversation'):
|
||||
muteConversation(baseDir, nickname, domain,
|
||||
postJsonObject['object']['conversation'])
|
||||
|
||||
# does this post have ignores on it from differenent actors?
|
||||
if not postJsonObject['object'].get('ignores'):
|
||||
if debug:
|
||||
|
@ -546,6 +553,10 @@ def unmutePost(baseDir: str, nickname: str, domain: str, port: int,
|
|||
print('UNMUTE: ' + muteFilename + ' file removed')
|
||||
|
||||
if hasObjectDict(postJsonObject):
|
||||
if postJsonObject['object'].get('conversation'):
|
||||
unmuteConversation(baseDir, nickname, domain,
|
||||
postJsonObject['object']['conversation'])
|
||||
|
||||
if postJsonObject['object'].get('ignores'):
|
||||
domainFull = getFullDomain(domain, port)
|
||||
actor = httpPrefix + '://' + domainFull + '/users/' + nickname
|
||||
|
|
13
inbox.py
13
inbox.py
|
@ -91,6 +91,7 @@ from speaker import updateSpeaker
|
|||
from announce import isSelfAnnounce
|
||||
from announce import createAnnounce
|
||||
from notifyOnPost import notifyWhenPersonPosts
|
||||
from conversation import updateConversation
|
||||
|
||||
|
||||
def storeHashTags(baseDir: str, nickname: str, postJsonObject: {}) -> None:
|
||||
|
@ -2483,12 +2484,18 @@ def _inboxAfterInitial(recentPostsCache: {}, maxRecentPosts: int,
|
|||
if nickname != 'inbox':
|
||||
# replies index will be updated
|
||||
updateIndexList.append('tlreplies')
|
||||
|
||||
conversationId = None
|
||||
if postJsonObject['object'].get('conversation'):
|
||||
conversationId = \
|
||||
postJsonObject['object']['conversation']
|
||||
|
||||
if postJsonObject['object'].get('inReplyTo'):
|
||||
inReplyTo = postJsonObject['object']['inReplyTo']
|
||||
if inReplyTo:
|
||||
if isinstance(inReplyTo, str):
|
||||
if not isMuted(baseDir, nickname, domain,
|
||||
inReplyTo):
|
||||
inReplyTo, conversationId):
|
||||
_replyNotify(baseDir, handle,
|
||||
httpPrefix + '://' + domain +
|
||||
'/users/' + nickname +
|
||||
|
@ -2585,9 +2592,11 @@ def _inboxAfterInitial(recentPostsCache: {}, maxRecentPosts: int,
|
|||
' post as html to cache in ' +
|
||||
timeDiff + ' mS')
|
||||
|
||||
handleName = handle.split('@')[0]
|
||||
updateConversation(baseDir, handleName, domain, postJsonObject)
|
||||
|
||||
_inboxUpdateCalendar(baseDir, handle, postJsonObject)
|
||||
|
||||
handleName = handle.split('@')[0]
|
||||
storeHashTags(baseDir, handleName, postJsonObject)
|
||||
|
||||
# send the post out to group members
|
||||
|
|
9
posts.py
9
posts.py
|
@ -4321,9 +4321,16 @@ def downloadAnnounce(session, baseDir: str, httpPrefix: str,
|
|||
return None
|
||||
|
||||
|
||||
def isMuted(baseDir: str, nickname: str, domain: str, postId: str) -> bool:
|
||||
def isMuted(baseDir: str, nickname: str, domain: str, postId: str,
|
||||
conversationId: str) -> bool:
|
||||
"""Returns true if the given post is muted
|
||||
"""
|
||||
if conversationId:
|
||||
convMutedFilename = \
|
||||
acctDir(baseDir, nickname, domain) + '/conversation/' + \
|
||||
conversationId.replace('/', '#') + '.muted'
|
||||
if os.path.isfile(convMutedFilename):
|
||||
return True
|
||||
postFilename = locatePost(baseDir, nickname, domain, postId)
|
||||
if not postFilename:
|
||||
return False
|
||||
|
|
35
utils.py
35
utils.py
|
@ -1487,6 +1487,38 @@ def _deleteHashtagsOnPost(baseDir: str, postJsonObject: {}) -> None:
|
|||
f.write(newlines)
|
||||
|
||||
|
||||
def _deleteConversationPost(baseDir: str, nickname: str, domain: str,
|
||||
postJsonObject: {}) -> None:
|
||||
"""Deletes a post from a conversation
|
||||
"""
|
||||
if not hasObjectDict(postJsonObject):
|
||||
return False
|
||||
if not postJsonObject['object'].get('conversation'):
|
||||
return False
|
||||
if not postJsonObject['object'].get('id'):
|
||||
return False
|
||||
conversationDir = acctDir(baseDir, nickname, domain) + '/conversation'
|
||||
conversationId = postJsonObject['object']['conversation']
|
||||
conversationId = conversationId.replace('/', '#')
|
||||
postId = postJsonObject['object']['id']
|
||||
conversationFilename = conversationDir + '/' + conversation
|
||||
if not os.path.isfile(conversationFilename):
|
||||
return False
|
||||
conversationStr = ''
|
||||
with open(conversationFilename, 'r') as fp:
|
||||
conversationStr = fp.read()
|
||||
if postId + '\n' not in conversationStr:
|
||||
return False
|
||||
conversationStr = conversationStr.replace(postId + '\n', '')
|
||||
if conversationStr:
|
||||
with open(conversationFilename, 'w+') as fp:
|
||||
fp.write(conversationStr)
|
||||
else:
|
||||
if os.path.isfile(conversationFilename + '.muted'):
|
||||
os.remove(conversationFilename + '.muted')
|
||||
os.remove(conversationFilename)
|
||||
|
||||
|
||||
def deletePost(baseDir: str, httpPrefix: str,
|
||||
nickname: str, domain: str, postFilename: str,
|
||||
debug: bool, recentPostsCache: {}) -> None:
|
||||
|
@ -1514,6 +1546,9 @@ def deletePost(baseDir: str, httpPrefix: str,
|
|||
# remove from recent posts cache in memory
|
||||
removePostFromCache(postJsonObject, recentPostsCache)
|
||||
|
||||
# remove from conversation index
|
||||
_deleteConversationPost(baseDir, nickname, domain, postJsonObject)
|
||||
|
||||
# remove any attachment
|
||||
_removeAttachment(baseDir, httpPrefix, domain, postJsonObject)
|
||||
|
||||
|
|
Loading…
Reference in New Issue