]> git.mxchange.org Git - fba.git/commitdiff
Continued:
authorRoland Häder <roland@mxchange.org>
Tue, 12 Sep 2023 10:13:58 +0000 (12:13 +0200)
committerRoland Häder <roland@mxchange.org>
Tue, 12 Sep 2023 10:19:08 +0000 (12:19 +0200)
- commit after each CSV row being handled
- tpzo fixed in module name
- always add domain to domains list

fba/commands.py
fba/helpers/processing.py

index f62de8032ed81471e70b3c12625ff97a5b59d27f..64125d9dbf8b294d58bc8f439cf428a5e23e3ca9 100644 (file)
@@ -319,7 +319,7 @@ def fetch_blocks(args: argparse.Namespace) -> int:
 
         # c.s isn't part of oliphant's "hidden" blocklists
         if blocker == "chaos.social" or software_helper.is_relay(software) or blocklists.has(blocker):
-            logger.debug("Skipping blocker='%s', run ./fba.py fetch_cs or fetch_oliphant instead!", blocker)
+            logger.debug("Skipping blocker='%s', run ./fba.py fetch_cs, fetch_oliphant, fetch_csv instead!", blocker)
             continue
 
         logger.debug("Invoking federation.fetch_blocks(%s) ...", blocker)
index 5f4f23e5f73a888f6e2d88dc78bf0a4421965124..0face7f3317b19b2a178cad29c81a59a81981bfe 100644 (file)
@@ -165,11 +165,11 @@ def csv_block(blocker: str, url: str, command: str):
             severity = "reject"
 
         if "reason" in row:
-            reason = tidup.reason(row["reason"]) if row["reason"] != None and row["reason"] != "" else None
+            reason = tidyup.reason(row["reason"]) if row["reason"] != None and row["reason"] != "" else None
         elif "comment" in row:
-            reason = tidup.reason(row["comment"]) if row["comment"] != None and row["comment"] != "" else None
+            reason = tidyup.reason(row["comment"]) if row["comment"] != None and row["comment"] != "" else None
         elif "Comment" in row:
-            reason = tidup.reason(row["Comment"]) if row["Comment"] != None and row["Comment"] != "" else None
+            reason = tidyup.reason(row["Comment"]) if row["Comment"] != None and row["Comment"] != "" else None
         else:
             logger.debug("row='%s' has no reason/comment key provided", row)
 
@@ -202,6 +202,9 @@ def csv_block(blocker: str, url: str, command: str):
             domain = utils.deobfuscate(domain, blocker)
             logger.debug("domain='%s' - AFTER!", domain)
 
+        logger.debug("Marking domain='%s' as handled", domain)
+        domains.append(domain)
+
         if not validators.domain(domain):
             logger.debug("domain='%s' is not a valid domain - SKIPPED!")
             continue
@@ -212,9 +215,6 @@ def csv_block(blocker: str, url: str, command: str):
             logger.debug("blocker='%s' has already blocked domain='%s' with severity='%s' - SKIPPED!", blocker, domain, severity)
             continue
 
-        logger.debug("Marking domain='%s' as handled", domain)
-        domains.append(domain)
-
         logger.debug("Processing domain='%s',blocker='%s',command='%s' ...", domain, blocker, command)
         processed = instance(domain, blocker, command)
         logger.debug("processed='%s'", processed)
@@ -231,8 +231,11 @@ def csv_block(blocker: str, url: str, command: str):
         if reject_reports:
             block(blocker, domain, None, "reject_reports")
 
+        logger.debug("Invoking commit() ...")
+        database.connection.commit()
+
     logger.debug("blocker='%s'", blocker)
-    if not blocklists.has(blocker):
+    if blocklists.has(blocker):
         logger.debug("Invoking instances.set_total_blocks(%s, domains()=%d) ...", blocker, len(domains))
         instances.set_total_blocks(blocker, domains)
 
@@ -241,9 +244,6 @@ def csv_block(blocker: str, url: str, command: str):
         logger.debug("Flushing updates for blocker='%s' ...", blocker)
         instances.update(blocker)
 
-    logger.debug("Invoking commit() ...")
-    database.connection.commit()
-
     logger.debug("config.get(bot_enabled)='%s',blockdict()=%d", config.get("bot_enabled"), len(blockdict))
     if config.get("bot_enabled") and len(blockdict) > 0:
         logger.info("Sending bot POST for blocker='%s',blockdict()=%d ...", blocker, len(blockdict))