Files
MediaManager/media_manager/notification/service_providers/email.py
2025-07-10 23:48:29 +02:00

39 lines
1.3 KiB
Python

from pydantic_settings import BaseSettings
import media_manager.notification.utils
from media_manager.notification.schemas import MessageNotification
from media_manager.notification.service_providers.abstractNotificationServiceProvider import (
AbstractNotificationServiceProvider,
)
from media_manager.config import AllEncompassingConfig
class EmailNotificationsConfig(BaseSettings):
enabled: bool = False
emails: list[str] = [] # the email addresses to send notifications to
class EmailNotificationServiceProvider(AbstractNotificationServiceProvider):
def __init__(self):
self.config = AllEncompassingConfig().notifications.email_notifications
def send_notification(self, message: MessageNotification) -> bool:
subject = "MediaManager - " + message.title
html = f"""\
<html>
<body>
<br>
{message.message}
<br>
<br>
This is an automated message from MediaManager.</p>
</body>
</html>
"""
for email in self.config.emails:
media_manager.notification.utils.send_email(
subject=subject, html=html, addressee=email
)
return True