Configuration parameter for enabling cw lists

merge-requests/30/head
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 return False
def loadCWLists(baseDir: str, verbose: bool) -> {}: def loadCWLists(baseDir: str, verbose: bool, listsEnabled: str) -> {}:
"""Load lists used for content warnings """Load lists used for content warnings
""" """
if not os.path.isdir(baseDir + '/cwlists'): if not os.path.isdir(baseDir + '/cwlists'):
@ -893,6 +893,8 @@ def loadCWLists(baseDir: str, verbose: bool) -> {}:
continue continue
if not listJson.get('name'): if not listJson.get('name'):
continue continue
if listJson['name'] not in listsEnabled:
continue
if not listJson.get('words') and not listJson.get('domains'): if not listJson.get('words') and not listJson.get('domains'):
continue continue
name = listJson['name'] name = listJson['name']

View File

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

View File

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