mirror of
https://github.com/QuivrHQ/quivr.git
synced 2024-12-15 09:32:22 +03:00
e1ad3dfb2a
This pull request adds the implementation of the notifications feature, including the ability to create, update, and delete notifications.
42 lines
1.3 KiB
Python
42 lines
1.3 KiB
Python
from typing import List
|
|
from uuid import UUID
|
|
|
|
from models.settings import get_supabase_client
|
|
from modules.notification.dto.inputs import NotificationUpdatableProperties
|
|
from modules.notification.entity.notification import Notification
|
|
from modules.notification.repository.notifications import Notifications
|
|
from modules.notification.repository.notifications_interface import (
|
|
NotificationInterface,
|
|
)
|
|
|
|
|
|
class NotificationService:
|
|
repository: NotificationInterface
|
|
|
|
def __init__(self):
|
|
supabase_client = get_supabase_client()
|
|
self.repository = Notifications(supabase_client)
|
|
|
|
def add_notification(self, notification: Notification):
|
|
"""
|
|
Add a notification
|
|
"""
|
|
return self.repository.add_notification(notification)
|
|
|
|
def get_chat_notifications(self, chat_id: UUID) -> List[Notification]:
|
|
"""
|
|
Get notifications by chat_id
|
|
"""
|
|
return self.repository.get_notifications_by_chat_id(chat_id)
|
|
|
|
def update_notification_by_id(
|
|
self, notification_id, notification: NotificationUpdatableProperties
|
|
):
|
|
"""
|
|
Update a notification
|
|
"""
|
|
if notification:
|
|
return self.repository.update_notification_by_id(
|
|
notification_id, notification
|
|
)
|