feat: init

This commit is contained in:
zhenyi
2026-06-07 11:30:56 +08:00
commit 563381c1ca
361 changed files with 41327 additions and 0 deletions
+11
View File
@@ -0,0 +1,11 @@
pub mod notification;
pub mod notification_blocks;
pub mod notification_deliveries;
pub mod notification_subscriptions;
pub mod notification_templates;
pub use notification::Notification;
pub use notification_blocks::NotificationBlock;
pub use notification_deliveries::NotificationDelivery;
pub use notification_subscriptions::NotificationSubscription;
pub use notification_templates::NotificationTemplate;
+31
View File
@@ -0,0 +1,31 @@
use crate::models::common::{NotificationType, Priority, TargetType};
use crate::models::json_types::{NotificationMetadata, TypedJson};
use chrono::{DateTime, Utc};
use serde::{Deserialize, Serialize};
use uuid::Uuid;
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, sqlx::FromRow)]
pub struct Notification {
pub id: Uuid,
pub user_id: Uuid,
pub actor_id: Option<Uuid>,
pub workspace_id: Option<Uuid>,
pub repo_id: Option<Uuid>,
pub issue_id: Option<Uuid>,
pub pull_request_id: Option<Uuid>,
pub channel_id: Option<Uuid>,
pub message_id: Option<Uuid>,
pub notification_type: NotificationType,
pub title: String,
pub body: Option<String>,
pub target_type: Option<TargetType>,
pub target_id: Option<Uuid>,
pub action_url: Option<String>,
pub priority: Priority,
pub read_at: Option<DateTime<Utc>>,
pub dismissed_at: Option<DateTime<Utc>>,
pub metadata: Option<TypedJson<NotificationMetadata>>,
pub created_at: DateTime<Utc>,
pub updated_at: DateTime<Utc>,
pub deleted_at: Option<DateTime<Utc>>,
}
@@ -0,0 +1,20 @@
use crate::models::common::{DeliveryChannel, NotificationType, TargetType};
use chrono::{DateTime, Utc};
use serde::{Deserialize, Serialize};
use uuid::Uuid;
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, sqlx::FromRow)]
pub struct NotificationBlock {
pub id: Uuid,
pub user_id: Uuid,
pub workspace_id: Option<Uuid>,
pub repo_id: Option<Uuid>,
pub target_type: TargetType,
pub target_id: Option<Uuid>,
pub notification_type: Option<NotificationType>,
pub channel: Option<DeliveryChannel>,
pub reason: Option<String>,
pub expires_at: Option<DateTime<Utc>>,
pub created_at: DateTime<Utc>,
pub updated_at: DateTime<Utc>,
}
@@ -0,0 +1,24 @@
use crate::models::common::{DeliveryChannel, Provider, Status};
use chrono::{DateTime, Utc};
use serde::{Deserialize, Serialize};
use uuid::Uuid;
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, sqlx::FromRow)]
pub struct NotificationDelivery {
pub id: Uuid,
pub notification_id: Uuid,
pub user_id: Uuid,
pub channel: DeliveryChannel,
pub destination: Option<String>,
pub status: Status,
pub provider: Option<Provider>,
pub provider_message_id: Option<String>,
pub attempts: i32,
pub last_error: Option<String>,
pub scheduled_at: Option<DateTime<Utc>>,
pub sent_at: Option<DateTime<Utc>>,
pub delivered_at: Option<DateTime<Utc>>,
pub failed_at: Option<DateTime<Utc>>,
pub created_at: DateTime<Utc>,
pub updated_at: DateTime<Utc>,
}
@@ -0,0 +1,21 @@
use crate::models::common::{EventType, SubscriptionLevel, TargetType};
use chrono::{DateTime, Utc};
use serde::{Deserialize, Serialize};
use uuid::Uuid;
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, sqlx::FromRow)]
pub struct NotificationSubscription {
pub id: Uuid,
pub user_id: Uuid,
pub workspace_id: Option<Uuid>,
pub repo_id: Option<Uuid>,
pub target_type: TargetType,
pub target_id: Option<Uuid>,
pub event_types: Vec<EventType>,
pub channels: Vec<String>,
pub level: SubscriptionLevel,
pub muted: bool,
pub muted_until: Option<DateTime<Utc>>,
pub created_at: DateTime<Utc>,
pub updated_at: DateTime<Utc>,
}
@@ -0,0 +1,21 @@
use crate::models::common::{DeliveryChannel, NotificationType};
use chrono::{DateTime, Utc};
use serde::{Deserialize, Serialize};
use uuid::Uuid;
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, sqlx::FromRow)]
pub struct NotificationTemplate {
pub id: Uuid,
pub key: String,
pub notification_type: NotificationType,
pub channel: DeliveryChannel,
pub locale: String,
pub subject_template: Option<String>,
pub title_template: String,
pub body_template: String,
pub action_text_template: Option<String>,
pub enabled: bool,
pub created_by: Option<Uuid>,
pub created_at: DateTime<Utc>,
pub updated_at: DateTime<Utc>,
}