From 5b54e87452335c205be242799debe73d7f997098 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Wed, 12 Jul 2023 06:49:13 +0200 Subject: [PATCH] Continued: - recursive adding is totally okay, as it won't happen to go endless - renamed blocks.add_instance() to add() --- fba/helpers/processing.py | 4 ++-- fba/http/federation.py | 6 ++++-- fba/models/blocks.py | 2 +- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/fba/helpers/processing.py b/fba/helpers/processing.py index 352ab31..5ffbbfc 100644 --- a/fba/helpers/processing.py +++ b/fba/helpers/processing.py @@ -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) diff --git a/fba/http/federation.py b/fba/http/federation.py index b4477cd..e3b40bf 100644 --- a/fba/http/federation.py +++ b/fba/http/federation.py @@ -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) diff --git a/fba/models/blocks.py b/fba/models/blocks.py index 1a861c5..943db34 100644 --- a/fba/models/blocks.py +++ b/fba/models/blocks.py @@ -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) -- 2.39.5