]> git.mxchange.org Git - fba.git/commitdiff
Continued:
authorRoland Häder <roland@mxchange.org>
Sun, 3 Sep 2023 02:29:17 +0000 (04:29 +0200)
committerRoland Häder <roland@mxchange.org>
Sun, 3 Sep 2023 02:29:17 +0000 (04:29 +0200)
- renamed processing.domain() to processing.instance()
- renamed its parameter 'name' to 'blocked' (unified)

fba/commands.py
fba/helpers/processing.py
fba/models/blocks.py

index b1b525f4c369d78213079f59ff33052c11e82765..89e9ed4304aecfc063882e52e61dea43a54b07cd 100644 (file)
@@ -1095,7 +1095,7 @@ def fetch_oliphant(args: argparse.Namespace) -> int:
             domains.append(domain)
 
             logger.debug("Processing domain='%s' ...", domain)
-            processed = processing.domain(domain, block["blocker"], inspect.currentframe().f_code.co_name)
+            processed = processing.instance(domain, block["blocker"], inspect.currentframe().f_code.co_name)
             logger.debug("processed='%s'", processed)
 
             if processing.block(block["blocker"], domain, None, severity) and config.get("bot_enabled"):
@@ -1170,7 +1170,7 @@ def fetch_txt(args: argparse.Namespace) -> int:
                     continue
 
                 logger.debug("Processing domain='%s',row[blocker]='%s'", domain, row["blocker"])
-                processed = processing.domain(domain, row["blocker"], inspect.currentframe().f_code.co_name)
+                processed = processing.instance(domain, row["blocker"], inspect.currentframe().f_code.co_name)
 
                 logger.debug("processed='%s'", processed)
                 if not processed:
@@ -1471,7 +1471,7 @@ def fetch_joinfediverse(args: argparse.Namespace) -> int:
             continue
 
         logger.debug("Proccessing blocked='%s' ...", block["blocked"])
-        processing.domain(block["blocked"], "climatejustice.social", inspect.currentframe().f_code.co_name)
+        processing.instance(block["blocked"], "climatejustice.social", inspect.currentframe().f_code.co_name)
 
     blockdict = list()
     for blocker in domains:
index fd7be65487fa905854e5638e5a95730ef5f8dc7b..5881ded240d52b3190d843a531b6d409aeb84631 100644 (file)
@@ -29,9 +29,9 @@ from fba.models import instances
 logging.basicConfig(level=logging.INFO)
 logger = logging.getLogger(__name__)
 
-def domain(name: str, blocker: str, command: str) -> bool:
-    logger.debug("name='%s',blocker='%s',command='%s' - CALLED!", name, blocker, command)
-    domain_helper.raise_on(name)
+def instance(blocked: str, blocker: str, command: str) -> bool:
+    logger.debug("blocked='%s',blocker='%s',command='%s' - CALLED!", blocked, blocker, command)
+    domain_helper.raise_on(blocked)
     domain_helper.raise_on(blocker)
 
     if not isinstance(command, str):
@@ -39,34 +39,34 @@ def domain(name: str, blocker: str, command: str) -> bool:
     elif command == "":
         raise ValueError("Parameter 'command' is empty")
 
-    logger.debug("name='%s' - BEFORE!", name)
-    name = utils.deobfuscate(name, blocker)
+    logger.debug("blocked='%s' - BEFORE!", blocked)
+    blocked = utils.deobfuscate(blocked, blocker)
 
-    logger.debug("name='%s' - DEOBFUSCATED!", name)
+    logger.debug("blocked='%s' - DEOBFUSCATED!", blocked)
     if instances.has_pending(blocker):
         logger.debug("Flushing updates for blocker='%s' ...", blocker)
         instances.update(blocker)
 
-    if not domain_helper.is_wanted(name):
-        logger.debug("name='%s' is not wanted - SKIPPED!", name)
+    if not domain_helper.is_wanted(blocked):
+        logger.debug("blocked='%s' is not wanted - SKIPPED!", blocked)
         return False
