+ except BaseException as exception:
+ print(f"ERROR: failed SQL query: domain='{domain}',sql_string='{sql_string}',exception[{type(exception)}]:'{str(exception)}'")
+ sys.exit(255)
+
+ # DEBUG: print("DEBUG: EXIT!")
+
+def update_last_instance_fetch(domain: str):
+ # DEBUG: print(f"DEBUG: domain='{domain}' - CALLED!")
+ if not isinstance(domain, str):
+ raise ValueError(f"Parameter domain[]={type(domain)} is not 'str'")
+ elif domain == "":
+ raise ValueError("Parameter 'domain' is empty")
+
+ # DEBUG: print("DEBUG: Updating last_instance_fetch for domain:", domain)
+ set("last_instance_fetch", domain, time.time())
+
+ # Running pending updated
+ # DEBUG: print(f"DEBUG: Invoking update_data({domain}) ...")
+ update_data(domain)
+
+ # DEBUG: print("DEBUG: EXIT!")
+
+def update_last_blocked(domain: str):
+ if not isinstance(domain, str):
+ raise ValueError(f"Parameter domain[]={type(domain)} is not 'str'")
+ elif domain == "":
+ raise ValueError("Parameter 'domain' is empty")
+
+ # DEBUG: print("DEBUG: Updating last_blocked for domain", domain)
+ set("last_blocked", domain, time.time())
+
+ # Running pending updated
+ # DEBUG: print(f"DEBUG: Invoking update_data({domain}) ...")
+ update_data(domain)
+
+ # DEBUG: print("DEBUG: EXIT!")
+
+def add(domain: str, origin: str, command: str, path: str = None):
+ # DEBUG: print(f"DEBUG: domain='{domain}',origin='{origin}',command='{command}',path='{path}' - CALLED!")
+ if not isinstance(domain, str):
+ raise ValueError(f"Parameter domain[]={type(domain)} is not 'str'")
+ elif domain == "":
+ raise ValueError("Parameter 'domain' is empty")
+ elif not isinstance(origin, str) and origin is not None:
+ raise ValueError(f"origin[]={type(origin)} is not 'str'")
+ elif origin == "":
+ raise ValueError("Parameter 'origin' is empty")
+ elif not isinstance(command, str):
+ raise ValueError(f"command[]={type(command)} is not 'str'")
+ elif command == "":
+ raise ValueError("Parameter 'command' is empty")
+ elif not validators.domain(domain.split("/")[0]):
+ raise ValueError(f"Bad domain name='{domain}'")
+ elif origin is not None and not validators.domain(origin.split("/")[0]):
+ raise ValueError(f"Bad origin name='{origin}'")
+ elif blacklist.is_blacklisted(domain):
+ raise Exception(f"domain='{domain}' is blacklisted, but method invoked")
+ elif domain.find("/profile/") > 0 or domain.find("/users/") > 0:
+ raise Exception(f"domain='{domain}' is a single user")
+
+ # DEBUG: print("DEBUG: domain,origin,command,path:", domain, origin, command, path)
+ software = fba.determine_software(domain, path)
+ # DEBUG: print("DEBUG: Determined software:", software)
+ if domain.find("/c/") > 0 and software == "lemmy":
+ domain = domain.split("/c/")[0]
+ if is_registered(domain):
+ print(f"WARNING: domain='{domain}' already registered after cutting off user part. - EXIT!")
+ return
+
+ print(f"INFO: Adding instance domain='{domain}' (origin='{origin}',software='{software}')")
+ try:
+ fba.cursor.execute(
+ "INSERT INTO instances (domain, origin, command, hash, software, first_seen) VALUES (?, ?, ?, ?, ?, ?)",
+ (
+ domain,
+ origin,
+ command,
+ fba.get_hash(domain),
+ software,
+ time.time()
+ ),
+ )
+
+ cache.set_sub_key("is_registered", domain, True)
+
+ if has_pending_instance_data(domain):
+ # DEBUG: print(f"DEBUG: domain='{domain}' has pending nodeinfo being updated ...")
+ set("last_status_code" , domain, None)
+ set("last_error_details", domain, None)
+ update_data(domain)
+ fba.remove_pending_error(domain)
+
+ if domain in fba.pending_errors:
+ # DEBUG: print("DEBUG: domain has pending error being updated:", domain)
+ update_last_error(domain, fba.pending_errors[domain])
+ fba.remove_pending_error(domain)
+
+ except BaseException as exception:
+ print(f"ERROR: failed SQL query: domain='{domain}',exception[{type(exception)}]:'{str(exception)}'")