cleaned code a bit
This commit is contained in:
parent
7b3cec623e
commit
012fd3ceef
@ -58,8 +58,8 @@ for instance in c.fetchall():
|
|||||||
for blocked in json["metadata"]["federation"]["mrf_simple"][mrf]:
|
for blocked in json["metadata"]["federation"]["mrf_simple"][mrf]:
|
||||||
if blocked == "":
|
if blocked == "":
|
||||||
continue
|
continue
|
||||||
c.execute("select case when ? in (select domain from instances) then 1 else 0 end", (blocked,))
|
c.execute("select domain from instances where domain = ?", (blocked,))
|
||||||
if c.fetchone() == (0,):
|
if c.fetchone() == None:
|
||||||
c.execute("insert into instances select ?, ?, ?", (blocked, sha256(bytes(blocked, "utf-8")).hexdigest(), get_type(blocked)))
|
c.execute("insert into instances select ?, ?, ?", (blocked, sha256(bytes(blocked, "utf-8")).hexdigest(), get_type(blocked)))
|
||||||
c.execute("insert into blocks select ?, ?, '', ?", (blocker, blocked, mrf))
|
c.execute("insert into blocks select ?, ?, '', ?", (blocker, blocked, mrf))
|
||||||
# Quarantined Instances
|
# Quarantined Instances
|
||||||
@ -67,8 +67,8 @@ for instance in c.fetchall():
|
|||||||
for blocked in json["metadata"]["federation"]["quarantined_instances"]:
|
for blocked in json["metadata"]["federation"]["quarantined_instances"]:
|
||||||
if blocked == "":
|
if blocked == "":
|
||||||
continue
|
continue
|
||||||
c.execute("select case when ? in (select domain from instances) then 1 else 0 end", (blocked,))
|
c.execute("select domain from instances where domain = ?", (blocked,))
|
||||||
if c.fetchone() == (0,):
|
if c.fetchone() == None:
|
||||||
c.execute("insert into instances select ?, ?, ?", (blocked, sha256(bytes(blocked, "utf-8")).hexdigest(), get_type(blocked)))
|
c.execute("insert into instances select ?, ?, ?", (blocked, sha256(bytes(blocked, "utf-8")).hexdigest(), get_type(blocked)))
|
||||||
c.execute("insert into blocks select ?, ?, '', 'quarantined_instances'", (blocker, blocked))
|
c.execute("insert into blocks select ?, ?, '', 'quarantined_instances'", (blocker, blocked))
|
||||||
conn.commit()
|
conn.commit()
|
||||||
@ -94,8 +94,8 @@ for instance in c.fetchall():
|
|||||||
if blocked["domain"].count("*") > 1:
|
if blocked["domain"].count("*") > 1:
|
||||||
c.execute("insert into blocks select ?, ifnull((select domain from instances where hash = ?), ?), ?, ?", (blocker, blocked["hash"], blocked["hash"], blocked['reason'], block_level))
|
c.execute("insert into blocks select ?, ifnull((select domain from instances where hash = ?), ?), ?, ?", (blocker, blocked["hash"], blocked["hash"], blocked['reason'], block_level))
|
||||||
else:
|
else:
|
||||||
c.execute("select case when ? in (select domain from instances) then 1 else 0 end", (blocked["domain"],))
|
c.execute("select domain from instances where domain = ?", (blocked["domain"],))
|
||||||
if c.fetchone() == (0,):
|
if c.fetchone() == None:
|
||||||
c.execute("insert into instances select ?, ?, ?", (blocked["domain"], sha256(bytes(blocked["domain"], "utf-8")).hexdigest(), get_type(blocked["domain"])))
|
c.execute("insert into instances select ?, ?, ?", (blocked["domain"], sha256(bytes(blocked["domain"], "utf-8")).hexdigest(), get_type(blocked["domain"])))
|
||||||
c.execute("insert into blocks select ?, ?, ?, ?", (blocker, blocked["domain"], blocked["reason"], block_level))
|
c.execute("insert into blocks select ?, ?, ?, ?", (blocker, blocked["domain"], blocked["reason"], block_level))
|
||||||
conn.commit()
|
conn.commit()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user