From 87853395b4cf16f335ae0e3fe40527da4920c8f8 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Sun, 18 Jun 2023 20:43:27 +0200 Subject: [PATCH] Continued: - bookwym and takahe are not supported, let's remove them - don't cut off path when checking if instances is registered or not - added commented out debug line --- api.py | 2 +- fba/commands.py | 4 ++-- fba/fba.py | 1 + fba/federation.py | 2 +- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/api.py b/api.py index 1033a01..16db02b 100644 --- a/api.py +++ b/api.py @@ -40,7 +40,7 @@ templates = Jinja2Templates(directory="templates") @router.get(config.get("base_url") + "/api/info.json", response_class=JSONResponse) def api_info(): - fba.cursor.execute("SELECT (SELECT COUNT(domain) FROM instances), (SELECT COUNT(domain) FROM instances WHERE software IN ('pleroma', 'mastodon', 'lemmy', 'friendica', 'misskey', 'bookwyrm', 'takahe', 'peertube')), (SELECT COUNT(blocker) FROM blocks), (SELECT COUNT(domain) FROM instances WHERE last_error_details IS NOT NULL)") + fba.cursor.execute("SELECT (SELECT COUNT(domain) FROM instances), (SELECT COUNT(domain) FROM instances WHERE software IN ('pleroma', 'mastodon', 'lemmy', 'friendica', 'misskey', 'peertube')), (SELECT COUNT(blocker) FROM blocks), (SELECT COUNT(domain) FROM instances WHERE last_error_details IS NOT NULL)") row = fba.cursor.fetchone() return { diff --git a/fba/commands.py b/fba/commands.py index 4c0211d..89563a8 100644 --- a/fba/commands.py +++ b/fba/commands.py @@ -153,7 +153,7 @@ def fetch_blocks(args: argparse.Namespace): else: # Re-check after "timeout" (aka. minimum interval) fba.cursor.execute( - "SELECT domain, software, origin, nodeinfo_url FROM instances WHERE software IN ('pleroma', 'mastodon', 'lemmy', 'friendica', 'misskey', 'bookwyrm', 'takahe', 'peertube') AND (last_blocked IS NULL OR last_blocked < ?) ORDER BY rowid DESC", [time.time() - config.get("recheck_block")] + "SELECT domain, software, origin, nodeinfo_url FROM instances WHERE software IN ('pleroma', 'mastodon', 'lemmy', 'friendica', 'misskey', 'peertube') AND (last_blocked IS NULL OR last_blocked < ?) ORDER BY rowid DESC", [time.time() - config.get("recheck_block")] ) rows = fba.cursor.fetchall() @@ -465,7 +465,7 @@ def fetch_instances(args: argparse.Namespace) -> int: # Loop through some instances fba.cursor.execute( - "SELECT domain, origin, software, nodeinfo_url FROM instances WHERE software IN ('pleroma', 'mastodon', 'friendica', 'misskey', 'lemmy', 'bookwyrm', 'takahe', 'peertube') AND (last_instance_fetch IS NULL OR last_instance_fetch < ?) ORDER BY rowid DESC", [time.time() - config.get("recheck_instance")] + "SELECT domain, origin, software, nodeinfo_url FROM instances WHERE software IN ('pleroma', 'mastodon', 'friendica', 'misskey', 'lemmy', 'peertube') AND (last_instance_fetch IS NULL OR last_instance_fetch < ?) ORDER BY rowid DESC", [time.time() - config.get("recheck_instance")] ) rows = fba.cursor.fetchall() diff --git a/fba/fba.py b/fba/fba.py index b175e57..aa1f375 100644 --- a/fba/fba.py +++ b/fba/fba.py @@ -38,6 +38,7 @@ def is_primitive(var: any) -> bool: return type(var) in {int, str, float, bool} or var is None def get_hash(domain: str) -> str: + # DEBUG: print(f"DEBUG: domain='{domain}' - CALLED!") if not isinstance(domain, str): raise ValueError(f"Parameter domain[]='{type(domain)}' is not 'str'") elif domain == "": diff --git a/fba/federation.py b/fba/federation.py index f5a5f1b..d966bc3 100644 --- a/fba/federation.py +++ b/fba/federation.py @@ -79,7 +79,7 @@ def fetch_instances(domain: str, origin: str, software: str, command: str, path: elif not validators.domain(domain.split("/")[0]): raise ValueError(f"domain='{domain}' is not a valid domain") - if not instances.is_registered(domain.split("/")[0]): + if not instances.is_registered(domain): # DEBUG: print(f"DEBUG: Adding new domain='{domain}',origin='{origin}',command='{command}',path='{path}',software='{software}'") instances.add(domain, origin, command, path, software) -- 2.39.5