add notifications; fixes #127
All checks were successful
CI/CD Pipeline / test (push) Successful in 8m48s
CI/CD Pipeline / deploy-staging (push) Has been skipped
CI/CD Pipeline / deploy-main (push) Has been skipped

This commit is contained in:
2024-03-20 15:56:34 +01:00
parent 2ebfe7564a
commit be50e65846
11 changed files with 194 additions and 17 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!(