mirror of https://gitlab.com/bashrc2/epicyon
Setting ignores on announces
parent
a317e69d31
commit
450a9faf57
123
blocking.py
123
blocking.py
|
@ -472,45 +472,47 @@ def mutePost(baseDir: str, nickname: str, domain: str, port: int,
|
||||||
return
|
return
|
||||||
print('mutePost: ' + str(postJsonObject))
|
print('mutePost: ' + str(postJsonObject))
|
||||||
|
|
||||||
|
postJsonObj = postJsonObject
|
||||||
if hasObjectDict(postJsonObject):
|
if hasObjectDict(postJsonObject):
|
||||||
domainFull = getFullDomain(domain, port)
|
postJsonObj = postJsonObject['object']
|
||||||
actor = localActorUrl(httpPrefix, nickname, domainFull)
|
domainFull = getFullDomain(domain, port)
|
||||||
|
actor = localActorUrl(httpPrefix, nickname, domainFull)
|
||||||
|
|
||||||
if postJsonObject['object'].get('conversation'):
|
if postJsonObj.get('conversation'):
|
||||||
muteConversation(baseDir, nickname, domain,
|
muteConversation(baseDir, nickname, domain,
|
||||||
postJsonObject['object']['conversation'])
|
postJsonObj['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 postJsonObj.get('ignores'):
|
||||||
if debug:
|
if debug:
|
||||||
print('DEBUG: Adding initial mute to ' + postId)
|
print('DEBUG: Adding initial mute to ' + postId)
|
||||||
ignoresJson = {
|
ignoresJson = {
|
||||||
"@context": "https://www.w3.org/ns/activitystreams",
|
"@context": "https://www.w3.org/ns/activitystreams",
|
||||||
'id': postId,
|
'id': postId,
|
||||||
'type': 'Collection',
|
'type': 'Collection',
|
||||||
"totalItems": 1,
|
"totalItems": 1,
|
||||||
'items': [{
|
'items': [{
|
||||||
'type': 'Ignore',
|
|
||||||
'actor': actor
|
|
||||||
}]
|
|
||||||
}
|
|
||||||
postJsonObject['object']['ignores'] = ignoresJson
|
|
||||||
else:
|
|
||||||
if not postJsonObject['object']['ignores'].get('items'):
|
|
||||||
postJsonObject['object']['ignores']['items'] = []
|
|
||||||
itemsList = postJsonObject['object']['ignores']['items']
|
|
||||||
for ignoresItem in itemsList:
|
|
||||||
if ignoresItem.get('actor'):
|
|
||||||
if ignoresItem['actor'] == actor:
|
|
||||||
return
|
|
||||||
newIgnore = {
|
|
||||||
'type': 'Ignore',
|
'type': 'Ignore',
|
||||||
'actor': actor
|
'actor': actor
|
||||||
}
|
}]
|
||||||
igIt = len(itemsList)
|
}
|
||||||
itemsList.append(newIgnore)
|
postJsonObj['ignores'] = ignoresJson
|
||||||
postJsonObject['object']['ignores']['totalItems'] = igIt
|
else:
|
||||||
saveJson(postJsonObject, postFilename)
|
if not postJsonObj['ignores'].get('items'):
|
||||||
|
postJsonObj['ignores']['items'] = []
|
||||||
|
itemsList = postJsonObj['ignores']['items']
|
||||||
|
for ignoresItem in itemsList:
|
||||||
|
if ignoresItem.get('actor'):
|
||||||
|
if ignoresItem['actor'] == actor:
|
||||||
|
return
|
||||||
|
newIgnore = {
|
||||||
|
'type': 'Ignore',
|
||||||
|
'actor': actor
|
||||||
|
}
|
||||||
|
igIt = len(itemsList)
|
||||||
|
itemsList.append(newIgnore)
|
||||||
|
postJsonObj['ignores']['totalItems'] = igIt
|
||||||
|
saveJson(postJsonObject, postFilename)
|
||||||
|
|
||||||
# remove cached post so that the muted version gets recreated
|
# remove cached post so that the muted version gets recreated
|
||||||
# without its content text and/or image
|
# without its content text and/or image
|
||||||
|
@ -564,34 +566,35 @@ def unmutePost(baseDir: str, nickname: str, domain: str, port: int,
|
||||||
pass
|
pass
|
||||||
print('UNMUTE: ' + muteFilename + ' file removed')
|
print('UNMUTE: ' + muteFilename + ' file removed')
|
||||||
|
|
||||||
|
postJsonObj = postJsonObject
|
||||||
if hasObjectDict(postJsonObject):
|
if hasObjectDict(postJsonObject):
|
||||||
if postJsonObject['object'].get('conversation'):
|
postJsonObj = postJsonObject['object']
|
||||||
unmuteConversation(baseDir, nickname, domain,
|
if postJsonObj.get('conversation'):
|
||||||
postJsonObject['object']['conversation'])
|
unmuteConversation(baseDir, nickname, domain,
|
||||||
|
postJsonObj['conversation'])
|
||||||
|
|
||||||
if postJsonObject['object'].get('ignores'):
|
if postJsonObj.get('ignores'):
|
||||||
domainFull = getFullDomain(domain, port)
|
domainFull = getFullDomain(domain, port)
|
||||||
actor = localActorUrl(httpPrefix, nickname, domainFull)
|
actor = localActorUrl(httpPrefix, nickname, domainFull)
|
||||||
totalItems = 0
|
totalItems = 0
|
||||||
if postJsonObject['object']['ignores'].get('totalItems'):
|
if postJsonObj['ignores'].get('totalItems'):
|
||||||
totalItems = \
|
totalItems = postJsonObj['ignores']['totalItems']
|
||||||
postJsonObject['object']['ignores']['totalItems']
|
itemsList = postJsonObj['ignores']['items']
|
||||||
itemsList = postJsonObject['object']['ignores']['items']
|
for ignoresItem in itemsList:
|
||||||
for ignoresItem in itemsList:
|
if ignoresItem.get('actor'):
|
||||||
if ignoresItem.get('actor'):
|
if ignoresItem['actor'] == actor:
|
||||||
if ignoresItem['actor'] == actor:
|
if debug:
|
||||||
if debug:
|
print('DEBUG: mute was removed for ' + actor)
|
||||||
print('DEBUG: mute was removed for ' + actor)
|
itemsList.remove(ignoresItem)
|
||||||
itemsList.remove(ignoresItem)
|
break
|
||||||
break
|
if totalItems == 1:
|
||||||
if totalItems == 1:
|
if debug:
|
||||||
if debug:
|
print('DEBUG: mute was removed from post')
|
||||||
print('DEBUG: mute was removed from post')
|
del postJsonObj['ignores']
|
||||||
del postJsonObject['object']['ignores']
|
else:
|
||||||
else:
|
igItLen = len(postJsonObj['ignores']['items'])
|
||||||
igItLen = len(postJsonObject['object']['ignores']['items'])
|
postJsonObj['ignores']['totalItems'] = igItLen
|
||||||
postJsonObject['object']['ignores']['totalItems'] = igItLen
|
saveJson(postJsonObject, postFilename)
|
||||||
saveJson(postJsonObject, postFilename)
|
|
||||||
|
|
||||||
# remove cached post so that the muted version gets recreated
|
# remove cached post so that the muted version gets recreated
|
||||||
# with its content text and/or image
|
# with its content text and/or image
|
||||||
|
|
Loading…
Reference in New Issue