From 11065bb66a8b574db036bfbaa36494747104ad40 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Wed, 17 Apr 2024 21:38:13 +0200 Subject: [PATCH] Continued: - renamed local (overwritten) variable 'blocked' to 'cleared' so the array index can be found again --- fba/networks/pleroma.py | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/fba/networks/pleroma.py b/fba/networks/pleroma.py index c38c2da..08a1b20 100644 --- a/fba/networks/pleroma.py +++ b/fba/networks/pleroma.py @@ -244,20 +244,23 @@ def fetch_blocks(domain: str) -> list: for blocked in rows: logger.debug("blocked='%s' - BEFORE!", blocked) reason = tidyup.reason(rows[blocked]["reason"]) if rows[blocked]["reason"] != "" else None - blocked = tidyup.domain(blocked) if blocked != "" else None - logger.debug("blocked='%s',reason='%s' - AFTER!", blocked, reason) + cleaned = tidyup.domain(blocked) if blocked != "" else None + logger.debug("cleaned='%s',reason='%s' - AFTER!", cleaned, reason) - 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) + if cleaned in [None, ""]: + logger.warning("cleaned[%s]='%s' is empty after tidyup.domain(): domain='%s',block_level='%s'", type(cleaned), cleaned, domain, block_level) + continue + elif blocked not in rows: + logger.warning("Cannot find blocked='%s' in rows()=%d: domain='%s',block_level='%s'", blocked,len(rows), 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 + continue logger.debug("Checking %d blockdict record(s) ...", len(blockdict)) for block in blockdict: - logger.debug("block[blocked]='%s',blocked='%s'", block["blocked"], blocked) - if block["blocked"] == blocked: + logger.debug("block[blocked]='%s',cleaned='%s'", block["blocked"], cleaned) + if block["blocked"] == cleaned: logger.debug("Updating reason='%s' for blocker='%s'", reason, block["blocked"]) block["reason"] = reason else: -- 2.39.5