scoreboard = []
for domain, highscore in scores:
- scoreboard.append({"domain": domain, "highscore": highscore})
+ scoreboard.append({
+ "domain" : domain,
+ "highscore": highscore
+ })
return scoreboard
block["first_added"] = datetime.utcfromtimestamp(block["first_added"]).strftime('%Y-%m-%d %H:%M')
block["last_seen"] = datetime.utcfromtimestamp(block["last_seen"]).strftime('%Y-%m-%d %H:%M')
- return templates.TemplateResponse("index.html", {"request": request, "domain": domain, "blocks": blocks, "reason": reason, "reverse": reverse, "info": info})
+ return templates.TemplateResponse("index.html", {
+ "request": request,
+ "domain" : domain,
+ "blocks" : blocks,
+ "reason" : reason,
+ "reverse": reverse,
+ "info" : info
+ })
@app.get(fba.config["base_url"] + "/api/mutual")
def mutual(domains: list[str] = Query()):
for line in header.find_all_next("table")[0].find_all("tr")[1:]:
blocks[header_text].append(
{
- "domain": line.find("span").text,
- "hash": line.find("span")["title"][9:],
- "reason": line.find_all("td")[1].text.strip(),
+ "domain": tidyup(line.find("span").text),
+ "hash" : tidyup(line.find("span")["title"][9:]),
+ "reason": tidyup(line.find_all("td")[1].text),
}
)
# NOISY-DEBUG: print("DEBUG: Returning blocks for domain:", domain)
return {
- "reject": blocks["Suspended servers"],
- "media_removal": blocks["Filtered media"],
+ "reject" : blocks["Suspended servers"],
+ "media_removal" : blocks["Filtered media"],
"followers_only": blocks["Limited servers"] + blocks["Silenced servers"],
}
for line in blocklist.find("table").find_all("tr")[1:]:
blocks.append({
- "domain": line.find_all("td")[0].text.strip(),
- "reason": line.find_all("td")[1].text.strip()
+ "domain": tidyup(line.find_all("td")[0].text),
+ "reason": tidyup(line.find_all("td")[1].text)
})
# NOISY-DEBUG: print("DEBUG: Returning blocks() for domain:", domain, len(blocks))
if instance["isSuspended"]:
blocks["suspended"].append(
{
- "domain": instance["host"],
+ "domain": tidyup(instance["host"]),
# no reason field, nothing
"reason": ""
}
for instance in doc:
if instance["isBlocked"]:
blocks["blocked"].append({
- "domain": instance["host"],
+ "domain": tidyup(instance["host"]),
"reason": ""
})
print("WARNING: API request failed for domain:", domain)
return {}
-def tidyup(domain: str) -> str:
+def tidyup(string: str) -> str:
+ # NOISY-DEBUG: print("DEBUG: BEFORE string:", string)
+
# some retards put their blocks in variable case
- domain = domain.lower()
+ string = string.lower().strip()
# other retards put the port
- domain = re.sub("\:\d+$", "", domain)
+ string = re.sub("\:\d+$", "", string)
# bigger retards put the schema in their blocklist, sometimes even without slashes
- domain = re.sub("^https?\:(\/*)", "", domain)
+ string = re.sub("^https?\:(\/*)", "", string)
# and trailing slash
- domain = re.sub("\/$", "", domain)
+ string = re.sub("\/$", "", string)
# and the @
- domain = re.sub("^\@", "", domain)
+ string = re.sub("^\@", "", string)
# the biggest retards of them all try to block individual users
- domain = re.sub("(.+)\@", "", domain)
+ string = re.sub("(.+)\@", "", string)
- return domain
+ # NOISY-DEBUG: print("DEBUG: AFTER string:", string)
+ return string
fba.connection.commit()
except Exception as e:
print("error:", e, blocker, software)
- elif software == "friendica" or software == "misskey":
+ elif software == "friendica" or software == "misskey" or software == "bookwyrm":
print("INFO: blocker:", blocker)
try:
if software == "friendica":
json = fba.get_friendica_blocks(blocker)
elif software == "misskey":
json = fba.get_misskey_blocks(blocker)
+ elif software == "bookwyrm":
+ json = fba.get_bookwyrm_blocks(blocker)
for block_level, blocks in json.items():
# NOISY-DEBUG: print("DEBUG: blocker,block_level,blocks():", blocker, block_level, len(blocks))