diff --git a/src/model/event.rs b/src/model/event.rs index cc7664c..3715ab1 100644 --- a/src/model/event.rs +++ b/src/model/event.rs @@ -259,10 +259,9 @@ WHERE trip_details.id=? let coxes = Registration::all_cox(db, self.id).await; for user in coxes { if let Some(user) = User::find_by_name(db, &user.name).await { - let notes = if let Some(notes) = update.notes { - format!("Grund der Absage: {notes}") - } else { - String::from("") + let notes = match update.notes { + Some(n) if !n.is_empty() => format!("Grund der Absage: {n}"), + _ => String::from(""), }; Notification::create( db, @@ -282,10 +281,9 @@ WHERE trip_details.id=? let rower = Registration::all_rower(db, self.trip_details_id).await; for user in rower { if let Some(user) = User::find_by_name(db, &user.name).await { - let notes = if let Some(notes) = update.notes { - format!("Grund der Absage: {notes}") - } else { - String::from("") + let notes = match update.notes { + Some(n) if !n.is_empty() => format!("Grund der Absage: {n}"), + _ => String::from(""), }; Notification::create( diff --git a/src/model/notification.rs b/src/model/notification.rs index b535aae..554f40e 100644 --- a/src/model/notification.rs +++ b/src/model/notification.rs @@ -135,22 +135,12 @@ ORDER BY read_at DESC, created_at DESC; .await .unwrap(); - println!("in mark_read"); - if let Some(action) = self.action_after_reading.as_ref() { - println!("{action:#?}"); // User read notification about cancelled trip/event let re = Regex::new(r"^remove_user_trip_with_trip_details_id:(\d+)$").unwrap(); if let Some(caps) = re.captures(action) { - println!("in 2nd if"); if let Some(matched) = caps.get(1) { - println!("in 3rd if"); if let Ok(number) = matched.as_str().parse::() { - println!("number: {number}"); - println!( - "DELETE FROM user_trip WHERE user_id = {} AND trip_details_id = {}", - self.user_id, number - ); let _ = sqlx::query!( "DELETE FROM user_trip WHERE user_id = ? AND trip_details_id = ?", self.user_id, diff --git a/src/model/trip.rs b/src/model/trip.rs index c0f4bac..8c6cf41 100644 --- a/src/model/trip.rs +++ b/src/model/trip.rs @@ -223,10 +223,9 @@ WHERE day=? .rower; for user in rowers { if let Some(user) = User::find_by_name(db, &user.name).await { - let notes = if let Some(notes) = update.notes { - format!("Grund der Absage: {notes}") - } else { - String::from("") + let notes = match update.notes { + Some(n) if !n.is_empty() => format!("Grund der Absage: {n}"), + _ => String::from(""), }; Notification::create(