From cff3bc30b825f4e83395560218fb1ecd270cb856 Mon Sep 17 00:00:00 2001 From: Izalia Mae Date: Mon, 26 Aug 2024 22:23:04 -0400 Subject: [PATCH] ensure log level for workers gets updated --- relay/database/connection.py | 1 + relay/views/api.py | 10 ++++++++-- relay/workers.py | 4 ---- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/relay/database/connection.py b/relay/database/connection.py index e18278a..1053294 100644 --- a/relay/database/connection.py +++ b/relay/database/connection.py @@ -141,6 +141,7 @@ class Connection(SqlConnection): return self.execute("SELECT * FROM inboxes WHERE accepted = 1").all(schema.Instance) + # todo: check if software is different than stored row def put_inbox(self, domain: str, inbox: str | None = None, diff --git a/relay/views/api.py b/relay/views/api.py index b1b820b..960e9f1 100644 --- a/relay/views/api.py +++ b/relay/views/api.py @@ -276,7 +276,10 @@ class Config(View): raise HttpError(400, 'Invalid key') with self.database.session() as conn: - conn.put_config(data['key'], data['value']) + value = conn.put_config(data['key'], data['value']) + + if data['key'] == 'log-level': + self.app.workers.set_log_level(value) return Response.new({'message': 'Updated config'}, ctype = 'json') @@ -288,7 +291,10 @@ class Config(View): raise HttpError(400, 'Invalid key') with self.database.session() as conn: - conn.put_config(data['key'], ConfigData.DEFAULT(data['key'])) + value = conn.put_config(data['key'], ConfigData.DEFAULT(data['key'])) + + if data['key'] == 'log-level': + self.app.workers.set_log_level(value) return Response.new({'message': 'Updated config'}, ctype = 'json') diff --git a/relay/workers.py b/relay/workers.py index 9fee7b1..963a54c 100644 --- a/relay/workers.py +++ b/relay/workers.py @@ -118,10 +118,6 @@ class PushWorkers(list[PushWorker]): self._count: int = count - def push_item(self, item: QueueItem) -> None: - self.queue.put(item) - - def push_message(self, inbox: str, message: Message, instance: Instance) -> None: self.queue.put(PostItem(inbox, message, instance))