Check for blocked domains

main2
Bob Mottram 2019-10-17 14:18:21 +01:00
parent c0361bd5bf
commit 335a35b84e
1 changed files with 12 additions and 8 deletions

View File

@ -39,10 +39,10 @@ from capabilities import capabilitiesReceiveUpdate
from like import updateLikesCollection from like import updateLikesCollection
from like import undoLikesCollectionEntry from like import undoLikesCollectionEntry
from blocking import isBlocked from blocking import isBlocked
from blocking import isBlockedDomain
from filters import isFiltered from filters import isFiltered
from announce import updateAnnounceCollection from announce import updateAnnounceCollection
from httpsig import messageContentDigest from httpsig import messageContentDigest
from blocking import isBlockedDomain
from posts import downloadAnnounce from posts import downloadAnnounce
from posts import isDM from posts import isDM
from posts import isReply from posts import isReply
@ -214,8 +214,12 @@ def savePostToInboxQueue(baseDir: str,httpPrefix: str, \
if isinstance(postJsonObject['object'], dict): if isinstance(postJsonObject['object'], dict):
if postJsonObject['object'].get('inReplyTo'): if postJsonObject['object'].get('inReplyTo'):
if isinstance(postJsonObject['object']['inReplyTo'], str): if isinstance(postJsonObject['object']['inReplyTo'], str):
replyNickname=getNicknameFromActor(postJsonObject['object']['inReplyTo'])
replyDomain,replyPort=getDomainFromActor(postJsonObject['object']['inReplyTo']) replyDomain,replyPort=getDomainFromActor(postJsonObject['object']['inReplyTo'])
if isBlockedDomain(baseDir,replyDomain):
print('WARN: post contains reply to a blocked domain: '+replyDomain)
return None
else:
replyNickname=getNicknameFromActor(postJsonObject['object']['inReplyTo'])
if replyNickname and replyDomain: if replyNickname and replyDomain:
if isBlocked(baseDir,nickname,domain,replyNickname,replyDomain): if isBlocked(baseDir,nickname,domain,replyNickname,replyDomain):
print('WARN: post contains reply to a blocked account: '+replyNickname+'@'+replyDomain) print('WARN: post contains reply to a blocked account: '+replyNickname+'@'+replyDomain)