From 0e7490a44b4f4f64fdfcd785419dd527461c45c8 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Mon, 5 Oct 2020 12:30:11 +0100 Subject: [PATCH] Don't include blogs from suspended accounts within newswire --- newswire.py | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/newswire.py b/newswire.py index 520878756..0944b108d 100644 --- a/newswire.py +++ b/newswire.py @@ -221,6 +221,7 @@ def addLocalBlogsToNewswire(baseDir: str, newswire: {}, maxBlogsPerAccount: int) -> None: """Adds blogs from this instance into the newswire """ + suspendedFilename = baseDir + '/accounts/suspended.txt' # go through each account for subdir, dirs, files in os.walk(baseDir + '/accounts'): for handle in dirs: @@ -229,10 +230,27 @@ def addLocalBlogsToNewswire(baseDir: str, newswire: {}, if 'inbox@' in handle: continue accountDir = os.path.join(baseDir + '/accounts', handle) + + # has this account been suspended? + nickname = handle.split('@')[0] + if os.path.isfile(suspendedFilename): + with open(suspendedFilename, "r") as f: + lines = f.readlines() + foundSuspended = False + for nick in lines: + if nick == nickname + '\n': + foundSuspended = True + break + if foundSuspended: + continue + + # has this account been blocked from posting to newswire? + if os.path.isfile(accountDir + '/.noblognewswire'): + continue + # is there a blogs timeline for this account? blogsIndex = accountDir + '/tlblogs.index' if os.path.isfile(blogsIndex): - nickname = handle.split('@')[0] domain = handle.split('@')[1] addAccountBlogsToNewswire(baseDir, nickname, domain, newswire, maxBlogsPerAccount,