]> git.mxchange.org Git - fba.git/commitdiff
only clear blocks if theres no error
authorEnju Aihara <5-EnjuAihara@users.noreply.gitlab.varis.social>
Sat, 5 Mar 2022 08:41:11 +0000 (09:41 +0100)
committerEnju Aihara <5-EnjuAihara@users.noreply.gitlab.varis.social>
Sat, 5 Mar 2022 08:41:11 +0000 (09:41 +0100)
fetch_blocks.py

index 1f4409ae9b95a25cb709cd4accba65b597cb0cd3..6c7491b0e5e7d92a4be32a4b8fb8513112bafda7 100644 (file)
@@ -8,9 +8,8 @@ c = conn.cursor()
 with open("pleroma_instances.txt", "r") as f:
     while blocker := f.readline().strip():
         print(blocker)
-        c.execute("delete from blocks where blocker = ?", (blocker,))
-        conn.commit()
         try:
+            c.execute("delete from blocks where blocker = ?", (blocker,))
             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]:
@@ -30,9 +29,8 @@ with open("pleroma_instances.txt", "r") as f:
 with open("mastodon_instances.txt", "r") as f:
     while blocker := f.readline().strip():
         print(blocker)
-        c.execute("delete from blocks where blocker = ?", (blocker,))
-        conn.commit()
         try:
+            c.execute("delete from blocks where blocker = ?", (blocker,))
             json = loads(get(f"http://127.0.0.1:8069/{blocker}").text)
             for blocked in json["reject"]:
                 if blocked["domain"].count("*") > 1: