25 lines
876 B
Rust
25 lines
876 B
Rust
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>,
|
|
}
|