feat(domain): models
This commit is contained in:
24
crates/domain/src/models/notification.rs
Normal file
24
crates/domain/src/models/notification.rs
Normal file
@@ -0,0 +1,24 @@
|
||||
use chrono::{DateTime, Utc};
|
||||
use crate::value_objects::{NotificationId, UserId, ThoughtId};
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub enum NotificationType { Like, Boost, Follow, Mention, Reply }
|
||||
impl NotificationType {
|
||||
pub fn from_str(s: &str) -> Self {
|
||||
match s { "like" => Self::Like, "boost" => Self::Boost, "follow" => Self::Follow, "mention" => Self::Mention, _ => Self::Reply }
|
||||
}
|
||||
pub fn as_str(&self) -> &str {
|
||||
match self { Self::Like => "like", Self::Boost => "boost", Self::Follow => "follow", Self::Mention => "mention", Self::Reply => "reply" }
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct Notification {
|
||||
pub id: NotificationId,
|
||||
pub user_id: UserId,
|
||||
pub notification_type: NotificationType,
|
||||
pub from_user_id: Option<UserId>,
|
||||
pub thought_id: Option<ThoughtId>,
|
||||
pub read: bool,
|
||||
pub created_at: DateTime<Utc>,
|
||||
}
|
||||
Reference in New Issue
Block a user