]> git.mxchange.org Git - fba.git/commitdiff
Continued:
authorRoland Häder <roland@mxchange.org>
Tue, 13 Aug 2024 21:22:01 +0000 (23:22 +0200)
committerRoland Häder <roland@mxchange.org>
Tue, 13 Aug 2024 21:22:50 +0000 (23:22 +0200)
- script is rejecting "reject" now in favor of "rejected" as there is
  "suspended" and "silenced" (past) already around
- Please run `$ sqlite3 blocks.db "UPDATE blocks SET block_level = 'rejected' WHERE block_level = 'reject';"`

fba/commands.py
fba/helpers/processing.py
fba/models/blocks.py
fba/networks/friendica.py
fba/networks/lemmy.py
fba/networks/mastodon.py
fba/networks/misskey.py
fba/networks/pleroma.py

index 153f45d288e059d3c2d91314890e652c2bf0f82b..7c96e6ea28afd3fd8d310f1a6b220dd8977cd4a6 100644 (file)
@@ -461,7 +461,7 @@ def fetch_blocks(args: argparse.Namespace) -> int:
             block["block_level"] = blocks.alias_block_level(block["block_level"])
             logger.debug("block[block_level]='%s' - AFTER!", block["block_level"])
 
-            if processing.block(blocker, block["blocked"], block["reason"], block["block_level"]) and block["block_level"] in ["reject", "suspend"] and config.get("bot_enabled"):
+            if processing.block(blocker, block["blocked"], block["reason"], block["block_level"]) and block["block_level"] in ["rejected", "suspended"] and config.get("bot_enabled"):
                 logger.debug("Appending block[blocked]'%s',reason='%s' for blocker='%s' ...", block["blocked"], block["block_level"], blocker)
                 blockdict.append({
                     "blocked": block["blocked"],
@@ -631,7 +631,7 @@ def fetch_todon_wiki(args: argparse.Namespace) -> int:
 
     blocklist = {
         "silenced": list(),
-        "reject": list(),
+        "rejected": list(),
     }
 
     logger.debug("Fetching domainblocks from source_domain='%s'", source_domain)
@@ -651,9 +651,9 @@ def fetch_todon_wiki(args: argparse.Namespace) -> int:
 
     suspended = doc.find("h3", {"id": "suspended_servers"}).find_next("ul").findAll("li")
     logger.info("Checking %d suspended entries ...", len(suspended))
-    blocklist["reject"] = utils.find_domains(suspended, "div")
+    blocklist["rejected"] = utils.find_domains(suspended, "div")
 
-    blocking = blocklist["silenced"] + blocklist["reject"]
+    blocking = blocklist["silenced"] + blocklist["rejected"]
     blocker = "todon.eu"
 
     logger.debug("Invoking instances.set_total_blocks(%s, %d) ...", blocker, len(blocking))
@@ -687,7 +687,7 @@ def fetch_todon_wiki(args: argparse.Namespace) -> int:
 
 
             logger.info("Adding new block: blocked='%s',block_level='%s'", blocked, block_level)
-            if processing.block(blocker, blocked, None, block_level) and block_level == "reject" and config.get("bot_enabled"):
+            if processing.block(blocker, blocked, None, block_level) and block_level in ["suspended", "rejected"] and config.get("bot_enabled"):
                 logger.debug("Appending blocked='%s',reason='%s' for blocker='%s' ...", blocked, block_level, blocker)
                 blockdict.append({
                     "blocked": blocked,
@@ -738,7 +738,7 @@ def fetch_cs(args: argparse.Namespace):
 
     blocklist = {
         "silenced": list(),
-        "reject"  : list(),
+        "rejected": list(),
     }
 
     source_domain = "raw.githubusercontent.com"
@@ -766,16 +766,16 @@ def fetch_cs(args: argparse.Namespace):
 
     blocked = doc.find("h2", {"id": "blocked-instances"}).findNext("table").find("tbody")
     logger.debug("blocked[%s]()=%d", type(blocked), len(blocked))
-    blocklist["reject"] = federation.find_domains(blocked)
+    blocklist["rejected"] = federation.find_domains(blocked)
 
-    blocking = blocklist["silenced"] + blocklist["reject"]
+    blocking = blocklist["silenced"] + blocklist["rejected"]
     blocker = "chaos.social"
 
     logger.debug("Invoking instances.set_total_blocks(%s, %d) ...", blocker, len(blocking))
     instances.set_last_blocked(blocker)
     instances.set_total_blocks(blocker, blocking)
 
-    logger.debug("blocklist[silenced]()=%d,blocklist[reject]()=%d", len(blocklist["silenced"]), len(blocklist["reject"]))
+    logger.debug("blocklist[silenced]()=%d,blocklist[reject]()=%d", len(blocklist["silenced"]), len(blocklist["rejected"]))
     if len(blocking) > 0:
         blockdict = list()
         for block_level in blocklist:
@@ -794,7 +794,7 @@ def fetch_cs(args: argparse.Namespace):
                         logger.warning("Exception '%s' during fetching instances (fetch_cs) from row[domain]='%s'", type(exception), row["domain"])
                         instances.set_last_error(row["domain"], exception)
 
-                if processing.block(blocker, row["domain"], row["reason"], block_level) and block_level == "reject" and config.get("bot_enabled"):
+                if processing.block(blocker, row["domain"], row["reason"], block_level) and block_level in ["suspended", "rejected"] and config.get("bot_enabled"):
                     logger.debug("Appending blocked='%s',reason='%s' for blocker='%s' ...", row["domain"], block_level, blocker)
                     blockdict.append({
                         "blocked": row["domain"],
@@ -1456,7 +1456,7 @@ def recheck_obfuscation(args: argparse.Namespace) -> int:
                 block["block_level"] = blocks.alias_block_level(block["block_level"])
 
                 logger.info("blocked='%s' has been deobfuscated to blocked='%s', adding ...", block["blocked"], blocked)
-                if processing.block(row["domain"], blocked, block["reason"], block["block_level"]) and block["block_level"] == "reject" and config.get("bot_enabled"):
+                if processing.block(row["domain"], blocked, block["reason"], block["block_level"]) and block["block_level"] in ["suspended", "rejected"] and config.get("bot_enabled"):
                     logger.debug("Appending blocked='%s',reason='%s' for blocker='%s' ...", block["blocked"], block["block_level"], row["domain"])
                     blockdict.append({
                         "blocked": blocked,
index 8fd5d8134d875806dba90f00432b33a4009222fc..04954d2beffd644c5f4f3f21f778666c4a10d66d 100644 (file)
@@ -180,7 +180,7 @@ def csv_block(blocker: str, url: str, command: str):
             severity = blocks.alias_block_level(row["severity"])
         else:
             logger.debug("row='%s' does not contain severity column, setting 'reject'", row)
-            severity = "reject"
+            severity = "rejected"
 
         if "reason" in row:
             reason = tidyup.reason(row["reason"]) if row["reason"] not in [None, ""] else None
index 0c4f32c0d9f402bfb724503b51085f065b31bfc4..c27bad3b0a01501960db42433fc7699bea6b8ee3 100644 (file)
@@ -36,7 +36,7 @@ def get_reason(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", "quarantined_instances"]:
+    elif block_level in ["accept", "reject", "suspend", "silence", "nsfw", "quarantined_instances"]:
         raise ValueError(f"block_level='{block_level}' is not wanted.")
     elif blacklist.is_blacklisted(blocker):
         raise Exception(f"blocker='{blocker}' is blacklisted but function invoked")
@@ -71,7 +71,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", "quarantined_instances"]:
+    elif block_level in ["accept", "reject", "suspend", "silence", "nsfw", "quarantined_instances"]:
         raise ValueError(f"block_level='{block_level}' is not wanted.")
     elif blacklist.is_blacklisted(blocker):
         raise Exception(f"blocker='{blocker}' is blacklisted but function invoked")
@@ -102,7 +102,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", "quarantined_instances"]:
+    elif block_level in ["accept", "reject", "suspend", "silence", "nsfw", "quarantined_instances"]:
         raise ValueError(f"blocked='{blocked}' has unwanted block_level='{block_level}'")
     elif blacklist.is_blacklisted(blocker):
         raise Exception(f"blocker='{blocker}' is blacklisted but function invoked")
@@ -131,7 +131,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", "quarantined_instances"]:
+    elif block_level in ["accept", "reject", "suspend", "silence", "nsfw", "quarantined_instances"]:
         raise ValueError(f"blocked='{blocked}' has unwanted block_level='{block_level}'")
     elif blacklist.is_blacklisted(blocker):
         raise Exception(f"blocker='{blocker}' is blacklisted but function invoked")
@@ -170,7 +170,7 @@ def add(blocker: str, blocked: str, reason: 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", "quarantined_instances"]:
+    elif block_level in ["accept", "reject", "suspend", "silence", "nsfw", "quarantined_instances"]:
         raise ValueError(f"blocked='{blocked}' has unwanted block_level='{block_level}'")
     elif blacklist.is_blacklisted(blocker):
         raise Exception(f"blocker='{blocker}' is blacklisted but function invoked")
index 05efa9a575b55fe570098bf6b5ac296a8a955062..47a247555374b3c4d48d001575db76ef0e3d20c5 100644 (file)
@@ -104,7 +104,7 @@ def fetch_blocks(domain: str) -> list:
             "blocker"    : domain,
             "blocked"    : blocked,
             "reason"     : reason,
-            "block_level": "reject",
+            "block_level": "rejected",
         })
 
     logger.debug("blocklist()=%d - EXIT!", len(blocklist))
index 8a9712de347f8fcb0751af0589b72936429190dc..d16bf6c4c01481c461f85377d0486a3f7ef03d06 100644 (file)
@@ -201,7 +201,7 @@ def fetch_blocks(domain: str) -> list:
                         "blocker"    : domain,
                         "blocked"    : blocked,
                         "reason"     : None,
-                        "block_level": "reject",
+                        "block_level": "rejected",
                     })
 
                 logger.debug("blocklist()=%d - EXIT!", len(blocklist))
@@ -226,7 +226,7 @@ def fetch_blocks(domain: str) -> list:
                     "blocker"    : domain,
                     "blocked"    : blocked,
                     "reason"     : None,
-                    "block_level": "reject",
+                    "block_level": "rejected",
                 })
         else:
             logger.warning("Cannot fetch /instances due to error: response.ok='%s',response.status_code=%d,response.details='%s'", response.ok, response.status_code, response.reason)
index b379ae078651ec83204f71b4ae807c175434e4b1..4f2af7b1dec75da92283262d00c2dde34d8da552 100644 (file)
@@ -152,7 +152,7 @@ def fetch_blocks_from_about(domain: str) -> dict:
 
     logger.debug("Returning blocklist for domain='%s' - EXIT!", domain)
     return {
-        "reject"        : blocklist["Suspended servers"],
+        "rejected"      : blocklist["Suspended servers"],
         "media_removal" : blocklist["Filtered media"],
         "followers_only": blocklist["Limited servers"] + blocklist["Silenced servers"],
     }
index e7c7053c78b988ec0d6f8da31328d86129277433..5d71e5894bf0a909a943759332f07f4e55eb0a97 100644 (file)
@@ -313,7 +313,7 @@ def fetch_blocks(domain: str) -> list:
                         "blocker"    : domain,
                         "blocked"    : blocked,
                         "reason"     : None,
-                        "block_level": "reject",
+                        "block_level": "rejected",
                     })
 
             logger.debug("count=%d", count)
index 87c1049bcb7fdc5311204f02b91a9912b360f5d4..27956b306709c2e92dcdea323323410bc999ec38 100644 (file)
@@ -46,8 +46,8 @@ language_mapping = {
     "media_removal"    : "media_removal",
     "media force-set as sensitive": "media_nsfw",
     "nsfw"             : "media_nsfw",
-    "reject"           : "reject",
-    "suspended servers": "reject",
+    "reject"           : "rejected",
+    "suspended servers": "suspended",
     "silenced servers" : "silenced",
     "removal from \"the whole known network\" timeline": "federated_timeline_removal",
 }
@@ -328,7 +328,8 @@ def fetch_blocks_from_about(domain: str) -> dict:
             break
 
     blocklist = {
-        "reject"        : [],
+        "rejected"      : [],
+        "suspended"     : [],
         "filtered_media": [],
         "followers_only": [],
         "silenced"      : [],