]> git.mxchange.org Git - fba.git/commitdiff
API now returns reasons
authorEnju Aihara <9839590-EnjuAihara@users.noreply.gitlab.com>
Thu, 14 Apr 2022 12:04:53 +0000 (14:04 +0200)
committerEnju Aihara <9839590-EnjuAihara@users.noreply.gitlab.com>
Thu, 14 Apr 2022 12:04:53 +0000 (14:04 +0200)
api.py

diff --git a/api.py b/api.py
index da21c1fcba3a335a69fd97c42395e3c07b535cf9..c6b9a338d40a1b7b40d5afffdd4063afffd15b15 100644 (file)
--- 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}