1use sea_orm::Set;
4use sea_orm::entity::prelude::*;
5use uuid::Uuid;
6
7#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
8#[sea_orm(table_name = "webhook")]
9pub struct Model {
10 #[sea_orm(primary_key, auto_increment = false)]
11 pub id: Uuid,
12 pub event: String,
13 pub callback_url: String,
14 pub name: Option<String>,
15 #[sea_orm(column_type = "Text", nullable)]
16 pub secret: Option<String>,
17}
18
19#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
20pub enum Relation {
21 #[sea_orm(has_many = "super::webhook_queue::Entity")]
22 WebhookQueue,
23}
24
25impl Related<super::webhook_queue::Entity> for Entity {
26 fn to() -> RelationDef {
27 Relation::WebhookQueue.def()
28 }
29}
30
31impl ActiveModelBehavior for ActiveModel {
32 fn new() -> Self {
33 Self {
34 id: Set(Uuid::new_v4()),
35 ..ActiveModelTrait::default()
36 }
37 }
38}