def info():
fba.c.execute("SELECT (SELECT count(domain) FROM instances), (SELECT count(domain) FROM instances WHERE software IN ('pleroma', 'mastodon', 'misskey', 'gotosocial', 'friendica')), (SELECT count(blocker) FROM blocks)")
known, indexed, blocks = fba.c.fetchone()
- fba.c.close()
+
return {
"known_instances": known,
"indexed_instances": indexed,
raise HTTPException(status_code=400, detail="Too many results")
fba.c.execute("SELECT blocker, count(blocker) FROM blocks WHERE block_level = 'reject' group by blocker ORDER BY count(blocker) DESC LIMIT ?", (blockers,))
scores = fba.c.fetchall()
- fba.c.close()
scoreboard = []
print(scores)
else:
fba.c.execute("SELECT blocker, blocked, block_level, reason, first_added, last_seen FROM blocks WHERE reason like ? AND reason != '' ORDER BY first_added asc", ("%"+reason+"%",))
blocks = fba.c.fetchall()
- fba.c.close()
result = {}
for blocker, blocked, block_level, reason, first_added, last_seen in blocks:
elif blockers != None:
scores = get(f"http://127.0.0.1:{fba.config['base_url']}{fba.config['base_url']}/top?blockers={blockers}")
elif blocked != None:
- scores = get(f"http://127.0.0.1:{fba.config['base_url']}{fba.config['base_url']}/top?blocked={blocked}")
+ scores = get(f"http://127.0.0.1:{fba.config['port']}{fba.config['base_url']}/top?blocked={blocked}")
if scores != None:
if not scores.ok:
raise HTTPException(status_code=blocks.status_code, detail=blocks.text)
info = None
blocks = None
if domain == None and reason == None and reverse == None:
- info = get(f"http://127.0.0.1:{fba.config['base_url']}{fba.config['base_url']}/info")
+ info = get(f"http://127.0.0.1:{fba.config['port']}{fba.config['base_url']}/info")
if not info.ok:
raise HTTPException(status_code=info.status_code, detail=info.text)
info = info.json()
elif domain != None:
- blocks = get(f"http://127.0.0.1:{fba.config['base_url']}{fba.config['base_url']}/api?domain={domain}")
+ blocks = get(f"http://127.0.0.1:{fba.config['port']}{fba.config['base_url']}/api?domain={domain}")
elif reason != None:
- blocks = get(f"http://127.0.0.1:{fba.config['base_url']}{fba.config['base_url']}/api?reason={reason}")
+ blocks = get(f"http://127.0.0.1:{fba.config['port']}{fba.config['base_url']}/api?reason={reason}")
elif reverse != None:
- blocks = get(f"http://127.0.0.1:{fba.config['base_url']}{fba.config['base_url']}/api?reverse={reverse}")
+ blocks = get(f"http://127.0.0.1:{fba.config['port']}{fba.config['base_url']}/api?reverse={reverse}")
if blocks != None:
if not blocks.ok:
raise HTTPException(status_code=blocks.status_code, detail=blocks.text)
},
)
res = fba.c.fetchone()
- fba.c.close()
+
if res is not None:
# Blocks found
return responses.JSONResponse(status_code=418, content={})
+
# No known blocks
return responses.JSONResponse(status_code=200, content={})
fba.c.execute("SELECT blocker, blocked, block_level, reason, first_added, last_seen FROM blocks ORDER BY first_added DESC LIMIT 50")
blocks = fba.c.fetchall()
- fba.c.close()
result = []
for blocker, blocked, block_level, reason, first_added, last_seen in blocks: