Check that posts don't contain replies from blocked domains

master
Bob Mottram 2019-09-01 20:52:14 +01:00
parent b9d853ef63
commit 9aa4837775
2 changed files with 13 additions and 0 deletions

View File

@ -116,6 +116,11 @@ def isBlocked(baseDir: str,nickname: str,domain: str, \
blockNickname: str,blockDomain: str) -> bool:
"""Is the given nickname blocked?
"""
# https://www.youtube.com/watch?v=5qw1hcevmdU
evilDomains=['gab.com','gabfed.com','spinster.xyz']
for concentratedEvil in evilDomains:
if blockDomain.endswith(concentratedEvil):
return True
globalBlockingFilename=baseDir+'/accounts/blocking.txt'
if os.path.isfile(globalBlockingFilename):
if '*@'+blockDomain in open(globalBlockingFilename).read():

View File

@ -208,6 +208,14 @@ def savePostToInboxQueue(baseDir: str,httpPrefix: str, \
if postJsonObject.get('object'):
if isinstance(postJsonObject['object'], dict):
if postJsonObject['object'].get('inReplyTo'):
if isinstance(postJsonObject['object']['inReplyTo'], str):
replyNickname=getNicknameFromActor(postJsonObject['object']['inReplyTo'])
replyDomain,replyPort=getDomainFromActor(postJsonObject['object']['inReplyTo'])
if replyNickname and replyDomain:
if isBlocked(baseDir,nickname,domain,postNickname,postDomain):
print('WARN: post contains reply from a blocked domain: '+replyDomain)
return None
if postJsonObject['object'].get('content'):
if isinstance(postJsonObject['object']['content'], str):
if isFiltered(baseDir,nickname,domain,postJsonObject['object']['content']):