Include both following and follower domains within broch

merge-requests/30/head
Bob Mottram 2021-02-15 22:42:16 +00:00
parent 6b55ceab12
commit f4fdedba87
1 changed files with 14 additions and 12 deletions

View File

@ -380,6 +380,7 @@ def setBrochMode(baseDir: str, domainFull: str, enabled: bool) -> None:
else: else:
# generate instance allow list # generate instance allow list
allowedDomains = [domainFull] allowedDomains = [domainFull]
followFiles = ('following.txt', 'followers.txt')
for subdir, dirs, files in os.walk(baseDir + '/accounts'): for subdir, dirs, files in os.walk(baseDir + '/accounts'):
for acct in dirs: for acct in dirs:
if '@' not in acct: 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: if 'inbox@' in acct or 'news@' in acct:
continue continue
accountDir = os.path.join(baseDir + '/accounts', acct) accountDir = os.path.join(baseDir + '/accounts', acct)
followingFilename = accountDir + '/following.txt' for followFileType in followFiles:
if not os.path.isfile(followingFilename): followingFilename = accountDir + '/' + followFileType
continue if not os.path.isfile(followingFilename):
with open(followingFilename, "r") as f: continue
followList = f.readlines() with open(followingFilename, "r") as f:
for handle in followList: followList = f.readlines()
if '@' not in handle: for handle in followList:
continue if '@' not in handle:
handle = handle.replace('\n', '') continue
handleDomain = handle.split('@')[1] handle = handle.replace('\n', '')
if handleDomain not in allowedDomains: handleDomain = handle.split('@')[1]
allowedDomains.append(handleDomain) if handleDomain not in allowedDomains:
allowedDomains.append(handleDomain)
break break
# write the allow file # write the allow file