This commit is contained in:
j3d1 2024-05-04 03:08:00 +02:00
parent d9d4d5092f
commit 0e4717cc1e

View file

@ -1,3 +1,5 @@
import asyncio
from aiohttp.client import ClientSession from aiohttp.client import ClientSession
from channels.layers import get_channel_layer from channels.layers import get_channel_layer
from channels.db import database_sync_to_async from channels.db import database_sync_to_async
@ -69,13 +71,15 @@ class NotificationDispatcher:
title = f"{ticket.name} [#{ticket.short_uuid()}]" title = f"{ticket.name} [#{ticket.short_uuid()}]"
print("Dispatching message:", message, "with event_id:", event_id) print("Dispatching message:", message, "with event_id:", event_id)
targets = await self.get_notification_targets() 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: for target in targets:
if target.channel_type == 'telegram': if target.channel_type == 'telegram':
print("Sending telegram notification to:", target.channel_target) 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': elif target.channel_type == 'email':
print("Sending email notification to:", target.channel_target) 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: else:
print("Unknown channel type:", target.channel_type) print("Unknown channel type:", target.channel_type)
await asyncio.gather(*jobs)