From 67d158a0baadf3f7dbd8deb65851a9253a6d751d Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Mon, 24 Jul 2023 14:53:53 +0200 Subject: [PATCH] Continued: - custom aoderelay name aliased --- fba/boot.py | 7 +++++++ fba/commands.py | 15 +++++++++++++++ fba/helpers/software.py | 3 +++ 3 files changed, 25 insertions(+) diff --git a/fba/boot.py b/fba/boot.py index 6d0182a..7bd816a 100644 --- a/fba/boot.py +++ b/fba/boot.py @@ -213,6 +213,13 @@ def init_parser(): ) parser.set_defaults(command=commands.convert_idna) + ### Fetch instances from ActivityPub relays ### + parser = subparser_command.add_parser( + "fetch_relays", + help="Fetches instances from ActivityPub relays", + ) + parser.set_defaults(command=commands.fetch_relays) + logger.debug("EXIT!") def run_command(): diff --git a/fba/commands.py b/fba/commands.py index 359d9c2..d94966f 100644 --- a/fba/commands.py +++ b/fba/commands.py @@ -1784,6 +1784,21 @@ def fetch_instances_social(args: argparse.Namespace) -> int: logger.debug("Success! - EXIT!") return 0 +def fetch_relays(args: argparse.Namespace) -> int: + logger.debug("args[]='%s' - CALLED!", type(args)) + + database.cursor.execute("SELECT domain, software FROM instances WHERE software IN ('activityrelay', 'aoderelay', 'selective-relay')") + + domains = list() + + rows = database.cursor.fetchall() + logger.info("Checking %d relays ...", len(rows)) + for row in rows: + logger.debug("Fetching peers from row[domain]='%s',row[software]='%s' ...", row["domain"], row["software"]) + + logger.debug("Success! - EXIT!") + return 0 + def convert_idna(args: argparse.Namespace) -> int: logger.debug("args[]='%s' - CALLED!", type(args)) diff --git a/fba/helpers/software.py b/fba/helpers/software.py index 6882608..cf9366b 100644 --- a/fba/helpers/software.py +++ b/fba/helpers/software.py @@ -67,6 +67,9 @@ def alias(software: str) -> str: elif software == "diaspora* social network": logger.debug("Setting diaspora: software='%s'", software) software = "diaspora" + elif software == "tkz relay": + logger.debug("Setting aoderelay: software='%s'", software) + software = "aoderelay" elif software.find("/") > 0: logger.warning("Spliting of slash: software='%s'", software) software = software.split("/")[-1] -- 2.39.5