]> git.mxchange.org Git - fba.git/commitdiff
Continued:
authorRoland Häder <roland@mxchange.org>
Wed, 17 Apr 2024 18:10:06 +0000 (20:10 +0200)
committerRoland Häder <roland@mxchange.org>
Wed, 17 Apr 2024 18:10:06 +0000 (20:10 +0200)
- need to check if variable 'blocked' is None or an empty string first
- log size (len()) not whole array

fba/networks/pleroma.py

index 0da479b4b3234919e18904a9d8a1cfe9a2d529ee..c38c2da7b785fc70807556b1c0aefd096c50aaf5 100644 (file)
@@ -247,12 +247,12 @@ def fetch_blocks(domain: str) -> list:
             blocked = tidyup.domain(blocked) if blocked != "" else None
             logger.debug("blocked='%s',reason='%s' - AFTER!", blocked, reason)
 
-            if blocked not in rows or "reason" not in rows[blocked]:
-                logger.warning("Cannot find blocked='%s' in rows()=%d,domain='%s' - BREAK!", blocked, len(rows), domain)
-                break
-            elif blocked in [None, ""]:
+            if blocked in [None, ""]:
                 logger.warning("blocked[%s]='%s' is empty after tidyup.domain(): domain='%s',block_level='%s'", type(blocked), blocked, domain, block_level)
                 continue
+            elif "reason" not in rows[blocked]:
+                logger.warning("Cannot find 'reason' in rows[%s]()=%d,domain='%s' - BREAK!", blocked, len(rows[blocked]), domain)
+                break
 
             logger.debug("Checking %d blockdict record(s) ...", len(blockdict))
             for block in blockdict:
@@ -272,7 +272,7 @@ def fetch_blocks(domain: str) -> list:
         if len(blocklist) > 0:
             logger.info("Checking %d different blocklist(s) ...", len(blocklist))
             for block_level in blocklist:
-                logger.debug("Checking blocklist[%s]()=%d entries ...", block_level, blocklist[block_level])
+                logger.debug("Checking blocklist[%s]()=%d entries ...", block_level, len(blocklist[block_level]))
                 for block in blocklist[block_level]:
                     logger.debug("Appending blocker='%s',block[blocked]='%s',block[reason]='%s',block_level='%s' ...",domain, block["blocked"], block["reason"], block_level)
                     blockdict.append({