Skip to content

Commit

Permalink
Merge templater into notifico-app
Browse files Browse the repository at this point in the history
  • Loading branch information
GamePad64 committed Jan 21, 2025
1 parent 53210c5 commit 4f2cd99
Show file tree
Hide file tree
Showing 45 changed files with 164 additions and 322 deletions.
74 changes: 31 additions & 43 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,14 @@ members = [
## Other
"notifico-core",
"notifico-template",
"notifico-template/migration",
"notifico-attachment",
]

[workspace.dependencies]
sea-orm = { version = "1.1.4", features = ["sqlx-sqlite", "sqlx-postgres", "sqlx-mysql", "runtime-tokio-native-tls", "macros"] }
reqwest = { version = "0.12.12", default-features = false, features = ["json", "native-tls", "native-tls-alpn", "charset", "http2", "multipart", "stream"] }
axum = { version = "0.8.1", features = ["macros"] }
axum-extra = { version = "0.10.0", features = ["typed-header"] }
axum-extra = { version = "0.11.0", features = ["typed-header"] }
clap = { version = "4.5.23", features = ["derive", "color", "usage", "env"] }
tokio = { version = "1.43", features = ["macros", "rt", "sync", "rt-multi-thread", "signal"] }
url = { version = "2.5.4", features = ["serde"] }
Expand Down
2 changes: 2 additions & 0 deletions notifico-app/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ rust-embed = { version = "8.5.0", features = ["mime-guess"] }
sea-orm = { workspace = true }
serde = { version = "1.0.217", features = ["derive"] }
serde_json = "1.0.134"
thiserror = "2.0.11"
tokio = { workspace = true }
tower-http = { version = "0.6.2", features = ["cors"] }
tracing = "0.1"
Expand All @@ -37,3 +38,4 @@ utoipa = { workspace = true }
utoipa-axum = { workspace = true }
utoipa-swagger-ui = { workspace = true }
uuid = { workspace = true }
multimap = "0.10.0"
2 changes: 2 additions & 0 deletions notifico-app/migration/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ pub use sea_orm_migration::prelude::*;
mod m20250108_000001_create_project_table;
mod m20250108_000002_create_pipeline_event;
mod m20250108_000003_recipient;
mod m20250121_000001_create_template_table;

pub struct Migrator;

Expand All @@ -14,6 +15,7 @@ impl MigratorTrait for Migrator {
Box::new(m20250108_000001_create_project_table::Migration),
Box::new(m20250108_000002_create_pipeline_event::Migration),
Box::new(m20250108_000003_recipient::Migration),
Box::new(m20250121_000001_create_template_table::Migration),
]
}

Expand Down
19 changes: 8 additions & 11 deletions notifico-app/src/controllers/event.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
use crate::entity;
use async_trait::async_trait;
use notifico_core::error::EngineError;
use notifico_core::http::admin::{
AdminCrudTable, ItemWithId, ListQueryParams, ListableTrait, PaginatedResult,
use crate::crud_table::{
AdminCrudError, AdminCrudTable, ItemWithId, ListQueryParams, ListableTrait, PaginatedResult,
};
use crate::entity;
use sea_orm::prelude::Uuid;
use sea_orm::ActiveValue::{Set, Unchanged};
use sea_orm::{ActiveModelTrait, PaginatorTrait};
Expand All @@ -21,19 +19,18 @@ impl EventDbController {
}
}

#[async_trait]
impl AdminCrudTable for EventDbController {
type Item = Event;

async fn get_by_id(&self, id: Uuid) -> Result<Option<Self::Item>, EngineError> {
async fn get_by_id(&self, id: Uuid) -> Result<Option<Self::Item>, AdminCrudError> {
let model = entity::event::Entity::find_by_id(id).one(&self.db).await?;
Ok(model.map(|m| m.into()))
}

async fn list(
&self,
params: ListQueryParams,
) -> Result<PaginatedResult<ItemWithId<Self::Item>>, EngineError> {
) -> Result<PaginatedResult<ItemWithId<Self::Item>>, AdminCrudError> {
let params = params.try_into()?;
Ok(PaginatedResult {
items: entity::event::Entity::find()
Expand All @@ -53,7 +50,7 @@ impl AdminCrudTable for EventDbController {
})
}

async fn create(&self, item: Self::Item) -> Result<ItemWithId<Self::Item>, EngineError> {
async fn create(&self, item: Self::Item) -> Result<ItemWithId<Self::Item>, AdminCrudError> {
let id = Uuid::now_v7();

entity::event::ActiveModel {
Expand All @@ -71,7 +68,7 @@ impl AdminCrudTable for EventDbController {
&self,
id: Uuid,
item: Self::Item,
) -> Result<ItemWithId<Self::Item>, EngineError> {
) -> Result<ItemWithId<Self::Item>, AdminCrudError> {
entity::event::ActiveModel {
id: Unchanged(id),
name: Set(item.name.clone()),
Expand All @@ -83,7 +80,7 @@ impl AdminCrudTable for EventDbController {
Ok(ItemWithId { id, item })
}

async fn delete(&self, id: Uuid) -> Result<(), EngineError> {
async fn delete(&self, id: Uuid) -> Result<(), AdminCrudError> {
entity::event::ActiveModel {
id: Set(id),
..Default::default()
Expand Down
Loading

0 comments on commit 4f2cd99

Please sign in to comment.