70 lines
1.7 KiB
Rust
70 lines
1.7 KiB
Rust
use chrono::{DateTime, Utc};
|
|
use serde::{Deserialize, Serialize};
|
|
use uuid::Uuid;
|
|
|
|
use crate::event::{RoomInfo, UserInfo, WorkspaceInfo};
|
|
|
|
#[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")]
|
|
pub enum NotifyEvent {
|
|
#[serde(rename = "notify.created")]
|
|
Created(NotifyCreatedService),
|
|
#[serde(rename = "notify.read")]
|
|
Read(NotifyReadService),
|
|
#[serde(rename = "notify.archived")]
|
|
Archived(NotifyArchivedService),
|
|
}
|
|
|
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
pub struct NotifyCreatedService {
|
|
pub id: Uuid,
|
|
pub room: Option<RoomInfo>,
|
|
pub workspace: Option<WorkspaceInfo>,
|
|
pub user: UserInfo,
|
|
pub notification_type: String,
|
|
pub title: String,
|
|
pub content: Option<String>,
|
|
pub related_message_id: Option<Uuid>,
|
|
pub related_user: Option<UserInfo>,
|
|
pub metadata: Option<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: UserInfo,
|
|
pub read_at: DateTime<Utc>,
|
|
}
|
|
|
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
pub struct NotifyArchivedService {
|
|
pub id: Uuid,
|
|
pub user: UserInfo,
|
|
pub archived_at: DateTime<Utc>,
|
|
}
|
|
|
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
pub struct NotifyReadClient {
|
|
pub id: Uuid,
|
|
}
|
|
|
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
pub struct NotifyReadAllClient {
|
|
pub workspace: Option<WorkspaceInfo>,
|
|
}
|
|
|
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
pub struct NotifyArchiveClient {
|
|
pub id: Uuid,
|
|
}
|