]> git.mxchange.org Git - fba.git/commitdiff
Continued:
authorRoland Häder <roland@mxchange.org>
Sat, 17 Jun 2023 09:58:41 +0000 (11:58 +0200)
committerRoland Häder <roland@mxchange.org>
Sat, 17 Jun 2023 09:58:41 +0000 (11:58 +0200)
- ignore "accept" block level as that is whitelisting instances, not blocking them

fba/models/blocks.py
fba/networks/mastodon.py
fba/networks/pleroma.py

index 8b6c745b7b8a7fb904570d9c0465357c37d40ce1..b0b0fa8e1df6a6f59371ec732742212b36944b10 100644 (file)
@@ -38,6 +38,8 @@ def update_reason(reason: str, blocker: str, blocked: str, block_level: str):
         raise ValueError(f"Parameter block_level[]='{type(block_level)}' is not 'str'")
     elif block_level == "":
         raise ValueError("Parameter 'block_level' is empty")
+    elif block_level == "accept";
+        raise ValueError("Accepted domains are not wanted here")
 
     # DEBUG: print("DEBUG: Updating block reason:", reason, blocker, blocked, block_level)
     try:
@@ -77,6 +79,8 @@ def update_last_seen(blocker: str, blocked: str, block_level: str):
         raise ValueError(f"Parameter block_level[]='{type(block_level)}' is not 'str'")
     elif block_level == "":
         raise ValueError("Parameter 'block_level' is empty")
+    elif block_level == "accept";
+        raise ValueError("Accepted domains are not wanted here")
 
     try:
         fba.cursor.execute(
@@ -114,6 +118,8 @@ def is_instance_blocked(blocker: str, blocked: 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 == "accept";
+        raise ValueError("Accepted domains are not wanted here")
 
     fba.cursor.execute(
         "SELECT * FROM blocks WHERE blocker = ? AND blocked = ? AND block_level = ? LIMIT 1",
@@ -151,6 +157,8 @@ 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 == "accept";
+        raise ValueError("Accepted domains are not wanted here")
 
     if reason is not None:
         # Maybe needs cleaning
index a31d0930fd27839b947ad6bb60d7a6ab4865069b..99de1416c09418664397405ae2b6e06b42de1e54 100644 (file)
@@ -231,6 +231,9 @@ def fetch_blocks(domain: str, origin: str, nodeinfo_url: str):
             if block_level == "":
                 print("WARNING: block_level is empty, domain:", domain)
                 continue
+            elif block_level == "accept";
+                print(f"DEBUG: domain='{domain}' skipping block_level='accept'")
+                continue
 
             # DEBUG: print(f"DEBUG: Checking {len(blocklist)} entries from domain='{domain}',software='mastodon',block_level='{block_level}' ...")
             for block in blocklist:
index aa8ea803e9bbfbdb2db9eddcbe76b52bded42563..aed1783cce8d34c4ba43e64ef59271c525a222a7 100644 (file)
@@ -92,6 +92,9 @@ def fetch_blocks(domain: str, origin: str, nodeinfo_url: str):
             if block_level == "":
                 print("WARNING: block_level is now empty!")
                 continue
+            elif block_level == "accept";
+                print(f"DEBUG: domain='{domain}' skipping block_level='accept'")
+                continue
 
             # DEBUG: print(f"DEBUG: Checking {len(blocklist)} entries from domain='{domain}',block_level='{block_level}' ...")
             if len(blocklist) > 0:
@@ -253,6 +256,9 @@ def fetch_blocks(domain: str, origin: str, nodeinfo_url: str):
             if block_level == "":
                 print("WARNING: block_level is now empty!")
                 continue
+            elif block_level == "accept";
+                print(f"DEBUG: domain='{domain}' skipping block_level='accept'")
+                continue
 
             # DEBUG: print(f"DEBUG: Checking {len(info.items())} entries from domain='{domain}',software='pleroma',block_level='{block_level}' ...")
             for blocked, reason in info.items():