From 90234a972434358852d501c9021e9203ec2c77a7 Mon Sep 17 00:00:00 2001 From: Izalia Mae Date: Sun, 4 Dec 2022 01:20:17 -0500 Subject: [PATCH] move apkeys out of RelayConfig and rename relay_software_names --- relay/config.py | 21 ++++++++++----------- relay/manage.py | 6 +++--- 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/relay/config.py b/relay/config.py index 9af25bc..77b5db4 100644 --- a/relay/config.py +++ b/relay/config.py @@ -9,23 +9,22 @@ from urllib.parse import urlparse from .misc import DotDict, boolean -relay_software_names = [ +RELAY_SOFTWARE = [ 'activityrelay', # https://git.pleroma.social/pleroma/relay 'aoderelay', # https://git.asonix.dog/asonix/relay 'feditools-relay' # https://git.ptzo.gdn/feditools/relay ] +APKEYS = [ + 'host', + 'whitelist_enabled', + 'blocked_software', + 'blocked_instances', + 'whitelist' +] + class RelayConfig(DotDict): - apkeys = { - 'host', - 'whitelist_enabled', - 'blocked_software', - 'blocked_instances', - 'whitelist' - } - - def __init__(self, path): DotDict.__init__(self, {}) @@ -243,7 +242,7 @@ class RelayConfig(DotDict): 'workers': self.workers, 'json_cache': self.json_cache, 'timeout': self.timeout, - 'ap': {key: self[key] for key in self.apkeys} + 'ap': {key: self[key] for key in APKEYS} } with open(self._path, 'w') as fd: diff --git a/relay/manage.py b/relay/manage.py index 0b58ecb..1bf2c03 100644 --- a/relay/manage.py +++ b/relay/manage.py @@ -8,7 +8,7 @@ from urllib.parse import urlparse from . import misc, __version__ from .application import Application -from .config import relay_software_names +from .config import RELAY_SOFTWARE app = None @@ -314,7 +314,7 @@ def cli_software_ban(name, fetch_nodeinfo): 'Ban software. Use RELAYS for NAME to ban relays' if name == 'RELAYS': - for name in relay_software_names: + for name in RELAY_SOFTWARE: app.config.ban_software(name) app.config.save() @@ -344,7 +344,7 @@ def cli_software_unban(name, fetch_nodeinfo): 'Ban software. Use RELAYS for NAME to unban relays' if name == 'RELAYS': - for name in relay_software_names: + for name in RELAY_SOFTWARE: app.config.unban_software(name) app.config.save()