From: Roland Häder Date: Wed, 21 Jun 2023 01:06:56 +0000 (+0200) Subject: Continued: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=6df4eccfcfbcf1c394f68de88b20e6e8013ca97a;p=fba.git Continued: - tidyup blocked domain - set last error on exception - don't lower header text --- diff --git a/fba/networks/lemmy.py b/fba/networks/lemmy.py index 63829bb..a7079d0 100644 --- a/fba/networks/lemmy.py +++ b/fba/networks/lemmy.py @@ -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!") diff --git a/fba/networks/mastodon.py b/fba/networks/mastodon.py index b0392ea..dd21519 100644 --- a/fba/networks/mastodon.py +++ b/fba/networks/mastodon.py @@ -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!")