67 lines
1.6 KiB
Rust
67 lines
1.6 KiB
Rust
use chrono::{DateTime, Utc};
|
|
use serde::{Deserialize, Serialize};
|
|
|
|
use models::{ProjectId, Uuid};
|
|
|
|
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
|
|
#[serde(rename_all = "snake_case")]
|
|
pub enum NotifyEventType {
|
|
Created,
|
|
Read,
|
|
Archived,
|
|
}
|
|
|
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
#[serde(tag = "type", rename_all = "snake_case")]
|
|
pub enum NotifyEvent {
|
|
Created(NotifyCreatedService),
|
|
Read(NotifyReadService),
|
|
Archived(NotifyArchivedService),
|
|
}
|
|
|
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
pub struct NotifyCreatedService {
|
|
pub id: Uuid,
|
|
pub room: Option<Uuid>,
|
|
pub project: Option<ProjectId>,
|
|
pub user_id: Option<Uuid>,
|
|
pub notification_type: String,
|
|
pub title: String,
|
|
pub content: Option<String>,
|
|
pub related_message_id: Option<Uuid>,
|
|
pub related_user_id: Option<Uuid>,
|
|
pub related_room_id: Option<Uuid>,
|
|
pub metadata: serde_json::Value,
|
|
pub created_at: DateTime<Utc>,
|
|
pub deep_link_url: Option<String>,
|
|
}
|
|
|
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
pub struct NotifyReadService {
|
|
pub id: Uuid,
|
|
pub user_id: Option<Uuid>,
|
|
pub read_at: DateTime<Utc>,
|
|
}
|
|
|
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
pub struct NotifyArchivedService {
|
|
pub id: Uuid,
|
|
pub user_id: Option<Uuid>,
|
|
pub archived_at: DateTime<Utc>,
|
|
}
|
|
|
|
#[derive(Debug, Clone, Deserialize, Serialize)]
|
|
pub struct NotifyReadClient {
|
|
pub id: Uuid,
|
|
}
|
|
|
|
#[derive(Debug, Clone, Deserialize, Serialize)]
|
|
pub struct NotifyReadAllClient {
|
|
pub project_id: Option<ProjectId>,
|
|
}
|
|
|
|
#[derive(Debug, Clone, Deserialize, Serialize)]
|
|
pub struct NotifyArchiveClient {
|
|
pub id: Uuid,
|
|
}
|