From f4fdedba87111cd22a3780b9597497643842cba6 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Mon, 15 Feb 2021 22:42:16 +0000 Subject: [PATCH] Include both following and follower domains within broch --- blocking.py | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/blocking.py b/blocking.py index d2ddfd89e..7e81776de 100644 --- a/blocking.py +++ b/blocking.py @@ -380,6 +380,7 @@ def setBrochMode(baseDir: str, domainFull: str, enabled: bool) -> None: else: # generate instance allow list allowedDomains = [domainFull] + followFiles = ('following.txt', 'followers.txt') for subdir, dirs, files in os.walk(baseDir + '/accounts'): for acct in dirs: if '@' not in acct: @@ -387,18 +388,19 @@ def setBrochMode(baseDir: str, domainFull: str, enabled: bool) -> None: if 'inbox@' in acct or 'news@' in acct: continue accountDir = os.path.join(baseDir + '/accounts', acct) - followingFilename = accountDir + '/following.txt' - if not os.path.isfile(followingFilename): - continue - with open(followingFilename, "r") as f: - followList = f.readlines() - for handle in followList: - if '@' not in handle: - continue - handle = handle.replace('\n', '') - handleDomain = handle.split('@')[1] - if handleDomain not in allowedDomains: - allowedDomains.append(handleDomain) + for followFileType in followFiles: + followingFilename = accountDir + '/' + followFileType + if not os.path.isfile(followingFilename): + continue + with open(followingFilename, "r") as f: + followList = f.readlines() + for handle in followList: + if '@' not in handle: + continue + handle = handle.replace('\n', '') + handleDomain = handle.split('@')[1] + if handleDomain not in allowedDomains: + allowedDomains.append(handleDomain) break # write the allow file