13 Commits

Author SHA1 Message Date
3dce62417e refactor: Cleaner solution for exportable dict 2023-01-26 12:05:12 +01:00
Georg Krause
d4c754c103 Merge branch 'develop' 2023-01-26 11:54:22 +01:00
8a8a725002 fix: Remove id from export
As this wil not be the same id on other instances exporting it does not make sense
2023-01-25 23:36:25 +01:00
58998e1c17 fix: Allow name to be empty in local blocklist 2023-01-25 23:35:04 +01:00
a484a41b45 Merge branch 'develop' of https://git.gieszer.link/gcrkrause/mastodon-blocklist-deploy into develop 2023-01-22 18:23:54 +01:00
Georg Krause
7ad318bc48 feat: Build docker image in CI 2023-01-18 12:02:56 +01:00
Georg Krause
8d5676d0b2 refactor: Avoid manually templating toml file entries 2023-01-13 13:56:56 +01:00
6d2a4d82b4 fix: Avoid exception when input is missing for diff and deploy 2023-01-13 13:56:55 +01:00
Georg Krause
d9d3f02fda feat: Add Dockerfile for development and deployment 2023-01-13 13:56:55 +01:00
0fca58810a feat: Allow token via environment variables 2023-01-13 13:56:55 +01:00
181ac45bbf refactor: Rename load_remote_blocklist->load_blocklist_from_instance 2023-01-13 13:56:43 +01:00
6a2a13bd74 refactor: Add missing return types 2023-01-13 13:56:43 +01:00
0dd6930c0f refactor: Rename load_local_blocklist -> load_blocklist_file 2023-01-13 13:56:43 +01:00
3 changed files with 37 additions and 5 deletions

23
.drone.yml Normal file
View File

@@ -0,0 +1,23 @@
---
kind: pipeline
type: exec
name: build
platform:
os: linux
arch: arm64
steps:
- name: build
commands:
- docker build -t gcrkrause/mastodon-blocklist-deploy .
- name: push
environment:
USERNAME:
from_secret: docker-hub-user
PASSWORD:
from_secret: docker-hub-pw
commands:
- docker login -u $USERNAME -p $PASSWORD
- docker push gcrkrause/mastodon-blocklist-deploy
- docker image prune -a -f

View File

@@ -64,8 +64,6 @@ def cli():
else:
token = os.getenv('MBD_TOKEN')
"""if there is a remote blocklist provided load this instead of fetching it from a server (for debugging reasons)"""
if args.remote_blocklist:
with open(args.remote_blocklist) as f:
@@ -92,10 +90,10 @@ def cli():
Instance.apply_blocks_from_diff(diffs, args.server, token, args.no_delete)
elif args.action == "export":
if not args.output:
print(toml.dumps({"instances": [b.__dict__ for b in remote_blocklist]}))
print(toml.dumps({"instances": [b.exportable_dict for b in remote_blocklist]}))
else:
with open(args.output, "w") as f:
toml.dump({"instances": [b.__dict__ for b in remote_blocklist]}, f)
toml.dump({"instances": [b.exportable_dict for b in remote_blocklist]}, f)
if __name__ == "__main__":

View File

@@ -27,6 +27,14 @@ class Instance:
def status_str(self):
return f"{self.severity}\nReject reports: {self.reject_reports}\nReject media: {self.reject_media}\nObfuscate: {self.obfuscate}"
@property
def exportable_dict(self):
keys = ["domain", "severity", "public_comment", "private_comment", "obfuscate", "reject_media", "reject_reports"]
exportable = {}
for key in keys:
exportable[key] = getattr(self, key)
return exportable
def parse_remote_block(self, instance_dict):
self.domain = instance_dict["domain"]
self.id = instance_dict["id"]
@@ -38,7 +46,10 @@ class Instance:
self.reject_reports = instance_dict["reject_reports"]
def parse_local_block(self, instance_dict):
self.name = instance_dict["name"]
try:
self.name = instance_dict["name"]
except KeyError:
pass
self.domain = instance_dict["domain"]
self.severity = instance_dict["severity"]
self.public_comment = instance_dict["public_comment"]