Add deletion for deploy

This commit is contained in:
moanos [he/him] 2023-01-11 20:13:27 +01:00
parent ddc7fb5936
commit de5b454ed6

View File

@ -1,3 +1,5 @@
import logging
import requests
@ -108,11 +110,17 @@ class Instance:
def apply_blocks_from_diff(diffs, server, token):
for diff in diffs:
if diff["local"] is None:
pass
"""Delete the block on the remote server"""
diff['remote'].delete(server, token)
logging.info(f"Deleted {diff['remote'].domain} from blocklist")
elif diff["remote"] is None:
"""Add the block on the remote server"""
diff["local"].apply(server, token)
logging.info(f"Added {diff['remote'].domain} to blocklist")
else:
"""Update the block on the remote server"""
diff["local"].apply(server, token, block_id=diff["remote"].id)
logging.info(f"Updated {diff['remote'].domain} in blocklist")
@staticmethod
def show_diffs(local_blocklist, remote_blocklist):