]> git.mxchange.org Git - fba.git/blobdiff - fba/networks/lemmy.py
Continued:
[fba.git] / fba / networks / lemmy.py
index 638cf79d3b12e2787732b57fb33a46973a155973..bfe1e805f0eed78685d3fa7669de0bb966aca2ac 100644 (file)
@@ -19,6 +19,7 @@ import logging
 
 import bs4
 
+from fba.helpers import blacklist
 from fba.helpers import config
 from fba.helpers import domain as domain_helper
 from fba.helpers import tidyup
@@ -71,6 +72,9 @@ def fetch_peers(domain: str, origin: str) -> list:
     logger.debug("domain='%s',origin='%s' - CALLED!", domain, origin)
     domain_helper.raise_on(domain)
 
+    if blacklist.is_blacklisted(domain):
+        raise Exception(f"domain='{domain}' is blacklisted but function is invoked.")
+
     peers = list()
 
     # No CSRF by default, you don't have to add network.api_headers by yourself here
@@ -121,7 +125,9 @@ def fetch_blocks(domain: str) -> list:
     logger.debug("domain='%s - CALLED!", domain)
     domain_helper.raise_on(domain)
 
-    if not instances.is_registered(domain):
+    if blacklist.is_blacklisted(domain):
+        raise Exception(f"domain='{domain}' is blacklisted but function is invoked.")
+    elif not instances.is_registered(domain):
         raise Exception(f"domain='{domain}' is not registered but function is invoked.")
 
     blocklist = list()
@@ -158,7 +164,7 @@ def fetch_blocks(domain: str) -> list:
                             content = str(header.contents[0])
                         logger.debug("content[%s]='%s' - AFTER!", type(content), content)
 
-                        if content is None:
+                        if content is None or content == "":
                             logger.debug("domain='%s' has returned empty header='%s' - SKIPPED!", domain, header)
                             continue
                         elif not isinstance(content, str):
@@ -233,6 +239,9 @@ def fetch_instances(domain: str, origin: str) -> list:
     logger.debug("domain='%s',origin='%s' - CALLED!", domain, origin)
     domain_helper.raise_on(domain)
 
+    if blacklist.is_blacklisted(domain):
+        raise Exception(f"domain='{domain}' is blacklisted but function is invoked.")
+
     peers = list()
 
     try: