libomni/types/db/v1/
notification.rs1use serde::{Deserialize, Serialize};
2use chrono::{DateTime, Utc};
3
4#[derive(Debug, sqlx::FromRow, Serialize, Deserialize)]
5pub struct UserNotification {
6 pub id: i64,
7 pub user_id: i64,
8 pub org_id: Option<i64>,
9 pub app_id: Option<i64>,
10 pub notification_type: String,
11 pub message: String,
12 pub read_status: bool,
13 pub importance: String,
14 pub action_url: Option<String>,
15 pub action_label: Option<String>,
16 pub created_at: DateTime<Utc>,
17 pub expires_at: Option<DateTime<Utc>>,
18}
19
20#[derive(Debug, sqlx::FromRow, Serialize, Deserialize)]
22pub struct RoleNotification {
23 pub id: i64,
24 pub role_id: i64,
25 pub org_id: Option<i64>,
26 pub app_id: Option<i64>,
27 pub notification_type: String,
28 pub message: String,
29 pub importance: String,
30 pub action_url: Option<String>,
31 pub action_label: Option<String>,
32 pub created_at: DateTime<Utc>,
33 pub expires_at: Option<DateTime<Utc>>,
34}
35
36#[derive(Debug, sqlx::FromRow, Serialize, Deserialize)]
38pub struct NotificationAcknowledgment {
39 pub id: i64,
40 pub user_id: i64,
41 pub notification_id: Option<i64>,
42 pub role_notification_id: Option<i64>,
43 pub acknowledged_at: DateTime<Utc>
44}
45
46#[derive(Debug, Serialize, Deserialize)]
49pub struct NotificationWithCount {
50 pub user_notifications: Vec<UserNotification>,
52 pub role_notifications: Vec<RoleNotification>,
54 pub acknowledgments: Vec<NotificationAcknowledgment>,
56 pub unread_user_count: i64,
58 pub unacknowledged_role_count: i64,
60 pub total_unread_count: i64
62}
63
64#[derive(Debug, Serialize, Deserialize)]
67pub struct UserNotificationWithRoleNotifications {
68 pub user_notifications: Vec<UserNotification>,
70 pub role_notifications: Vec<RoleNotification>,
72 pub acknowledgments: Vec<NotificationAcknowledgment>
74}
75
76#[derive(Debug, sqlx::FromRow, Serialize)]
77pub struct Notification {
78 pub id: i64,
79 pub user_id: Option<i64>,
80 pub org_id: Option<i64>,
81 pub app_id: Option<i64>,
82 pub notification_type: String, pub message: String,
84 pub read_status: bool,
85 pub created_at: DateTime<Utc>,
86}