From 07b4cc8e23b1b3c81d6e062ab29af62ebae4b238 Mon Sep 17 00:00:00 2001 From: jedi Date: Sat, 4 May 2024 03:08:00 +0200 Subject: [PATCH] stash --- core/notifications/dispatch.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/core/notifications/dispatch.py b/core/notifications/dispatch.py index 92c22d4..fc8900e 100644 --- a/core/notifications/dispatch.py +++ b/core/notifications/dispatch.py @@ -1,3 +1,5 @@ +import asyncio + from aiohttp.client import ClientSession from channels.layers import get_channel_layer from channels.db import database_sync_to_async @@ -69,13 +71,15 @@ class NotificationDispatcher: title = f"{ticket.name} [#{ticket.short_uuid()}]" print("Dispatching message:", message, "with event_id:", event_id) targets = await self.get_notification_targets() - # await telegram_notify(message, TELEGRAM_GROUP_CHAT_ID) + jobs = [] + # jobs.append(telegram_notify(message, TELEGRAM_GROUP_CHAT_ID)) for target in targets: if target.channel_type == 'telegram': print("Sending telegram notification to:", target.channel_target) - await telegram_notify(message, target.channel_target) + jobs.append(telegram_notify(message, target.channel_target)) elif target.channel_type == 'email': print("Sending email notification to:", target.channel_target) - await email_notify(message, title, target.channel_target) + jobs.append(email_notify(message, title, target.channel_target)) else: print("Unknown channel type:", target.channel_type) + await asyncio.gather(*jobs)