From f54f8ff1010924d87533b58f07d487fb23cbbae1 Mon Sep 17 00:00:00 2001 From: Enju Aihara <9839590-EnjuAihara@users.noreply.gitlab.com> Date: Thu, 14 Apr 2022 14:04:53 +0200 Subject: [PATCH] API now returns reasons --- api.py | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/api.py b/api.py index da21c1f..c6b9a33 100644 --- a/api.py +++ b/api.py @@ -22,7 +22,7 @@ def info(): def blocked(domain: str): conn = sqlite3.connect("blocks.db") c = conn.cursor() - c.execute("select blocker, block_level from blocks where blocked = ?", (domain,)) + c.execute("select blocker, block_level, reason from blocks where blocked = ?", (domain,)) blocks = c.fetchall() conn.close() @@ -40,8 +40,23 @@ def blocked(domain: str): "reject_deletes": [], } - for domain, block_level in blocks: + reasons = { + "reject": {}, + "media_removal": {}, + "federated_timeline_removal": {}, + "media_nsfw": {}, + "quarantined_instances": {}, + "report_removal": {}, + "followers_only": {}, + "accept": {}, + "avatar_removal": {}, + "banner_removal": {}, + "reject_deletes": {}, + } + + for domain, block_level, reason in blocks: result[block_level].append(domain) + reasons[block_level][domain] = reason - return result + return result | {"reasons": reasons} -- 2.39.5