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:
parent
96a48ec633
commit
ea58d34c14
|
@ -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 blocklist: A dictionary of block definitions, keyed by domain
|
||||||
@param filepath: The path to the file the list should be saved in.
|
@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']
|
fieldnames = ['domain', 'severity', 'private_comment', 'public_comment', 'reject_media', 'reject_reports', 'obfuscate']
|
||||||
with open(filepath, "w") as fp:
|
with open(filepath, "w") as fp:
|
||||||
|
|
|
@ -8,7 +8,7 @@ blocklist_instance_sources = [
|
||||||
# List of URLs to read csv blocklists from
|
# List of URLs to read csv blocklists from
|
||||||
blocklist_url_sources = [
|
blocklist_url_sources = [
|
||||||
'file:///etc/fediblockhole/blocklist-01.csv',
|
'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
|
# List of instances to write blocklist to
|
||||||
|
|
Loading…
Reference in New Issue