Configuration parameter for enabling cw lists

main
Bob Mottram 2021-10-21 14:36:40 +01:00
parent a6381f5c50
commit b91c6282c7
3 changed files with 6 additions and 3 deletions

View File

@ -876,7 +876,7 @@ def brochModeLapses(baseDir: str, lapseDays: int = 7) -> bool:
return False
def loadCWLists(baseDir: str, verbose: bool) -> {}:
def loadCWLists(baseDir: str, verbose: bool, listsEnabled: str) -> {}:
"""Load lists used for content warnings
"""
if not os.path.isdir(baseDir + '/cwlists'):
@ -893,6 +893,8 @@ def loadCWLists(baseDir: str, verbose: bool) -> {}:
continue
if not listJson.get('name'):
continue
if listJson['name'] not in listsEnabled:
continue
if not listJson.get('words') and not listJson.get('domains'):
continue
name = listJson['name']

View File

@ -17199,7 +17199,8 @@ def runDaemon(defaultReplyIntervalHours: int,
updateBlockedCache(baseDir, httpd.blockedCache,
httpd.blockedCacheLastUpdated,
httpd.blockedCacheUpdateSecs)
httpd.CWlists = loadCWLists(baseDir, True)
httpd.listsEnabled = getConfigParam(baseDir, "listsEnabled")
httpd.CWlists = loadCWLists(baseDir, True, httpd.listsEnabled)
# cache to store css files
httpd.cssCache = {}

View File

@ -5769,7 +5769,7 @@ def _testWordsSimilarity() -> None:
def _testAddCWfromLists(baseDir: str) -> None:
print('testAddCWfromLists')
translate = {}
CWlists = loadCWLists(baseDir, True)
CWlists = loadCWLists(baseDir, True, "Murdoch press")
assert CWlists
postJsonObject = {