37 lines
1.2 KiB
Python
37 lines
1.2 KiB
Python
from typing import Dict
|
|
from app.notification.backend.business.notification_manager import NotificationManager
|
|
from app.notification.backend.models.constants import NotificationChannel
|
|
|
|
|
|
class NotificationHub:
|
|
def __init__(self):
|
|
pass
|
|
|
|
async def enqueue_notification(
|
|
self,
|
|
channels: list[str], # Accept multiple channels as a list of strings
|
|
receiver_id: str,
|
|
subject: str,
|
|
event: str,
|
|
properties: Dict,
|
|
):
|
|
# Convert string channels to NotificationChannel enums
|
|
notification_channels = []
|
|
for channel_str in channels:
|
|
try:
|
|
notification_channels.append(NotificationChannel[channel_str.upper()])
|
|
except KeyError:
|
|
raise ValueError(f"Unsupported notification channel: {channel_str}")
|
|
|
|
# Initialize NotificationManager with sender_id
|
|
notification_manager = NotificationManager()
|
|
|
|
# Call the enqueue_notification method in NotificationManager
|
|
return await notification_manager.enqueue_notification(
|
|
channels=notification_channels,
|
|
receiver_id=receiver_id,
|
|
subject=subject,
|
|
event=event,
|
|
properties=properties,
|
|
)
|