Load cw lists at startup

merge-requests/30/head
Bob Mottram 2021-10-21 12:13:24 +01:00
parent 13d1224b35
commit b8c957eb38
2 changed files with 24 additions and 0 deletions

View File

@ -874,3 +874,25 @@ def brochModeLapses(baseDir: str, lapseDays: int = 7) -> bool:
print('Broch mode has elapsed')
return True
return False
def loadLists(baseDir: str, verbose: bool) -> {}:
"""Load lists used for blocking or warnings
"""
if not os.path.isdir(baseDir + '/lists'):
return {}
result = {}
for subdir, dirs, files in os.walk(baseDir + '/lists'):
for f in files:
if not f.endswith('.json'):
continue
listFilename = os.path.join(baseDir + '/lists', f)
listJson = loadJson(listFilename)
if not listJson:
continue
if listJson.get('name') and listJson.get('domains'):
name = listJson['name']
if verbose:
print('List: ' + name)
result[name] = listJson
return result

View File

@ -125,6 +125,7 @@ from media import replaceTwitter
from media import attachMedia
from media import pathIsVideo
from media import pathIsAudio
from blocking import loadLists
from blocking import updateBlockedCache
from blocking import mutePost
from blocking import unmutePost
@ -17164,6 +17165,7 @@ def runDaemon(defaultReplyIntervalHours: int,
updateBlockedCache(baseDir, httpd.blockedCache,
httpd.blockedCacheLastUpdated,
httpd.blockedCacheUpdateSecs)
httpd.lists = loadLists(baseDir, True)
# cache to store css files
httpd.cssCache = {}