Add domain-wide blacklist and whitelist functionality

This commit is contained in:
Joakim Hellsén 2026-04-12 23:51:05 +02:00
commit bdbd46ebd4
Signed by: Joakim Hellsén
SSH key fingerprint: SHA256:/9h/CsExpFp+PRhsfA0xznFx2CGfTT5R/kpuFfUgEQk
14 changed files with 930 additions and 305 deletions

View file

@ -173,9 +173,11 @@ def test_export_state_creates_state_json(tmp_path: Path) -> None:
tag: str | None = None,
default: str | None = None,
) -> list[Any] | str | None:
if feed_or_key == () and tag is None:
# Called for global webhooks list
return []
if feed_or_key == () and tag == "domain_blacklist":
return {"example.com": {"blacklist_title": "spoiler"}}
if feed_or_key == () and tag == "domain_whitelist":
return {"example.com": {"whitelist_title": "release"}}
if tag == "webhook":
return "https://discord.com/api/webhooks/123/abc"
@ -194,6 +196,8 @@ def test_export_state_creates_state_json(tmp_path: Path) -> None:
data: dict[str, Any] = json.loads(state_file.read_text(encoding="utf-8"))
assert "feeds" in data
assert "webhooks" in data
assert data["domain_blacklist"]["example.com"]["blacklist_title"] == "spoiler"
assert data["domain_whitelist"]["example.com"]["whitelist_title"] == "release"
assert data["feeds"][0]["url"] == "https://example.com/feed.rss"
assert data["feeds"][0]["webhook"] == "https://discord.com/api/webhooks/123/abc"