]> git.mxchange.org Git - fba.git/commitdiff
Continued:
authorRoland Häder <roland@mxchange.org>
Thu, 18 May 2023 21:09:04 +0000 (23:09 +0200)
committerRoland Häder <roland@mxchange.org>
Thu, 18 May 2023 21:09:04 +0000 (23:09 +0200)
- you better should check an array on a specific key with `key in my_array`

fetch_blocks.py

index 2ea4a8662a30380da72e189153d77556a6881207..6b0e060e05dcac8adabf17215fd0c4d603ee300b 100644 (file)
@@ -26,12 +26,13 @@ for blocker, software in fba.c.fetchall():
             federation = reqto.get(
                 f"https://{blocker}/nodeinfo/2.1.json", headers=fba.headers, timeout=5
             ).json()["metadata"]["federation"]
+
             if "mrf_simple" in federation:
                 for block_level, blocks in (
                     {**federation["mrf_simple"],
                     **{"quarantined_instances": federation["quarantined_instances"]}}
                 ).items():
-                    # NOISY-DEBUG: print("DEBUG: block_level, blocks.items():", block_level, len(blocks.items()))
+                    # NOISY-DEBUG: print("DEBUG: block_level, blocks():", block_level, len(blocks))
                     block_level = fba.tidyup(block_level)
                     # NOISY-DEBUG: print("DEBUG: BEFORE block_level:", block_level)
 
@@ -348,13 +349,10 @@ for blocker, software in fba.c.fetchall():
 
             if (federation == None):
                 print("WARNING: No valid response:", blocker);
+            elif "error" in federation:
+                print("WARNING: API returned error:", federation["error"])
             else:
                 for peer in federation:
-                    # NOISY-DEBUG: print("DEBUG: peer(),[]:", len(peer), type(peer))
-                    if (isinstance(peer, str) and peer == "error"):
-                        print("WARNING: Cannot continue, maybe authentication required?", blocker)
-                        break
-
                     blocked = peer["domain"].lower()
                     # NOISY-DEBUG: print("DEBUG: BEFORE-blocked:", blocked)
                     blocked = fba.tidyup(blocked)