send creator of boatdamage notification when it has been repaired #395
@ -235,19 +235,31 @@ ORDER BY created_at DESC
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if boat_damage.user_id_fixed != self.user_id_created as i32 {
|
||||||
|
let user_fixed = User::find_by_id(db, boat_damage.user_id_fixed)
|
||||||
|
.await
|
||||||
|
.unwrap();
|
||||||
|
let user_created = User::find_by_id(db, self.user_id_created as i32)
|
||||||
|
.await
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
// Boatdamage is also directly verified, if a tech has repaired it. We don't want to
|
||||||
|
// send 2 notifications.
|
||||||
|
if !user_fixed.has_role(db, "tech").await {
|
||||||
Notification::create(
|
Notification::create(
|
||||||
db,
|
db,
|
||||||
&User::find_by_id(db, boat_damage.user_id_fixed)
|
&user_created,
|
||||||
.await
|
|
||||||
.unwrap(),
|
|
||||||
&format!(
|
&format!(
|
||||||
"Du hat den Bootschaden '{}' beim Boot '{}' repariert. Danke für deine Hilfe!",
|
"{} hat den von dir eingetragenen Bootschaden '{}' beim Boot '{}' repariert. Dieser muss nun noch von unseren Bootswarten bestätigt werden.",
|
||||||
|
user_fixed.name,
|
||||||
boat_damage.desc, boat.name,
|
boat_damage.desc, boat.name,
|
||||||
),
|
),
|
||||||
"Bootsschaden repariert",
|
"Bootsschaden repariert",
|
||||||
None,
|
None,
|
||||||
)
|
)
|
||||||
.await;
|
.await;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
@ -277,6 +289,42 @@ ORDER BY created_at DESC
|
|||||||
)
|
)
|
||||||
.execute(db)
|
.execute(db)
|
||||||
.await.map_err(|e| e.to_string())?;
|
.await.map_err(|e| e.to_string())?;
|
||||||
|
|
||||||
|
if boat.user_id_verified != self.user_id_created as i32 {
|
||||||
|
let user_verified = User::find_by_id(db, boat.user_id_verified).await.unwrap();
|
||||||
|
let user_created = User::find_by_id(db, self.user_id_created as i32)
|
||||||
|
.await
|
||||||
|
.unwrap();
|
||||||
|
let boat = Boat::find_by_id(db, self.boat_id as i32).await.unwrap();
|
||||||
|
|
||||||
|
if user_verified.id == self.user_id_fixed.unwrap() {
|
||||||
|
Notification::create(
|
||||||
|
db,
|
||||||
|
&user_created,
|
||||||
|
&format!(
|
||||||
|
"{} hat den von dir eingetragenen Bootschaden '{}' beim Boot '{}' repariert und verifiziert.",
|
||||||
|
user_verified.name,
|
||||||
|
self.desc, boat.name,
|
||||||
|
),
|
||||||
|
"Bootsschaden repariert & verifiziert",
|
||||||
|
None,
|
||||||
|
)
|
||||||
|
.await;
|
||||||
|
} else {
|
||||||
|
Notification::create(
|
||||||
|
db,
|
||||||
|
&user_created,
|
||||||
|
&format!(
|
||||||
|
"{} hat verifiziert, dass der von dir eingetragenen Bootschaden '{}' beim Boot '{}' korrekt repariert wurde.",
|
||||||
|
user_verified.name,
|
||||||
|
self.desc, boat.name,
|
||||||
|
),
|
||||||
|
"Bootsschaden verifiziert",
|
||||||
|
None,
|
||||||
|
).await;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -145,7 +145,6 @@ impl Fairing for Usage {
|
|||||||
{
|
{
|
||||||
let config = req.rocket().state::<Config>().unwrap();
|
let config = req.rocket().state::<Config>().unwrap();
|
||||||
let Ok(mut file) = OpenOptions::new()
|
let Ok(mut file) = OpenOptions::new()
|
||||||
.write(true)
|
|
||||||
.append(true)
|
.append(true)
|
||||||
.open(config.usage_log_path.clone())
|
.open(config.usage_log_path.clone())
|
||||||
else {
|
else {
|
||||||
|
Loading…
Reference in New Issue
Block a user