From 335a35b84ea221f4509e5b9d7fae14287fb7e3bc Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Thu, 17 Oct 2019 14:18:21 +0100 Subject: [PATCH] Check for blocked domains --- inbox.py | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/inbox.py b/inbox.py index 251b26346..62d263de3 100644 --- a/inbox.py +++ b/inbox.py @@ -39,10 +39,10 @@ from capabilities import capabilitiesReceiveUpdate from like import updateLikesCollection from like import undoLikesCollectionEntry from blocking import isBlocked +from blocking import isBlockedDomain from filters import isFiltered from announce import updateAnnounceCollection from httpsig import messageContentDigest -from blocking import isBlockedDomain from posts import downloadAnnounce from posts import isDM from posts import isReply @@ -214,15 +214,19 @@ def savePostToInboxQueue(baseDir: str,httpPrefix: str, \ 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,replyNickname,replyDomain): - print('WARN: post contains reply to a blocked account: '+replyNickname+'@'+replyDomain) - return None - else: - print('WARN: post is a reply to an unidentified account: '+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 isBlocked(baseDir,nickname,domain,replyNickname,replyDomain): + print('WARN: post contains reply to a blocked account: '+replyNickname+'@'+replyDomain) + return None + else: + print('WARN: post is a reply to an unidentified account: '+postJsonObject['object']['inReplyTo']) + return None if postJsonObject['object'].get('content'): if isinstance(postJsonObject['object']['content'], str): if isFiltered(baseDir,nickname,domain,postJsonObject['object']['content']):