notification (#282)
All checks were successful
CI/CD Pipeline / test (push) Successful in 8m58s
CI/CD Pipeline / deploy-staging (push) Successful in 4m18s
CI/CD Pipeline / deploy-main (push) Has been skipped

Reviewed-on: #282
This commit is contained in:
2024-03-20 16:19:12 +01:00
parent 68a1153885
commit 9d14dae4a7
12 changed files with 274 additions and 22 deletions

View File

@ -5,7 +5,7 @@ use rocket::FromForm;
use serde::Serialize;
use sqlx::{FromRow, Sqlite, SqlitePool, Transaction};
use super::{boat::Boat, log::Log, rower::Rower, user::User};
use super::{boat::Boat, log::Log, notification::Notification, rower::Rower, user::User};
#[derive(FromRow, Serialize, Clone, Debug)]
pub struct Logbook {
@ -525,6 +525,23 @@ ORDER BY departure DESC
Rower::create(db, self.id, *rower)
.await
.map_err(|e| LogbookUpdateError::RowerCreateError(*rower, e.to_string()))?;
let user = User::find_by_id_tx(db, *rower as i32).await.unwrap();
Notification::create_with_tx(
db,
&user,
&format!(
"Neuer Logbucheintrag: Ausfahrt am {}.{}.{} nach {} ({} km)",
dep.day(),
dep.month(),
dep.year(),
log.destination,
log.distance_in_km
),
"Neuer Logbucheintrag",
None,
)
.await;
}
sqlx::query!(