From: Roland Häder Date: Tue, 11 Jul 2023 05:58:58 +0000 (+0200) Subject: Continued: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=f384904c74557de49ca7fddb0555821064a8bb13;p=fba.git Continued: - alias "quarantined_instances" to "quarantined", you may have to run `DELETE FROM blocks WHERE block_level='quarantined_instances';` - ... and: `UPDATE instances SET last_blocked = NULL WHERE software IS NOT NULL AND last_status_code = 200;` - ... to reset your database, then don't forget to execute ./fba.py fetch_blocks --- diff --git a/fba/models/blocks.py b/fba/models/blocks.py index cad0f6c..3a18152 100644 --- a/fba/models/blocks.py +++ b/fba/models/blocks.py @@ -47,7 +47,7 @@ def update_reason(reason: str, blocker: str, blocked: str, block_level: str): 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 ["accept", "suspend", "silence", "nsfw"]: + elif block_level in ["accept", "suspend", "silence", "nsfw", "quarantined_instances"]: raise ValueError(f"block_level='{block_level}' is not wanted.") logger.debug("Updating block reason='%s',blocker='%s',blocked='%s',block_level='%s'", reason, blocker, blocked, block_level) @@ -81,7 +81,7 @@ def update_last_seen(blocker: str, blocked: str, block_level: str): 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 ["accept", "suspend", "silence", "nsfw"]: + elif block_level in ["accept", "suspend", "silence", "nsfw", "quarantined_instances"]: raise ValueError(f"blocked='{blocked}' has unwanted block_level='{block_level}'") database.cursor.execute( @@ -113,7 +113,7 @@ def is_instance_blocked(blocker: str, blocked: str, block_level: str = None) -> 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 ["accept", "suspend", "silence", "nsfw"]: + elif block_level in ["accept", "suspend", "silence", "nsfw", "quarantined_instances"]: raise ValueError(f"blocked='{blocked}' has unwanted block_level='{block_level}'") if block_level is None: @@ -152,7 +152,7 @@ def add_instance(blocker: str, blocked: str, reason: str, block_level: str): raise Exception(f"blocker='{blocker}' is blacklisted but function invoked") elif blacklist.is_blacklisted(blocked): raise Exception(f"blocked='{blocked}' is blacklisted but function invoked") - elif block_level in ["accept", "suspend", "silence", "nsfw"]: + elif block_level in ["accept", "suspend", "silence", "nsfw", "quarantined_instances"]: raise ValueError(f"blocked='{blocked}' has unwanted block_level='{block_level}'") if reason is not None: diff --git a/fba/utils.py b/fba/utils.py index 6007635..756dc5b 100644 --- a/fba/utils.py +++ b/fba/utils.py @@ -270,6 +270,9 @@ def alias_block_level(block_level: str) -> str: elif block_level == "nsfw": logger.debug("Block level 'nsfw' has been changed to 'media_nsfw'") block_level = "media_nsfw" + elif block_level == "quarantined_instances": + logger.debug("Block level 'quarantined_instances' has been changed to 'quarantined'") + block_level = "quarantined" logger.debug("block_level='%s' - EXIT!", block_level) return block_level