From 228234a4daa72504bba8fea7ab19e1c3b34758e8 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Mon, 5 Oct 2020 19:21:12 +0100 Subject: [PATCH] Have a list of trusted handles permitted to post to the newswire --- newswire.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/newswire.py b/newswire.py index 0944b108..8ce9b48e 100644 --- a/newswire.py +++ b/newswire.py @@ -221,7 +221,16 @@ def addLocalBlogsToNewswire(baseDir: str, newswire: {}, maxBlogsPerAccount: int) -> None: """Adds blogs from this instance into the newswire """ + # get the list of handles who are trusted to post to the newswire + newswireTrusted = '' + newswireTrustedFilename = baseDir + '/accounts/newswiretrusted.txt' + if os.path.isfile(newswireTrustedFilename): + with open(newswireTrustedFilename, 'r+') as trustFile: + newswireTrusted = trustFile.read() + + # file containing suspended account nicknames suspendedFilename = baseDir + '/accounts/suspended.txt' + # go through each account for subdir, dirs, files in os.walk(baseDir + '/accounts'): for handle in dirs: @@ -229,6 +238,8 @@ def addLocalBlogsToNewswire(baseDir: str, newswire: {}, continue if 'inbox@' in handle: continue + if handle not in newswireTrusted: + continue accountDir = os.path.join(baseDir + '/accounts', handle) # has this account been suspended? @@ -244,10 +255,6 @@ def addLocalBlogsToNewswire(baseDir: str, newswire: {}, 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):