From ce11d2dff1070fcc009c8092fd8a18a9b06089a4 Mon Sep 17 00:00:00 2001 From: jedi Date: Sat, 4 May 2024 00:10:38 +0200 Subject: [PATCH] stash --- core/notifications/dispatch.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/core/notifications/dispatch.py b/core/notifications/dispatch.py index 389535e..4285852 100644 --- a/core/notifications/dispatch.py +++ b/core/notifications/dispatch.py @@ -43,7 +43,7 @@ class NotificationDispatcher: @database_sync_to_async def get_ticket(self, ticket_id): - return IssueThread.objects.get(id=ticket_id) + return IssueThread.objects.get(id=ticket_id).prefetch_related('event') async def run_forever(self): # Infinite loop to continuously listen for messages @@ -64,8 +64,7 @@ class NotificationDispatcher: print("Error: Invalid message format") async def dispatch(self, ticket, event_id, new): - message = database_sync_to_async(render_notification_new_ticket)(ticket) if new else database_sync_to_async( - render_notification_reply_ticket)(ticket) + message = render_notification_new_ticket(ticket) if new else await render_notification_reply_ticket(ticket) print("Dispatching message:", message, "with event_id:", event_id) targets = await self.get_notification_targets() await telegram_notify(message, TELEGRAM_GROUP_CHAT_ID)