]> git.mxchange.org Git - fba.git/blobdiff - fba/networks/mastodon.py
Continued:
[fba.git] / fba / networks / mastodon.py
index b0392ea13f5e751dfc85c29d01d29112ea6b5cdf..a440c04cd97d2ecb3ef0f772dd5691384fcee823 100644 (file)
@@ -19,14 +19,15 @@ import inspect
 import bs4
 import validators
 
-from fba import blacklist
-from fba import config
 from fba import csrf
 from fba import fba
-from fba import network
 
+from fba.helpers import blacklist
+from fba.helpers import config
 from fba.helpers import tidyup
 
+from fba.http import network
+
 from fba.models import blocks
 from fba.models import instances
 
@@ -287,6 +288,9 @@ def fetch_blocks(domain: str, origin: str, nodeinfo_url: str):
                 elif blocked.endswith(".tld"):
                     print(f"WARNING: blocked='{blocked}' is a fake domain, please don't crawl them!")
                     continue
+                elif blacklist.is_blacklisted(blocked):
+                    # DEBUG: print(f"DEBUG: blocked='{blocked}' is blacklisted - SKIPPED!")
+                    continue
                 elif not instances.is_registered(blocked):
                     # DEBUG: print(f"DEBUG: Domain blocked='{blocked}' wasn't found, adding ..., domain='{domain}',origin='{origin}',nodeinfo_url='{nodeinfo_url}'")
                     instances.add(blocked, domain, inspect.currentframe().f_code.co_name, nodeinfo_url)
@@ -301,6 +305,9 @@ def fetch_blocks(domain: str, origin: str, nodeinfo_url: str):
                 elif blocked.endswith(".tld"):
                     print(f"WARNING: blocked='{blocked}' is a fake domain, please don't crawl them!")
                     continue
+                elif blacklist.is_blacklisted(blocked):
+                    # DEBUG: print(f"DEBUG: blocked='{blocked}' is blacklisted - SKIPPED!")
+                    continue
                 elif not instances.is_registered(blocked):
                     # DEBUG: print("DEBUG: Hash wasn't found, adding:", blocked, domain)
                     instances.add(blocked, domain, inspect.currentframe().f_code.co_name, nodeinfo_url)
@@ -323,5 +330,6 @@ def fetch_blocks(domain: str, origin: str, nodeinfo_url: str):
         fba.connection.commit()
     except network.exceptions as exception:
         print(f"ERROR: domain='{domain}',software='mastodon',exception[{type(exception)}]:'{str(exception)}'")
+        instances.set_last_error(domain, exception)
 
     # DEBUG: print("DEBUG: EXIT!")