From e00823707d4eb87bd7a4f8fb607520dbe7aa2cf7 Mon Sep 17 00:00:00 2001
From: Enju Aihara <5-EnjuAihara@users.noreply.gitlab.varis.social>
Date: Sat, 5 Mar 2022 13:09:00 +0100
Subject: [PATCH] ignore empty blocks

---
 fetch_blocks.py | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/fetch_blocks.py b/fetch_blocks.py
index 27cbbab..aa30b8f 100644
--- a/fetch_blocks.py
+++ b/fetch_blocks.py
@@ -14,11 +14,15 @@ with open("pleroma_instances.txt", "r") as f:
             json = loads(get(f"https://{blocker}/nodeinfo/2.1.json").text)
             for mrf in json["metadata"]["federation"]["mrf_simple"]:
                 for blocked in json["metadata"]["federation"]["mrf_simple"][mrf]:
+                    if blocked == "":
+                        continue
                     c.execute("select case when ? in (select domain from instances) then 1 else 0 end", (blocked,))
                     if c.fetchone() == (0,):
                         c.execute("insert into instances select ?, ?", (blocked, sha256(bytes(blocked, "utf-8")).hexdigest()))
                     c.execute("insert into blocks select ?, ?, '', ?", (blocker, blocked, mrf))
             for blocked in json["metadata"]["federation"]["quarantined_instances"]:
+                if blocked == "":
+                    continue
                 c.execute("select case when ? in (select domain from instances) then 1 else 0 end", (blocked,))
                 if c.fetchone() == (0,):
                     c.execute("insert into instances select ?, ?", (blocked, sha256(bytes(blocked, "utf-8")).hexdigest()))
-- 
GitLab