-    elif instances.is_recent(name):
-        logger.debug("name='%s' has been recently checked - SKIPPED!", name)
+    elif instances.is_recent(blocked):
+        logger.debug("blocked='%s' has been recently checked - SKIPPED!", blocked)
         return False
 
     processed = False
     try:
-        logger.info("Fetching instances for name='%s',blocker='%s',command='%s' ...", name, blocker, command)
-        federation.fetch_instances(name, blocker, None, command)
+        logger.info("Fetching instances for blocked='%s',blocker='%s',command='%s' ...", blocked, blocker, command)
+        federation.fetch_instances(blocked, blocker, None, command)
         processed = True
     except network.exceptions as exception:
-        logger.warning("Exception '%s' during fetching instances (%s) from name='%s'", type(exception), command, name)
-        instances.set_last_error(name, exception)
+        logger.warning("Exception '%s' during fetching instances (%s) from blocked='%s'", type(exception), command, blocked)
+        instances.set_last_error(blocked, exception)
 
-    logger.debug("Checking if name='%s' has pending updates ...", name)
-    if instances.has_pending(name):
-        logger.debug("Flushing updates for name='%s' ...", name)
-        instances.update(name)
+    logger.debug("Checking if blocked='%s' has pending updates ...", blocked)
+    if instances.has_pending(blocked):
+        logger.debug("Flushing updates for blocked='%s' ...", blocked)
+        instances.update(blocked)
 
     logger.debug("processed='%s' - EXIT!", processed)
     return processed
@@ -76,7 +76,6 @@ def block(blocker: str, blocked: str, reason: str, block_level: str) -> bool:
     domain_helper.raise_on(blocker)
     domain_helper.raise_on(blocked)
 
-    added = False
     if not isinstance(reason, str) and reason is not None:
         raise ValueError(f"Parameter reason[]='{type(reason)}' is not of type 'str'")
     elif not isinstance(block_level, str):
@@ -86,12 +85,13 @@ def block(blocker: str, blocked: str, reason: str, block_level: str) -> bool:
     elif blacklist.is_blacklisted(blocked):
         raise ValueError(f"blocked='{blocked}' is blacklisted but function was invoked")
 
+    added = False
     if not blocks.is_instance_blocked(blocker, blocked, block_level):
         logger.debug("Invoking blocks.add(%s, %s, %s, %s) ...", blocker, blocked, reason, block_level)
         blocks.add(blocker, blocked, reason, block_level)
         added = True
     else:
-        logger.debug("Updating block last seen and reason for blocker='%s',blocked='%s' ...", blocker, blocked)
+        logger.debug("Updating last_seen for blocker='%s',blocked='%s',block_level='%s' ...", blocker, blocked, block_level)
         blocks.update_last_seen(blocker, blocked, block_level)
 
     logger.debug("added='%s' - EXIT!", added)
index f4af845c0dd71c595bc5f64a60f66d643a1eec6a..16c7027a8213003f529fa50714bf24afd0610f38 100644 (file)
@@ -190,8 +190,6 @@ def translate_idnas(rows: list, column: str):
         raise ValueError("Parameter 'rows' is an empty list")
     elif not isinstance(column, str):
         raise ValueError(f"column='{type(column)}' is not of type 'str'")
-    elif column == "":
-        raise ValueError("Parameter 'column' is empty")
     elif column not in ["blocker", "blocked"]:
         raise ValueError(f"column='{column}' is not supported")
 
@@ -216,8 +214,6 @@ def alias_block_level(block_level: str) -> str:
 
     if not isinstance(block_level, str):
         raise ValueError(f"Parameter block_level[]='{type(block_level)}' is not of type 'str'")
-    elif block_level == "":
-        raise ValueError("Parameter 'block_level' is empty")
     elif block_level in ["accept", "accepted"]:
         raise ValueError(f"Parameter block_level='{block_level}' is not accepted but function was invoked")
     elif block_level == "silence":