if not res.ok or res.status_code >= 400:
res = reqto.get(f"https://{domain}/api/v3/site", headers=headers, timeout=(config["connection_timeout"], config["read_timeout"]))
- if "federated_instances" in json and "linked" in json["federated_instances"]:
+ if not res.ok or res.status_code >= 400:
+ print("WARNING: Could not reach any JSON API:", domain)
+ update_last_error(domain, res)
+ elif "federated_instances" in res.json() and "linked" in res.json()["federated_instances"]:
# NOISY-DEBUG: print("DEBUG: Found federated_instances", domain)
- peers = json["federated_instances"]["linked"] + json["federated_instances"]["allowed"] + json["federated_instances"]["blocked"]
+ peers = res.json()["federated_instances"]["linked"] + res.json()["federated_instances"]["allowed"] + res.json()["federated_instances"]["blocked"]
else:
- print("WARNING: Could not reach any JSON API:", domain)
+ print("WARNING: JSON response does not contain 'federated_instances':", domain)
update_last_error(domain, res)
else:
# NOISY-DEBUG: print("DEBUG:Querying API was successful:", domain, len(res.json()))