mirror of
https://git.kiwifarms.net/mint/fedi-block-api.git
synced 2024-10-23 03:09:06 +00:00
dont delete blocks
This commit is contained in:
parent
eec20e4659
commit
5862133eb8
1 changed files with 18 additions and 10 deletions
|
@ -75,7 +75,6 @@ for blocker, software in c.fetchall():
|
||||||
print(blocker)
|
print(blocker)
|
||||||
try:
|
try:
|
||||||
# Blocks
|
# Blocks
|
||||||
c.execute("delete from blocks where blocker = ?", (blocker,))
|
|
||||||
federation = get(
|
federation = get(
|
||||||
f"https://{blocker}/nodeinfo/2.1.json", headers=headers, timeout=5
|
f"https://{blocker}/nodeinfo/2.1.json", headers=headers, timeout=5
|
||||||
).json()["metadata"]["federation"]
|
).json()["metadata"]["federation"]
|
||||||
|
@ -95,6 +94,11 @@ for blocker, software in c.fetchall():
|
||||||
"insert into instances select ?, ?, ?",
|
"insert into instances select ?, ?, ?",
|
||||||
(blocked, get_hash(blocked), get_type(blocked)),
|
(blocked, get_hash(blocked), get_type(blocked)),
|
||||||
)
|
)
|
||||||
|
c.execute(
|
||||||
|
"select * from blocks where blocker = ? and blocked = ? and block_level = ?",
|
||||||
|
(blocker, blocked, block_level),
|
||||||
|
)
|
||||||
|
if c.fetchone() == None:
|
||||||
c.execute(
|
c.execute(
|
||||||
"insert into blocks select ?, ?, '', ?",
|
"insert into blocks select ?, ?, '', ?",
|
||||||
(blocker, blocked, block_level),
|
(blocker, blocked, block_level),
|
||||||
|
@ -119,7 +123,6 @@ for blocker, software in c.fetchall():
|
||||||
elif software == "mastodon":
|
elif software == "mastodon":
|
||||||
print(blocker)
|
print(blocker)
|
||||||
try:
|
try:
|
||||||
c.execute("delete from blocks where blocker = ?", (blocker,))
|
|
||||||
json = get_mastodon_blocks(blocker)
|
json = get_mastodon_blocks(blocker)
|
||||||
for block_level, blocks in json.items():
|
for block_level, blocks in json.items():
|
||||||
for instance in blocks:
|
for instance in blocks:
|
||||||
|
@ -133,6 +136,11 @@ for blocker, software in c.fetchall():
|
||||||
"insert into instances select ?, ?, ?",
|
"insert into instances select ?, ?, ?",
|
||||||
(blocked, get_hash(blocked), get_type(blocked)),
|
(blocked, get_hash(blocked), get_type(blocked)),
|
||||||
)
|
)
|
||||||
|
c.execute(
|
||||||
|
"select * from blocks where blocker = ? and blocked = ? and block_level = ?",
|
||||||
|
(blocker, blocked, block_level),
|
||||||
|
)
|
||||||
|
if c.fetchone() == None:
|
||||||
c.execute(
|
c.execute(
|
||||||
"insert into blocks select ?, ?, ?, ?",
|
"insert into blocks select ?, ?, ?, ?",
|
||||||
(
|
(
|
||||||
|
|
Loading…
Reference in a new issue