From 4c356b2fe9074c8fe96fbafd5737224c817f2fe3 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Mon, 25 May 2020 10:21:34 +0100 Subject: [PATCH] Check for blocked actors within arriving announce posts --- inbox.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/inbox.py b/inbox.py index 1874a1b2e..fa2692064 100644 --- a/inbox.py +++ b/inbox.py @@ -1356,6 +1356,8 @@ def receiveAnnounce(recentPostsCache: {}, '"users", "channel" or "profile" missing in ' + messageJson['type']) return False + + # is the domain of the announce actor blocked? objectDomain = \ messageJson['object'].replace('https://', '') objectDomain = objectDomain.replace('http://', '') @@ -1370,9 +1372,18 @@ def receiveAnnounce(recentPostsCache: {}, return False if not os.path.isdir(baseDir + '/accounts/' + handle): print('DEBUG: unknown recipient of announce - ' + handle) - # is this post in the outbox of the person? + + # is the announce actor blocked? nickname = handle.split('@')[0] - postFilename = locatePost(baseDir, nickname, handle.split('@')[1], + actorNickname = getNicknameFromActor(messageJson['actor']) + actorDomain, actorPort = getDomainFromActor(messageJson['actor']) + if isBlocked(baseDir, nickname, domain, actorNickname, actorDomain): + print('Receive announce blocked for actor: ' + + actorNickname + '@' + actorDomain) + return False + + # is this post in the outbox of the person? + postFilename = locatePost(baseDir, nickname, domain, messageJson['object']) if not postFilename: if debug: