From a392322149c50eab87700705670642882dc7ea70 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Thu, 15 Aug 2024 21:35:57 +0200 Subject: [PATCH] Continued: - let also process.block() abort when an unwanted block_level is provided - alias also "reject" to "rejected" --- fba/helpers/processing.py | 2 ++ fba/models/blocks.py | 3 +++ 2 files changed, 5 insertions(+) diff --git a/fba/helpers/processing.py b/fba/helpers/processing.py index 04954d2..464eded 100644 --- a/fba/helpers/processing.py +++ b/fba/helpers/processing.py @@ -97,6 +97,8 @@ def block(blocker: str, blocked: str, reason: str, block_level: str) -> bool: raise ValueError(f"Parameter block_level[]='{type(block_level)}' is not of type 'str'") elif block_level == "": raise ValueError("Parameter block_level is empty") + elif block_level in ["reject", "suspend", "accept", "silence", "nsfw", "quarantined_instances"]: + raise ValueError(f"Parameter block_level='{block_level}' is not supported") elif blacklist.is_blacklisted(blocker): raise ValueError(f"blocker='{blocker}' is blacklisted but function was invoked") elif blacklist.is_blacklisted(blocked): diff --git a/fba/models/blocks.py b/fba/models/blocks.py index c27bad3..1ebe3ea 100644 --- a/fba/models/blocks.py +++ b/fba/models/blocks.py @@ -263,6 +263,9 @@ def alias_block_level(block_level: str) -> str: elif block_level == "suspend": logger.debug("Block level 'suspend' has been changed to 'suspended'") block_level = "suspended" + elif block_level == "reject": + logger.debug("Block level 'reject' has been changed to 'rejected'") + block_level = "rejected" elif block_level == "nsfw": logger.debug("Block level 'nsfw' has been changed to 'media_nsfw'") block_level = "media_nsfw" -- 2.39.5