]> git.mxchange.org Git - fba.git/commitdiff
Continued:
authorRoland Häder <roland@mxchange.org>
Wed, 12 Jul 2023 04:49:13 +0000 (06:49 +0200)
committerRoland Häder <roland@mxchange.org>
Wed, 12 Jul 2023 04:49:13 +0000 (06:49 +0200)
- recursive adding is totally okay, as it won't happen to go endless
- renamed blocks.add_instance() to add()

fba/helpers/processing.py
fba/http/federation.py
fba/models/blocks.py

index 352ab31b6a6d381915793339757a53d28e88a232..5ffbbfc3a53bee26125b2ce5308babea124379f9 100644 (file)
@@ -84,8 +84,8 @@ def block(blocker: str, blocked: str, reason: str, block_level: str) -> bool:
         raise ValueError("Parameter block_level is empty")
 
     if not blocks.is_instance_blocked(blocker, blocked, block_level):
-        logger.debug("Invoking blocks.add_instance(%s, %s, %s, %s) ...", blocker, blocked, reason, block_level)
-        blocks.add_instance(blocker, blocked, reason, 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)
index b4477cd32cbd12ab5c0de6fdaf59714f5b6f62d9..e3b40bf8f928e92e1524b738fc3df87e79ed11a5 100644 (file)
@@ -63,6 +63,8 @@ def fetch_instances(domain: str, origin: str, software: str, command: str, path:
         logger.debug("Determined software='%s' for domain='%s'", software, domain)
     elif not isinstance(software, str):
         raise ValueError(f"Parameter software[]='{type(software)}' is not of type 'str'")
+    elif not isinstance(path, str) and path is not None:
+        raise ValueError(f"Parameter path[]='{type(path)}' is not of type 'str'")
 
     logger.debug("Checking if domain='%s' is registered ...", domain)
     if not instances.is_registered(domain):
@@ -127,8 +129,8 @@ def fetch_instances(domain: str, origin: str, software: str, command: str, path:
             logger.debug("instance='%s' is a link to a tag - SKIPPED!", instance)
             continue
         elif not instances.is_registered(instance):
-            logger.debug("Adding new instance='%s',domain='%s',command='%s'", instance, domain, command)
-            instances.add(instance, domain, command)
+            logger.debug("Fetching instance='%s',origin='%s',command='%s',path='%s' ...", instance, domain, command, path)
+            fetch_instances(instance, domain, None, command, path)
 
     logger.debug("Invoking cookies.clear(%s) ...", domain)
     cookies.clear(domain)
index 1a861c5ea3f7981e29bfa502bc41f8a623934f1c..943db348cd6fd7c9471ed93b22a6ff14d078125d 100644 (file)
@@ -139,7 +139,7 @@ def is_instance_blocked(blocker: str, blocked: str, block_level: str = None) ->
     logger.debug("is_blocked='%s' - EXIT!", is_blocked)
     return is_blocked
 
-def add_instance(blocker: str, blocked: str, reason: str, block_level: str):
+def add(blocker: str, blocked: str, reason: str, block_level: str):
     logger.debug("blocker='%s',blocked='%s',reason='%s',block_level='%s' - CALLED!", blocker, blocked, reason, block_level)
     domain_helper.raise_on(blocker)
     domain_helper.raise_on(blocked)