From 100f5533827156b6429a26b0c3c5318b84d38e0c Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Fri, 23 Jun 2023 05:46:02 +0200 Subject: [PATCH] WIP: - if the domain part of foo.tld/c/ is already registered, then this might be a link to a user profile - also log software --- fba/http/federation.py | 4 ++-- fba/models/instances.py | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/fba/http/federation.py b/fba/http/federation.py index d59d63b..a27bedc 100644 --- a/fba/http/federation.py +++ b/fba/http/federation.py @@ -93,7 +93,7 @@ def fetch_instances(domain: str, origin: str, software: str, command: str, path: logger.debug("domain='%s' has pending nodeinfo data, flushing ...", domain) instances.update_data(domain) - logger.info("Checking %d instances from domain='%s' ...", len(peerlist), domain) + logger.info("Checking %d instance(s) from domain='%s',software='%s' ...", len(peerlist), domain, software) for instance in peerlist: logger.debug("instance='%s'", instance) if instance is None: @@ -110,7 +110,7 @@ def fetch_instances(domain: str, origin: str, software: str, command: str, path: elif not utils.is_domain_wanted(instance): logger.debug("instance='%s' is not wanted - SKIPPED!", instance) continue - elif instance.find("/profile/") > 0 or instance.find("/users/") > 0: + elif instance.find("/profile/") > 0 or instance.find("/users/") > 0 or (instances.is_registered(instance.split("/")[0]) and instance.find("/c/") > 0): logger.debug("instance='%s' is a link to a single user profile - SKIPPED!", instance) continue elif not instances.is_registered(instance): diff --git a/fba/models/instances.py b/fba/models/instances.py index 9a3a273..fe2c1b0 100644 --- a/fba/models/instances.py +++ b/fba/models/instances.py @@ -148,6 +148,7 @@ def update_data(domain: str): def add(domain: str, origin: str, command: str, path: str = None, software: str = None): logger.debug("domain='%s',origin='%s',command='%s',path='%s',software='%s' - CALLED!", domain, origin, command, path, software) domain_helper.raise_on(domain) + if not isinstance(origin, str) and origin is not None: raise ValueError(f"origin[]='{type(origin)}' is not 'str'") elif origin == "": @@ -168,7 +169,7 @@ def add(domain: str, origin: str, command: str, path: str = None, software: str raise ValueError(f"Bad origin name='{origin}'") elif blacklist.is_blacklisted(domain): raise Exception(f"domain='{domain}' is blacklisted, but method invoked") - elif domain.find("/profile/") > 0 or domain.find("/users/") > 0 or (software == "lemmy" and domain.find("/c/") > 0): + elif domain.find("/profile/") > 0 or domain.find("/users/") > 0 or (is_registered(domain.split("/")[0]) and domain.find("/c/") > 0): raise Exception(f"domain='{domain}' is a single user") if software is None: -- 2.39.5