]> git.mxchange.org Git - fba.git/blobdiff - fetch_blocks.py
Continued:
[fba.git] / fetch_blocks.py
index 260945f35a2a58c60bda26e04a7784c1933901ee..c114aad0cde4094262bbd266d1efd06ddc515346 100755 (executable)
@@ -29,7 +29,7 @@ from fba import *
 boot.acquire_lock()
 
 fba.cursor.execute(
-    "SELECT domain, software, origin, nodeinfo_url FROM instances WHERE software IN ('pleroma', 'mastodon', 'friendica', 'misskey', 'gotosocial', 'bookwyrm', 'takahe') AND (last_blocked IS NULL OR last_blocked < ?) ORDER BY rowid DESC", [time.time() - fba.config["recheck_block"]]
+    "SELECT domain, software, origin, nodeinfo_url FROM instances WHERE software IN ('pleroma', 'mastodon', 'friendica', 'misskey', 'gotosocial', 'bookwyrm', 'takahe') AND (last_blocked IS NULL OR last_blocked < ?) ORDER BY rowid DESC", [time.time() - config.config["recheck_block"]]
 )
 
 rows = fba.cursor.fetchall()
@@ -225,7 +225,7 @@ for blocker, software, origin, nodeinfo_url in rows:
                 # handling CSRF, I've saw at least one server requiring it to access the endpoint
                 # DEBUG: print("DEBUG: Fetching meta:", blocker)
                 meta = bs4.BeautifulSoup(
-                    reqto.get(f"https://{blocker}/", headers=fba.headers, timeout=(fba.config["connection_timeout"], fba.config["read_timeout"])).text,
+                    reqto.get(f"https://{blocker}/", headers=fba.headers, timeout=(config.config["connection_timeout"], config.config["read_timeout"])).text,
                     "html.parser",
                 )
                 try:
@@ -237,7 +237,7 @@ for blocker, software, origin, nodeinfo_url in rows:
                     reqheaders = fba.api_headers
 
                 # DEBUG: print("DEBUG: Querying API domain_blocks:", blocker)
-                blocks = reqto.get(f"https://{blocker}/api/v1/instance/domain_blocks", headers=reqheaders, timeout=(fba.config["connection_timeout"], fba.config["read_timeout"])).json()
+                blocks = reqto.get(f"https://{blocker}/api/v1/instance/domain_blocks", headers=reqheaders, timeout=(config.config["connection_timeout"], config.config["read_timeout"])).json()
 
                 print(f"INFO: Checking {len(blocks)} entries from blocker='{blocker}',software='{software}' ...")
                 for block in blocks:
@@ -447,7 +447,7 @@ for blocker, software, origin, nodeinfo_url in rows:
         print("INFO: blocker:", blocker)
         try:
             # Blocks
-            federation = reqto.get(f"https://{blocker}{fba.get_peers_url}?filter=suspended", headers=fba.api_headers, timeout=(fba.config["connection_timeout"], fba.config["read_timeout"])).json()
+            federation = reqto.get(f"https://{blocker}{fba.get_peers_url}?filter=suspended", headers=fba.api_headers, timeout=(config.config["connection_timeout"], config.config["read_timeout"])).json()
 
             if (federation == None):
                 print("WARNING: No valid response:", blocker);
@@ -522,7 +522,7 @@ for blocker, software, origin, nodeinfo_url in rows:
     else:
         print("WARNING: Unknown software:", blocker, software)
 
-    if fba.config["bot_enabled"] and len(blockdict) > 0:
+    if config.config["bot_enabled"] and len(blockdict) > 0:
         send_bot_post(blocker, blockdict)
 
     blockdict = []