main
use sea_orm::entity::prelude::*;
use serde::{Deserialize, Serialize};
use time::OffsetDateTime;
use uuid::Uuid;
#[derive(
Debug,
Clone,
Copy,
PartialEq,
Eq,
Default,
EnumIter,
DeriveActiveEnum,
Serialize,
Deserialize,
utoipa::ToSchema,
)]
#[sea_orm(rs_type = "i16", db_type = "SmallInteger")]
pub enum WebhookDeliveryStatus {
#[default]
#[sea_orm(num_value = 0)]
Pending,
#[sea_orm(num_value = 1)]
Delivering,
#[sea_orm(num_value = 2)]
Done,
#[sea_orm(num_value = 3)]
Failed,
}
#[sea_orm::model]
#[derive(Clone, Debug, PartialEq, DeriveEntityModel)]
#[sea_orm(table_name = "chat_webhook_delivery")]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub id: Uuid,
#[sea_orm(indexed)]
pub webhook_id: Uuid,
pub room_id: Uuid,
pub event_type: String,
#[sea_orm(column_type = "JsonBinary")]
pub payload: sea_orm::JsonValue,
#[sea_orm(default_value = 0)]
pub status: WebhookDeliveryStatus,
#[sea_orm(default_value = 0)]
pub attempts: i32,
pub next_retry_at: OffsetDateTime,
pub last_error: Option<String>,
pub created_at: OffsetDateTime,
pub updated_at: OffsetDateTime,
}
impl ActiveModelBehavior for ActiveModel {}