Added helper error if the remote URL

doesn't return a valid CSV blocklist.
Updated sample config to use valid raw github URL.
This commit is contained in:
Justin Warren 2022-12-20 10:20:20 +11:00
parent 96a48ec633
commit ea58d34c14
No known key found for this signature in database
2 changed files with 6 additions and 2 deletions

View File

@ -319,7 +319,11 @@ def save_blocklist_to_file(blocklist: list[dict], filepath: str):
@param blocklist: A dictionary of block definitions, keyed by domain
@param filepath: The path to the file the list should be saved in.
"""
blocklist = sorted(blocklist, key=lambda x: x['domain'])
try:
blocklist = sorted(blocklist, key=lambda x: x['domain'])
except KeyError:
log.error("Field 'domain' not found in blocklist. Are you sure the URLs are correct?")
log.debug(f"blocklist is: {blocklist}")
fieldnames = ['domain', 'severity', 'private_comment', 'public_comment', 'reject_media', 'reject_reports', 'obfuscate']
with open(filepath, "w") as fp:

View File

@ -8,7 +8,7 @@ blocklist_instance_sources = [
# List of URLs to read csv blocklists from
blocklist_url_sources = [
'file:///etc/fediblockhole/blocklist-01.csv',
'https://github.com/fediblockhole/samples/demo-blocklist-01.csv',
'https://raw.githubusercontent.com/eigenmagic/fediblockhole/main/samples/demo-blocklist-01.csv',
]
# List of instances to write blocklist to