Enabled lists set from commandline

merge-requests/30/head
Bob Mottram 2021-10-21 15:06:25 +01:00
parent 142a68a97c
commit 0c0cbf9485
3 changed files with 27 additions and 7 deletions

View File

@ -16864,7 +16864,8 @@ def loadTokens(baseDir: str, tokensDict: {}, tokensLookup: {}) -> None:
break break
def runDaemon(defaultReplyIntervalHours: int, def runDaemon(listsEnabled: str,
defaultReplyIntervalHours: int,
lowBandwidth: bool, lowBandwidth: bool,
maxLikeCount: int, maxLikeCount: int,
sharedItemsFederatedDomains: [], sharedItemsFederatedDomains: [],
@ -17219,7 +17220,10 @@ def runDaemon(defaultReplyIntervalHours: int,
createNewsInbox(baseDir, domain, port, httpPrefix) createNewsInbox(baseDir, domain, port, httpPrefix)
setConfigParam(baseDir, "listsEnabled", "Murdoch press") setConfigParam(baseDir, "listsEnabled", "Murdoch press")
httpd.listsEnabled = getConfigParam(baseDir, "listsEnabled") if listsEnabled:
httpd.listsEnabled = listsEnabled
else:
httpd.listsEnabled = getConfigParam(baseDir, "listsEnabled")
httpd.CWlists = loadCWLists(baseDir, True, httpd.listsEnabled) httpd.CWlists = loadCWLists(baseDir, True, httpd.listsEnabled)
# set the avatar for the news account # set the avatar for the news account

View File

@ -112,6 +112,10 @@ def str2bool(v) -> bool:
parser = argparse.ArgumentParser(description='ActivityPub Server') parser = argparse.ArgumentParser(description='ActivityPub Server')
parser.add_argument('--listsEnabled', type=str,
default=None,
help='Names of content warning lists enabled. ' +
'See the cwlists directory')
parser.add_argument('--userAgentBlocks', type=str, parser.add_argument('--userAgentBlocks', type=str,
default=None, default=None,
help='List of blocked user agents, separated by commas') help='List of blocked user agents, separated by commas')
@ -3011,6 +3015,13 @@ if userAgentsBlockedStr:
for agentBlockStr in agentBlocksList: for agentBlockStr in agentBlocksList:
userAgentsBlocked.append(agentBlockStr.strip()) userAgentsBlocked.append(agentBlockStr.strip())
listsEnabled = ''
if args.listsEnabled:
listsEnabled = args.listsEnabled
setConfigParam(baseDir, 'listsEnabled', listsEnabled)
else:
listsEnabled = getConfigParam(baseDir, 'listsEnabled')
city = \ city = \
getConfigParam(baseDir, 'city') getConfigParam(baseDir, 'city')
if city is not None: if city is not None:
@ -3064,7 +3075,8 @@ if args.defaultCurrency:
print('Default currency set to ' + args.defaultCurrency) print('Default currency set to ' + args.defaultCurrency)
if __name__ == "__main__": if __name__ == "__main__":
runDaemon(args.defaultReplyIntervalHours, runDaemon(listsEnabled,
args.defaultReplyIntervalHours,
args.lowBandwidth, args.maxLikeCount, args.lowBandwidth, args.maxLikeCount,
sharedItemsFederatedDomains, sharedItemsFederatedDomains,
userAgentsBlocked, userAgentsBlocked,

View File

@ -817,8 +817,9 @@ def createServerAlice(path: str, domain: str, port: int,
userAgentsBlocked = [] userAgentsBlocked = []
maxLikeCount = 10 maxLikeCount = 10
defaultReplyIntervalHours = 9999999999 defaultReplyIntervalHours = 9999999999
listsEnabled = ''
print('Server running: Alice') print('Server running: Alice')
runDaemon(defaultReplyIntervalHours, runDaemon(listsEnabled, defaultReplyIntervalHours,
lowBandwidth, maxLikeCount, lowBandwidth, maxLikeCount,
sharedItemsFederatedDomains, sharedItemsFederatedDomains,
userAgentsBlocked, userAgentsBlocked,
@ -955,8 +956,9 @@ def createServerBob(path: str, domain: str, port: int,
userAgentsBlocked = [] userAgentsBlocked = []
maxLikeCount = 10 maxLikeCount = 10
defaultReplyIntervalHours = 9999999999 defaultReplyIntervalHours = 9999999999
listsEnabled = ''
print('Server running: Bob') print('Server running: Bob')
runDaemon(defaultReplyIntervalHours, runDaemon(listsEnabled, defaultReplyIntervalHours,
lowBandwidth, maxLikeCount, lowBandwidth, maxLikeCount,
sharedItemsFederatedDomains, sharedItemsFederatedDomains,
userAgentsBlocked, userAgentsBlocked,
@ -1022,8 +1024,9 @@ def createServerEve(path: str, domain: str, port: int, federationList: [],
maxLikeCount = 10 maxLikeCount = 10
lowBandwidth = True lowBandwidth = True
defaultReplyIntervalHours = 9999999999 defaultReplyIntervalHours = 9999999999
listsEnabled = ''
print('Server running: Eve') print('Server running: Eve')
runDaemon(defaultReplyIntervalHours, runDaemon(listsEnabled, defaultReplyIntervalHours,
lowBandwidth, maxLikeCount, lowBandwidth, maxLikeCount,
sharedItemsFederatedDomains, sharedItemsFederatedDomains,
userAgentsBlocked, userAgentsBlocked,
@ -1091,8 +1094,9 @@ def createServerGroup(path: str, domain: str, port: int,
maxLikeCount = 10 maxLikeCount = 10
lowBandwidth = True lowBandwidth = True
defaultReplyIntervalHours = 9999999999 defaultReplyIntervalHours = 9999999999
listsEnabled = ''
print('Server running: Group') print('Server running: Group')
runDaemon(defaultReplyIntervalHours, runDaemon(listsEnabled, defaultReplyIntervalHours,
lowBandwidth, maxLikeCount, lowBandwidth, maxLikeCount,
sharedItemsFederatedDomains, sharedItemsFederatedDomains,
userAgentsBlocked, userAgentsBlocked,