]> git.mxchange.org Git - fba.git/commitdiff
Continued:
authorRoland Häder <roland@mxchange.org>
Mon, 10 Jul 2023 00:56:21 +0000 (02:56 +0200)
committerRoland Häder <roland@mxchange.org>
Mon, 10 Jul 2023 00:56:21 +0000 (02:56 +0200)
- yet again an other misskey instance (stella.place) returns the same results
  with raising offset all over again

fba/networks/misskey.py

index 1f6e42df93972a4f1786372c0bf14a6e80537b9b..35eff0b79c52cb0115bedc6f24532b4ddee15b78 100644 (file)
@@ -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,