koprogo_api/application/ports/
notification_preference_repository.rs1use crate::domain::entities::{NotificationChannel, NotificationPreference, NotificationType};
2use async_trait::async_trait;
3use uuid::Uuid;
4
5#[async_trait]
6pub trait NotificationPreferenceRepository: Send + Sync {
7 async fn create(
9 &self,
10 preference: &NotificationPreference,
11 ) -> Result<NotificationPreference, String>;
12
13 async fn find_by_id(&self, id: Uuid) -> Result<Option<NotificationPreference>, String>;
15
16 async fn find_by_user_and_type(
18 &self,
19 user_id: Uuid,
20 notification_type: NotificationType,
21 ) -> Result<Option<NotificationPreference>, String>;
22
23 async fn find_by_user(&self, user_id: Uuid) -> Result<Vec<NotificationPreference>, String>;
25
26 async fn update(
28 &self,
29 preference: &NotificationPreference,
30 ) -> Result<NotificationPreference, String>;
31
32 async fn delete(&self, id: Uuid) -> Result<bool, String>;
34
35 async fn is_channel_enabled(
37 &self,
38 user_id: Uuid,
39 notification_type: NotificationType,
40 channel: NotificationChannel,
41 ) -> Result<bool, String>;
42
43 async fn create_defaults_for_user(
45 &self,
46 user_id: Uuid,
47 ) -> Result<Vec<NotificationPreference>, String>;
48}