Compare commits
No commits in common. "6ba97e263138e090aa5f69556c0ef5eac2d3bdb1" and "ae1091c9a2810f775c6154ad15316beca845699e" have entirely different histories.
6ba97e2631
...
ae1091c9a2
@ -77,30 +77,23 @@ impl Trip {
|
|||||||
.await;
|
.await;
|
||||||
if same_starting_datetime.len() > 1 {
|
if same_starting_datetime.len() > 1 {
|
||||||
for notify in same_starting_datetime {
|
for notify in same_starting_datetime {
|
||||||
// don't notify oneself
|
if notify.id != trip_details.id {
|
||||||
if notify.id == trip_details.id {
|
// notify everyone except oneself
|
||||||
continue;
|
if let Some(trip) = Trip::find_by_trip_details(db, notify.id).await {
|
||||||
}
|
let user = User::find_by_id(db, trip.cox_id as i32).await.unwrap();
|
||||||
|
Notification::create(
|
||||||
// don't notify people who have cancelled their trip
|
db,
|
||||||
if notify.cancelled(db) {
|
&user,
|
||||||
continue;
|
&format!(
|
||||||
}
|
"{} hat eine Ausfahrt zur selben Zeit ({} um {}) wie du erstellt",
|
||||||
|
cox.user.name, trip.day, trip.planned_starting_time
|
||||||
if let Some(trip) = Trip::find_by_trip_details(db, notify.id).await {
|
),
|
||||||
let user = User::find_by_id(db, trip.cox_id as i32).await.unwrap();
|
"Neue Ausfahrt zur selben Zeit",
|
||||||
Notification::create(
|
None,
|
||||||
db,
|
None,
|
||||||
&user,
|
)
|
||||||
&format!(
|
.await;
|
||||||
"{} hat eine Ausfahrt zur selben Zeit ({} um {}) wie du erstellt",
|
}
|
||||||
cox.user.name, trip.day, trip.planned_starting_time
|
|
||||||
),
|
|
||||||
"Neue Ausfahrt zur selben Zeit",
|
|
||||||
None,
|
|
||||||
None,
|
|
||||||
)
|
|
||||||
.await;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -77,10 +77,6 @@ WHERE day = ? AND planned_starting_time = ?
|
|||||||
.await.unwrap()
|
.await.unwrap()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn cancelled(&self, db: &SqlitePool) -> bool {
|
|
||||||
self.max_people == 0
|
|
||||||
}
|
|
||||||
|
|
||||||
/// This function is called when a person registers to a trip or when the cox changes the
|
/// This function is called when a person registers to a trip or when the cox changes the
|
||||||
/// amount of free places.
|
/// amount of free places.
|
||||||
pub async fn check_free_spaces(&self, db: &SqlitePool) {
|
pub async fn check_free_spaces(&self, db: &SqlitePool) {
|
||||||
@ -89,7 +85,7 @@ WHERE day = ? AND planned_starting_time = ?
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if self.cancelled(db) {
|
if self.max_people == 0 {
|
||||||
// Cox cancelled event, thus it's probably bad weather. Don't bother with sending
|
// Cox cancelled event, thus it's probably bad weather. Don't bother with sending
|
||||||
// notifications
|
// notifications
|
||||||
return;
|
return;
|
||||||
|
Loading…
Reference in New Issue
Block a user