mirror of
https://github.com/maxdorninger/MediaManager.git
synced 2026-04-21 16:25:36 +02:00
modify notification module config
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
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 (
|
||||
@@ -5,10 +7,14 @@ from media_manager.notification.service_providers.abstractNotificationServicePro
|
||||
)
|
||||
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
|
||||
self.config = AllEncompassingConfig().notifications.email_notifications
|
||||
|
||||
def send_notification(self, message: MessageNotification) -> bool:
|
||||
subject = "MediaManager - " + message.title
|
||||
@@ -23,7 +29,10 @@ class EmailNotificationServiceProvider(AbstractNotificationServiceProvider):
|
||||
</body>
|
||||
</html>
|
||||
"""
|
||||
media_manager.notification.utils.send_email(
|
||||
subject=subject, html=html, addressee=self.config.email
|
||||
)
|
||||
|
||||
for email in self.config.emails:
|
||||
media_manager.notification.utils.send_email(
|
||||
subject=subject, html=html, addressee=email
|
||||
)
|
||||
|
||||
return True
|
||||
|
||||
Reference in New Issue
Block a user