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