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)