From: Roland Häder Date: Mon, 10 Jul 2023 00:56:21 +0000 (+0200) Subject: Continued: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=e2bb23bbc5813787af254e4d457ebfa9ccae649b;p=fba.git Continued: - yet again an other misskey instance (stella.place) returns the same results with raising offset all over again --- diff --git a/fba/networks/misskey.py b/fba/networks/misskey.py index 1f6e42d..35eff0b 100644 --- a/fba/networks/misskey.py +++ b/fba/networks/misskey.py @@ -21,6 +21,7 @@ from fba import csrf from fba import utils from fba.helpers import config +from fba.helpers import dicts as dict_helper from fba.helpers import domain as domain_helper from fba.helpers import tidyup @@ -126,12 +127,6 @@ def fetch_blocks(domain: str) -> list: logger.debug("domain='%s' - CALLED!", domain) domain_helper.raise_on(domain) - logger.debug("Fetching misskey blocks from domain='%s'", domain) - blocklist = list() - - offset = 0 - step = config.get("misskey_limit") - # No CSRF by default, you don't have to add network.api_headers by yourself here headers = tuple() @@ -143,8 +138,13 @@ def fetch_blocks(domain: str) -> list: instances.set_last_error(domain, exception) return list() + blocklist = list() + offset = 0 + step = config.get("misskey_limit") + # iterating through all "suspended" (follow-only in its terminology) # instances page-by-page since it doesn't support sending them all at once + logger.debug("Fetching misskey blocks from domain='%s'", domain) while True: try: logger.debug("Fetching offset=%d from domain='%s' ...", offset, domain) @@ -192,12 +192,14 @@ def fetch_blocks(domain: str) -> list: count = 0 for instance in rows: # Is it there? - logger.debug("instance[%s]='%s'", type(instance), instance) - if "isSuspended" in instance and instance["isSuspended"]: + logger.debug("instance[]='%s'", type(instance)) + blocked = tidyup.domain(instance["host"]) + if "isSuspended" in instance and instance["isSuspended"] and not dict_helper.has_key(blocklist, "blocked", blocked): count = count + 1 + logger.debug("Appending blocker='%s',blocked='%s',block_level='suspended'", domain, blocked) blocklist.append({ "blocker" : domain, - "blocked" : tidyup.domain(instance["host"]), + "blocked" : blocked, "reason" : None, "block_level": "suspended", }) @@ -260,10 +262,10 @@ def fetch_blocks(domain: str) -> list: count = 0 for instance in rows: # Is it there? - logger.debug("instance[%s]='%s'", type(instance), instance) - if "isBlocked" in instance and instance["isBlocked"]: + logger.debug("instance[]='%s'", type(instance)) + blocked = tidyup.domain(instance["host"]) + if "isBlocked" in instance and instance["isBlocked"] and not dict_helper.has_key(blocklist, "blocked", blocked): count = count + 1 - blocked = tidyup.domain(instance["host"]) logger.debug("Appending blocker='%s',blocked='%s',block_level='reject'", domain, blocked) blocklist.append({ "blocker" : domain,