]> git.mxchange.org Git - fba.git/commitdiff
Continued:
authorRoland Häder <roland@mxchange.org>
Wed, 21 Jun 2023 01:06:56 +0000 (03:06 +0200)
committerRoland Häder <roland@mxchange.org>
Wed, 21 Jun 2023 01:06:56 +0000 (03:06 +0200)
- tidyup blocked domain
- set last error on exception
- don't lower header text

fba/networks/lemmy.py
fba/networks/mastodon.py

index 63829bb6deb662f0c3aa6a9e52bfc98fcc627d5b..a7079d0680ee3ec44cbad99490183c5c55aa99ab 100644 (file)
@@ -26,6 +26,8 @@ from fba import fba
 from fba import federation
 from fba import network
 
+from fba.helpers import tidyup
+
 from fba.models import blocks
 from fba.models import instances
 
@@ -72,6 +74,7 @@ def fetch_peers(domain: str) -> list:
 
     except network.exceptions as exception:
         print(f"WARNING: Exception during fetching JSON: domain='{domain}',exception[{type(exception)}]:'{str(exception)}'")
+        instances.set_last_error(domain, exception)
 
     # DEBUG: print(f"DEBUG: Adding '{len(peers)}' for domain='{domain}'")
     instances.set_total_peers(domain, peers)
@@ -95,7 +98,36 @@ def fetch_blocks(domain: str, origin: str, nodeinfo_url: str):
         raise ValueError("Parameter 'nodeinfo_url' is empty")
 
     translations = [
-        "blocked instances",
+        "Blocked Instances",
+        "Instàncies bloquejades",
+        "Blocáilte Ásc",
+        "封锁实例",
+        "Blokované instance",
+        "Geblokkeerde instanties",
+        "Blockerade instanser",
+        "Instàncias blocadas",
+        "Istanze bloccate",
+        "Instances bloquées",
+        "Letiltott példányok",
+        "Instancias bloqueadas",
+        "Blokeatuta dauden instantziak",
+        "차단된 인스턴스",
+        "Peladen Yang Diblokir",
+        "Blokerede servere",
+        "Blokitaj nodoj",
+        "Блокирани Инстанции",
+        "Blockierte Instanzen",
+        "Estetyt instanssit",
+        "Instâncias bloqueadas",
+        "Zablokowane instancje",
+        "Blokované inštancie",
+        "المثلاء المحجوبون",
+        "Užblokuoti serveriai",
+        "ブロックしたインスタンス",
+        "Блокированные Инстансы",
+        "Αποκλεισμένοι διακομιστές",
+        "封鎖站台",
+        "Instâncias bloqueadas",
     ]
 
     try:
@@ -133,7 +165,7 @@ def fetch_blocks(domain: str, origin: str, nodeinfo_url: str):
                 content = header.contents[0]
  
                 # DEBUG: print(f"DEBUG: content='{content}'")
-                if content.lower() in translations:
+                if content in translations:
                     # DEBUG: print("DEBUG: Found header with blocked instances - BREAK!")
                     found = header
                     break
@@ -147,7 +179,7 @@ def fetch_blocks(domain: str, origin: str, nodeinfo_url: str):
             # DEBUG: print(f"DEBUG: Found {len(blocking)} blocked instance(s) ...")
             for tag in blocking:
                 # DEBUG: print(f"DEBUG: tag[]='{type(tag)}'")
-                blocked = tag.contents[0]
+                blocked = tidyup.domain(tag.contents[0])
 
                 # DEBUG: print(f"DEBUG: blocked='{blocked}'")
                 if not validators.domain(blocked):
@@ -182,5 +214,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!")
index b0392ea13f5e751dfc85c29d01d29112ea6b5cdf..dd215196851773a0bc8c1d4521dbe074ab8733d1 100644 (file)
@@ -323,5 +323,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!")