]> git.mxchange.org Git - fba.git/commitdiff
Continued:
authorRoland Häder <roland@mxchange.org>
Thu, 8 Jun 2023 18:03:43 +0000 (20:03 +0200)
committerRoland Häder <roland@mxchange.org>
Thu, 8 Jun 2023 18:04:45 +0000 (20:04 +0200)
- some block reasons have a long domain list (which can be taken as
  instance names, too) with no space after a comma
- this causes the web page to be very(!) wide
- added missing "import inspect"
- improved some debug messages

api.py
fba/federation/mastodon.py
fba/federation/misskey.py

diff --git a/api.py b/api.py
index ec459f5987a95cb58e8f5f0f869457cbe8fbb3a4..7c41eed383d817a2d1da6dd5ace564e6b67f3a73 100644 (file)
--- a/api.py
+++ b/api.py
@@ -110,6 +110,9 @@ def blocked(domain: str = None, reason: str = None, reverse: str = None):
 
     result = {}
     for blocker, blocked, block_level, reason, first_seen, last_seen in blocklist:
+        if reason != None and reason != "":
+            reason = reason.replace(",", " ").replace("  ", " ")
+
         entry = {
             "blocker"   : blocker,
             "blocked"   : blocked,
@@ -117,6 +120,7 @@ def blocked(domain: str = None, reason: str = None, reverse: str = None):
             "first_seen": first_seen,
             "last_seen" : last_seen
         }
+
         if block_level in result:
             result[block_level].append(entry)
         else:
index 11eac1bb969dd60118fe68ba545486719566d1c9..4752ca1792d41815b74b89a39262e155f7b152ff 100644 (file)
@@ -15,6 +15,7 @@
 # along with this program.  If not, see <https://www.gnu.org/licenses/>.
 
 import bs4
+import inspect
 import validators
 
 from fba import blacklist
@@ -127,7 +128,7 @@ def fetch_blocks(domain: str, origin: str, nodeinfo_url: str):
                 "reject"        : [],
                 "media_removal" : [],
                 "followers_only": [],
-                "report_removal": []
+                "report_removal": [],
             }
 
             # handling CSRF, I've saw at least one server requiring it to access the endpoint
@@ -187,10 +188,12 @@ def fetch_blocks(domain: str, origin: str, nodeinfo_url: str):
 
             # DEBUG: print(f"DEBUG: Checking {len(blocklist)} entries from domain='{domain}',software='mastodon',block_level='{block_level}' ...")
             for block in blocklist:
+                # DEBUG: print(f"DEBUG: block[]='{type(block)}'")
                 blocked, blocked_hash, reason = block.values()
-                # DEBUG: print("DEBUG: blocked,hash,reason:", blocked, blocked_hash, reason)
+                # DEBUG: print(f"DEBUG: blocked='{blocked}',blocked_hash='{blocked_hash}',reason='{reason}':")
                 blocked = fba.tidyup_domain(blocked)
-                # DEBUG: print("DEBUG: AFTER-blocked:", blocked)
+                reason  = fba.tidyup_reason(reason)
+                # DEBUG: print(f"DEBUG: blocked='{blocked}',reason='{reason}' - AFTER!")
 
                 if blocked == "":
                     print("WARNING: blocked is empty:", domain)
index 1428948cf8c8f7fd54a0f6f5dd0eb3b3b27cbcbe..8ea0b2b44b18a1bcfbe8eee590f97d794d6a5d23 100644 (file)
@@ -58,13 +58,13 @@ def fetch_peers(domain: str) -> list:
 
         # DEBUG: print(f"DEBUG: fetched()={len(fetched)}")
         if len(fetched) == 0:
-            # DEBUG: print("DEBUG: Returned zero bytes, exiting loop:", domain)
+            # DEBUG: print(f"DEBUG: Returned zero bytes, exiting loop, domain='{domain}'")
             break
         elif len(fetched) != config.get("misskey_limit"):
             # DEBUG: print(f"DEBUG: Fetched '{len(fetched)}' row(s) but expected: '{config.get('misskey_limit')}'")
             offset = offset + (config.get("misskey_limit") - len(fetched))
         else:
-            # DEBUG: print("DEBUG: Raising offset by step:", step)
+            # DEBUG: print(f"DEBUG: Raising offset by step={step}")
             offset = offset + step
 
         # Check records
@@ -76,7 +76,7 @@ def fetch_peers(domain: str) -> list:
 
         already = 0
         for row in fetched:
-            # DEBUG: print(f"DEBUG: row():{len(row)}")
+            # DEBUG: print(f"DEBUG: row()={len(row)}")
             if not "host" in row:
                 print(f"WARNING: row()={len(row)} does not contain key 'host': {row},domain='{domain}'")
                 continue
@@ -104,5 +104,5 @@ def fetch_peers(domain: str) -> list:
     # DEBUG: print(f"DEBUG: Updating last_instance_fetch for domain='{domain}' ...")
     instances.update_last_instance_fetch(domain)
 
-    # DEBUG: print("DEBUG: Returning peers[]:", type(peers))
+    # DEBUG: print(f"DEBUG: Returning peers[]='{type(peers)}'")
     return peers