This commit is contained in:
j3d1 2024-05-04 03:08:00 +02:00
parent 42509388bd
commit 07b4cc8e23

View file

@ -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)