Merge pull request 'better-text' (#564) from better-text into main
Reviewed-on: #564
This commit is contained in:
commit
2889d40d55
@ -282,16 +282,17 @@ WHERE trip_details.id=?
|
|||||||
let rower = Registration::all_rower(db, self.trip_details_id).await;
|
let rower = Registration::all_rower(db, self.trip_details_id).await;
|
||||||
for user in rower {
|
for user in rower {
|
||||||
if let Some(user) = User::find_by_name(db, &user.name).await {
|
if let Some(user) = User::find_by_name(db, &user.name).await {
|
||||||
let notes = match update.notes {
|
let notes = if let Some(notes) = update.notes {
|
||||||
Some(n) if !n.is_empty() => n,
|
format!("Grund der Absage: {notes}")
|
||||||
_ => ".",
|
} else {
|
||||||
|
String::from("")
|
||||||
};
|
};
|
||||||
|
|
||||||
Notification::create(
|
Notification::create(
|
||||||
db,
|
db,
|
||||||
&user,
|
&user,
|
||||||
&format!(
|
&format!(
|
||||||
"Die Ausfahrt {} am {} um {} wurde abgesagt{}",
|
"Die Ausfahrt {} am {} um {} wurde abgesagt. {}",
|
||||||
self.name, self.day, self.planned_starting_time, notes
|
self.name, self.day, self.planned_starting_time, notes
|
||||||
),
|
),
|
||||||
"Absage Ausfahrt",
|
"Absage Ausfahrt",
|
||||||
|
@ -21,7 +21,7 @@ pub struct Notification {
|
|||||||
|
|
||||||
impl Notification {
|
impl Notification {
|
||||||
pub async fn find_by_id(db: &SqlitePool, id: i64) -> Option<Self> {
|
pub async fn find_by_id(db: &SqlitePool, id: i64) -> Option<Self> {
|
||||||
sqlx::query_as!(Self, "SELECT * FROM notification WHERE id like ?", id)
|
sqlx::query_as!(Self, "SELECT id, user_id, message, read_at, created_at, category, link, action_after_reading FROM notification WHERE id like ?", id)
|
||||||
.fetch_one(db)
|
.fetch_one(db)
|
||||||
.await
|
.await
|
||||||
.ok()
|
.ok()
|
||||||
@ -135,12 +135,22 @@ ORDER BY read_at DESC, created_at DESC;
|
|||||||
.await
|
.await
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
|
println!("in mark_read");
|
||||||
|
|
||||||
if let Some(action) = self.action_after_reading.as_ref() {
|
if let Some(action) = self.action_after_reading.as_ref() {
|
||||||
|
println!("{action:#?}");
|
||||||
// User read notification about cancelled trip/event
|
// User read notification about cancelled trip/event
|
||||||
let re = Regex::new(r"^remove_user_trip_with_trip_details_id:(\d+)$").unwrap();
|
let re = Regex::new(r"^remove_user_trip_with_trip_details_id:(\d+)$").unwrap();
|
||||||
if let Some(caps) = re.captures(action) {
|
if let Some(caps) = re.captures(action) {
|
||||||
|
println!("in 2nd if");
|
||||||
if let Some(matched) = caps.get(1) {
|
if let Some(matched) = caps.get(1) {
|
||||||
|
println!("in 3rd if");
|
||||||
if let Ok(number) = matched.as_str().parse::<i32>() {
|
if let Ok(number) = matched.as_str().parse::<i32>() {
|
||||||
|
println!("number: {number}");
|
||||||
|
println!(
|
||||||
|
"DELETE FROM user_trip WHERE user_id = {} AND trip_details_id = {}",
|
||||||
|
self.user_id, number
|
||||||
|
);
|
||||||
let _ = sqlx::query!(
|
let _ = sqlx::query!(
|
||||||
"DELETE FROM user_trip WHERE user_id = ? AND trip_details_id = ?",
|
"DELETE FROM user_trip WHERE user_id = ? AND trip_details_id = ?",
|
||||||
self.user_id,
|
self.user_id,
|
||||||
|
Loading…
Reference in New Issue
Block a user