return None
# NOISY-DEBUG: print("DEBUG: json():", len(json), json)
- if "software" not in json or "name" not in json["software"]:
+ if "status" in json and json["status"] == "error" and "message" in json:
+ print("WARNING: JSON response is an error:", json["message"])
+ update_last_error(domain, json["message"])
+ return None
+ elif "software" not in json or "name" not in json["software"]:
print("WARNING: JSON response does not include [software][name], guessing ...")
found = 0
- for element in {"uri", "title", "description", "email", "version", "urls", "stats", "thumbnail", "languages", "contact_account"}:
+ for element in {"uri", "title", "short_description", "description", "email", "version", "urls", "stats", "thumbnail", "languages", "contact_account", "registrations", "approval_required"}:
+ # NOISY-DEBUG: print("DEBUG: element:", element)
if element in json:
found = found + 1
# NOISY-DEBUG: print("DEBUG: Maybe is Mastodon:", domain)
return "mastodon"
- print("WARNING: Cannot guess software type:", domain, found, len(json))
+ print(f"WARNING: Cannot guess software type: domain='{domain}',found={found},json()={len(json)}")
return None
software = tidyup(json["software"]["name"])
return software
def update_block_reason(reason: str, blocker: str, blocked: str, block_level: str):
- # NOISY: # NOISY-DEBUG: print("DEBUG: Updating block reason:", reason, blocker, blocked, block_level)
+ # NOISY-DEBUG: print("DEBUG: Updating block reason:", reason, blocker, blocked, block_level)
try:
cursor.execute(
"UPDATE blocks SET reason = ?, last_seen = ? WHERE blocker = ? AND blocked = ? AND block_level = ? AND reason = ''",
sys.exit(255)
def update_last_seen(blocker: str, blocked: str, block_level: str):
- # NOISY: # NOISY-DEBUG: print("DEBUG: Updating last_seen for:", blocker, blocked, block_level)
+ # NOISY-DEBUG: print("DEBUG: Updating last_seen for:", blocker, blocked, block_level)
try:
cursor.execute(
"UPDATE blocks SET last_seen = ? WHERE blocker = ? AND blocked = ? AND block_level = ?",