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 getDomainFromActor
|
||||||
from utils import getNicknameFromActor
|
from utils import getNicknameFromActor
|
||||||
from utils import acctDir
|
from utils import acctDir
|
||||||
|
from conversation import muteConversation
|
||||||
|
from conversation import unmuteConversation
|
||||||
|
|
||||||
|
|
||||||
def addGlobalBlock(baseDir: str,
|
def addGlobalBlock(baseDir: str,
|
||||||
|
@ -468,6 +470,11 @@ def mutePost(baseDir: str, nickname: str, domain: str, port: int,
|
||||||
if hasObjectDict(postJsonObject):
|
if hasObjectDict(postJsonObject):
|
||||||
domainFull = getFullDomain(domain, port)
|
domainFull = getFullDomain(domain, port)
|
||||||
actor = httpPrefix + '://' + domainFull + '/users/' + nickname
|
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?
|
# does this post have ignores on it from differenent actors?
|
||||||
if not postJsonObject['object'].get('ignores'):
|
if not postJsonObject['object'].get('ignores'):
|
||||||
if debug:
|
if debug:
|
||||||
|
@ -546,6 +553,10 @@ def unmutePost(baseDir: str, nickname: str, domain: str, port: int,
|
||||||
print('UNMUTE: ' + muteFilename + ' file removed')
|
print('UNMUTE: ' + muteFilename + ' file removed')
|
||||||
|
|
||||||
if hasObjectDict(postJsonObject):
|
if hasObjectDict(postJsonObject):
|
||||||
|
if postJsonObject['object'].get('conversation'):
|
||||||
|
unmuteConversation(baseDir, nickname, domain,
|
||||||
|
postJsonObject['object']['conversation'])
|
||||||
|
|
||||||
if postJsonObject['object'].get('ignores'):
|
if postJsonObject['object'].get('ignores'):
|
||||||
domainFull = getFullDomain(domain, port)
|
domainFull = getFullDomain(domain, port)
|
||||||
actor = httpPrefix + '://' + domainFull + '/users/' + nickname
|
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 isSelfAnnounce
|
||||||
from announce import createAnnounce
|
from announce import createAnnounce
|
||||||
from notifyOnPost import notifyWhenPersonPosts
|
from notifyOnPost import notifyWhenPersonPosts
|
||||||
|
from conversation import updateConversation
|
||||||
|
|
||||||
|
|
||||||
def storeHashTags(baseDir: str, nickname: str, postJsonObject: {}) -> None:
|
def storeHashTags(baseDir: str, nickname: str, postJsonObject: {}) -> None:
|
||||||
|
@ -2483,12 +2484,18 @@ def _inboxAfterInitial(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')
|
||||||
|
|
||||||
|
conversationId = None
|
||||||
|
if postJsonObject['object'].get('conversation'):
|
||||||
|
conversationId = \
|
||||||
|
postJsonObject['object']['conversation']
|
||||||
|
|
||||||
if postJsonObject['object'].get('inReplyTo'):
|
if postJsonObject['object'].get('inReplyTo'):
|
||||||
inReplyTo = postJsonObject['object']['inReplyTo']
|
inReplyTo = postJsonObject['object']['inReplyTo']
|
||||||
if inReplyTo:
|
if inReplyTo:
|
||||||
if isinstance(inReplyTo, str):
|
if isinstance(inReplyTo, str):
|
||||||
if not isMuted(baseDir, nickname, domain,
|
if not isMuted(baseDir, nickname, domain,
|
||||||
inReplyTo):
|
inReplyTo, conversationId):
|
||||||
_replyNotify(baseDir, handle,
|
_replyNotify(baseDir, handle,
|
||||||
httpPrefix + '://' + domain +
|
httpPrefix + '://' + domain +
|
||||||
'/users/' + nickname +
|
'/users/' + nickname +
|
||||||
|
@ -2585,9 +2592,11 @@ def _inboxAfterInitial(recentPostsCache: {}, maxRecentPosts: int,
|
||||||
' post as html to cache in ' +
|
' post as html to cache in ' +
|
||||||
timeDiff + ' mS')
|
timeDiff + ' mS')
|
||||||
|
|
||||||
|
handleName = handle.split('@')[0]
|
||||||
|
updateConversation(baseDir, handleName, domain, postJsonObject)
|
||||||
|
|
||||||
_inboxUpdateCalendar(baseDir, handle, postJsonObject)
|
_inboxUpdateCalendar(baseDir, handle, postJsonObject)
|
||||||
|
|
||||||
handleName = handle.split('@')[0]
|
|
||||||
storeHashTags(baseDir, handleName, postJsonObject)
|
storeHashTags(baseDir, handleName, postJsonObject)
|
||||||
|
|
||||||
# send the post out to group members
|
# 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
|
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
|
"""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)
|
postFilename = locatePost(baseDir, nickname, domain, postId)
|
||||||
if not postFilename:
|
if not postFilename:
|
||||||
return False
|
return False
|
||||||
|
|
35
utils.py
35
utils.py
|
@ -1487,6 +1487,38 @@ def _deleteHashtagsOnPost(baseDir: str, postJsonObject: {}) -> None:
|
||||||
f.write(newlines)
|
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,
|
def deletePost(baseDir: str, httpPrefix: str,
|
||||||
nickname: str, domain: str, postFilename: str,
|
nickname: str, domain: str, postFilename: str,
|
||||||
debug: bool, recentPostsCache: {}) -> None:
|
debug: bool, recentPostsCache: {}) -> None:
|
||||||
|
@ -1514,6 +1546,9 @@ def deletePost(baseDir: str, httpPrefix: str,
|
||||||
# remove from recent posts cache in memory
|
# remove from recent posts cache in memory
|
||||||
removePostFromCache(postJsonObject, recentPostsCache)
|
removePostFromCache(postJsonObject, recentPostsCache)
|
||||||
|
|
||||||
|
# remove from conversation index
|
||||||
|
_deleteConversationPost(baseDir, nickname, domain, postJsonObject)
|
||||||
|
|
||||||
# remove any attachment
|
# remove any attachment
|
||||||
_removeAttachment(baseDir, httpPrefix, domain, postJsonObject)
|
_removeAttachment(baseDir, httpPrefix, domain, postJsonObject)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue