Compare commits
No commits in common. "f968d5d03b141d2f42a2107d5d0625e87d4cbddc" and "0b46cbf8dbb0487a54e092cd5b24f237c441dcd0" have entirely different histories.
f968d5d03b
...
0b46cbf8db
@ -77,16 +77,8 @@ impl Trip {
|
||||
.await;
|
||||
if same_starting_datetime.len() > 1 {
|
||||
for notify in same_starting_datetime {
|
||||
// don't notify oneself
|
||||
if notify.id == trip_details.id {
|
||||
continue;
|
||||
}
|
||||
|
||||
// don't notify people who have cancelled their trip
|
||||
if notify.cancelled(db) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if notify.id != trip_details.id {
|
||||
// notify everyone except oneself
|
||||
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(
|
||||
@ -105,6 +97,7 @@ impl Trip {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub async fn find_by_trip_details(db: &SqlitePool, tripdetails_id: i64) -> Option<Self> {
|
||||
sqlx::query_as!(
|
||||
|
@ -77,10 +77,6 @@ WHERE day = ? AND planned_starting_time = ?
|
||||
.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
|
||||
/// amount of free places.
|
||||
pub async fn check_free_spaces(&self, db: &SqlitePool) {
|
||||
@ -89,7 +85,7 @@ WHERE day = ? AND planned_starting_time = ?
|
||||
return;
|
||||
}
|
||||
|
||||
if self.cancelled(db) {
|
||||
if self.max_people == 0 {
|
||||
// Cox cancelled event, thus it's probably bad weather. Don't bother with sending
|
||||
// notifications
|
||||
return;
|
||||
|
Loading…
Reference in New Issue
Block a user