Compare commits
No commits in common. "10f2e3016a72b9f7bb8e99071c98bef37f3e8768" and "b6c9cb0b993fc95c0fda147fe0848859f8897cb8" have entirely different histories.
10f2e3016a
...
b6c9cb0b99
1
Cargo.lock
generated
1
Cargo.lock
generated
@ -2272,7 +2272,6 @@ dependencies = [
|
|||||||
"lettre",
|
"lettre",
|
||||||
"log",
|
"log",
|
||||||
"openssl",
|
"openssl",
|
||||||
"regex",
|
|
||||||
"rocket",
|
"rocket",
|
||||||
"rocket_dyn_templates",
|
"rocket_dyn_templates",
|
||||||
"serde",
|
"serde",
|
||||||
|
@ -27,7 +27,6 @@ csv = "1.3"
|
|||||||
itertools = "0.12"
|
itertools = "0.12"
|
||||||
job_scheduler_ng = "2.0"
|
job_scheduler_ng = "2.0"
|
||||||
ureq = { version = "2.9", features = ["json"] }
|
ureq = { version = "2.9", features = ["json"] }
|
||||||
regex = "1.10"
|
|
||||||
|
|
||||||
[target.'cfg(not(windows))'.dependencies]
|
[target.'cfg(not(windows))'.dependencies]
|
||||||
openssl = { version = "0.10", features = [ "vendored" ] }
|
openssl = { version = "0.10", features = [ "vendored" ] }
|
||||||
|
@ -160,7 +160,6 @@ CREATE TABLE IF NOT EXISTS "notification" (
|
|||||||
"read_at" DATETIME,
|
"read_at" DATETIME,
|
||||||
"created_at" DATETIME DEFAULT CURRENT_TIMESTAMP NOT NULL,
|
"created_at" DATETIME DEFAULT CURRENT_TIMESTAMP NOT NULL,
|
||||||
"category" TEXT NOT NULL,
|
"category" TEXT NOT NULL,
|
||||||
"action_after_reading" TEXT,
|
|
||||||
"link" TEXT
|
"link" TEXT
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -137,7 +137,7 @@ ORDER BY created_at DESC
|
|||||||
|
|
||||||
if !was_unusable_before && boat.is_locked(db).await {
|
if !was_unusable_before && boat.is_locked(db).await {
|
||||||
let cox = Role::find_by_name(db, "cox").await.unwrap();
|
let cox = Role::find_by_name(db, "cox").await.unwrap();
|
||||||
Notification::create_for_role(db, &cox, &format!("Liebe Steuerberechtigte, bitte beachten, dass {} bis auf weiteres aufgrund von Reparaturarbeiten gesperrt ist.", boat.name), "Boot gesperrt", None, None).await;
|
Notification::create_for_role(db, &cox, &format!("Liebe Steuerberechtigte, bitte beachten, dass {} bis auf weiteres aufgrund von Reparaturarbeiten gesperrt ist.", boat.name), "Boot gesperrt", None).await;
|
||||||
}
|
}
|
||||||
|
|
||||||
let technicals =
|
let technicals =
|
||||||
@ -158,7 +158,6 @@ ORDER BY created_at DESC
|
|||||||
),
|
),
|
||||||
"Neuer Bootsschaden angelegt",
|
"Neuer Bootsschaden angelegt",
|
||||||
None,
|
None,
|
||||||
None,
|
|
||||||
)
|
)
|
||||||
.await;
|
.await;
|
||||||
}
|
}
|
||||||
@ -179,7 +178,6 @@ ORDER BY created_at DESC
|
|||||||
),
|
),
|
||||||
"Neuer Bootsschaden angelegt",
|
"Neuer Bootsschaden angelegt",
|
||||||
None,
|
None,
|
||||||
None,
|
|
||||||
)
|
)
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
@ -237,7 +235,7 @@ ORDER BY created_at DESC
|
|||||||
boat.name,
|
boat.name,
|
||||||
),
|
),
|
||||||
"Bootsschaden repariert",
|
"Bootsschaden repariert",
|
||||||
None,None
|
None,
|
||||||
)
|
)
|
||||||
.await;
|
.await;
|
||||||
}
|
}
|
||||||
@ -263,7 +261,7 @@ ORDER BY created_at DESC
|
|||||||
boat_damage.desc, boat.name,
|
boat_damage.desc, boat.name,
|
||||||
),
|
),
|
||||||
"Bootsschaden repariert",
|
"Bootsschaden repariert",
|
||||||
None,None
|
None,
|
||||||
)
|
)
|
||||||
.await;
|
.await;
|
||||||
}
|
}
|
||||||
@ -322,7 +320,6 @@ ORDER BY created_at DESC
|
|||||||
),
|
),
|
||||||
"Bootsschaden repariert & verifiziert",
|
"Bootsschaden repariert & verifiziert",
|
||||||
None,
|
None,
|
||||||
None
|
|
||||||
)
|
)
|
||||||
.await;
|
.await;
|
||||||
} else {
|
} else {
|
||||||
@ -336,14 +333,13 @@ ORDER BY created_at DESC
|
|||||||
),
|
),
|
||||||
"Bootsschaden verifiziert",
|
"Bootsschaden verifiziert",
|
||||||
None,
|
None,
|
||||||
None
|
|
||||||
).await;
|
).await;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if was_unusable_before && !boat.is_locked(db).await {
|
if was_unusable_before && !boat.is_locked(db).await {
|
||||||
let cox = Role::find_by_name(db, "cox").await.unwrap();
|
let cox = Role::find_by_name(db, "cox").await.unwrap();
|
||||||
Notification::create_for_role(db, &cox, &format!("Liebe Steuerberechtigte, {} wurde repariert und freut sich ab sofort wieder gerudert zu werden :-)", boat.name), "Boot repariert", None, None).await;
|
Notification::create_for_role(db, &cox, &format!("Liebe Steuerberechtigte, {} wurde repariert und freut sich ab sofort wieder gerudert zu werden :-)", boat.name), "Boot repariert", None).await;
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
@ -175,7 +175,7 @@ WHERE end_date >= CURRENT_DATE ORDER BY end_date
|
|||||||
boatreservation.usage
|
boatreservation.usage
|
||||||
),
|
),
|
||||||
"Neue Bootsreservierung",
|
"Neue Bootsreservierung",
|
||||||
None,None
|
None,
|
||||||
)
|
)
|
||||||
.await;
|
.await;
|
||||||
}
|
}
|
||||||
|
@ -549,7 +549,6 @@ ORDER BY departure DESC
|
|||||||
),
|
),
|
||||||
"Neuer Logbucheintrag",
|
"Neuer Logbucheintrag",
|
||||||
None,
|
None,
|
||||||
None,
|
|
||||||
)
|
)
|
||||||
.await;
|
.await;
|
||||||
}
|
}
|
||||||
@ -579,7 +578,7 @@ ORDER BY departure DESC
|
|||||||
&vorstand,
|
&vorstand,
|
||||||
&format!("'{}' hat eine mehrtägige Ausfahrt vom {} bis {} eingetragen ({} km; Ziel: {}; Anmerkungen: {}). Falls das nicht stimmen sollte, bitte nachhaken.",user.name,log.departure, log.arrival, log.distance_in_km, log.destination, log.comments.clone().unwrap_or("".into())),
|
&format!("'{}' hat eine mehrtägige Ausfahrt vom {} bis {} eingetragen ({} km; Ziel: {}; Anmerkungen: {}). Falls das nicht stimmen sollte, bitte nachhaken.",user.name,log.departure, log.arrival, log.distance_in_km, log.destination, log.comments.clone().unwrap_or("".into())),
|
||||||
"Mehrtägige Ausfahrt eingetragen",
|
"Mehrtägige Ausfahrt eingetragen",
|
||||||
None,None
|
None,
|
||||||
).await;
|
).await;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -591,7 +590,7 @@ ORDER BY departure DESC
|
|||||||
&vorstand,
|
&vorstand,
|
||||||
&format!("'{}' hat eine Ausfahrt mit externem Boot '{}' am {} eingetragen ({} km; Ziel: {}; Anmerkungen: {}). Falls das nicht stimmen sollte, bitte nachhaken.",user.name,boat.name,log.departure,log.distance_in_km, log.destination, log.comments.unwrap_or("".into())),
|
&format!("'{}' hat eine Ausfahrt mit externem Boot '{}' am {} eingetragen ({} km; Ziel: {}; Anmerkungen: {}). Falls das nicht stimmen sollte, bitte nachhaken.",user.name,boat.name,log.departure,log.distance_in_km, log.destination, log.comments.unwrap_or("".into())),
|
||||||
"Ausfahrt mit externem Boot eingetragen",
|
"Ausfahrt mit externem Boot eingetragen",
|
||||||
None,None,
|
None,
|
||||||
).await;
|
).await;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
use std::ops::DerefMut;
|
use std::ops::DerefMut;
|
||||||
|
|
||||||
use chrono::NaiveDateTime;
|
use chrono::NaiveDateTime;
|
||||||
use regex::Regex;
|
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use sqlx::{FromRow, Sqlite, SqlitePool, Transaction};
|
use sqlx::{FromRow, Sqlite, SqlitePool, Transaction};
|
||||||
|
|
||||||
@ -16,7 +15,6 @@ pub struct Notification {
|
|||||||
pub created_at: NaiveDateTime,
|
pub created_at: NaiveDateTime,
|
||||||
pub category: String,
|
pub category: String,
|
||||||
pub link: Option<String>,
|
pub link: Option<String>,
|
||||||
pub action_after_reading: Option<String>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Notification {
|
impl Notification {
|
||||||
@ -32,15 +30,13 @@ impl Notification {
|
|||||||
message: &str,
|
message: &str,
|
||||||
category: &str,
|
category: &str,
|
||||||
link: Option<&str>,
|
link: Option<&str>,
|
||||||
action_after_reading: Option<&str>,
|
|
||||||
) {
|
) {
|
||||||
sqlx::query!(
|
sqlx::query!(
|
||||||
"INSERT INTO notification(user_id, message, category, link, action_after_reading) VALUES (?, ?, ?, ?, ?)",
|
"INSERT INTO notification(user_id, message, category, link) VALUES (?, ?, ?, ?)",
|
||||||
user.id,
|
user.id,
|
||||||
message,
|
message,
|
||||||
category,
|
category,
|
||||||
link,
|
link
|
||||||
action_after_reading
|
|
||||||
)
|
)
|
||||||
.execute(db.deref_mut())
|
.execute(db.deref_mut())
|
||||||
.await
|
.await
|
||||||
@ -53,10 +49,9 @@ impl Notification {
|
|||||||
message: &str,
|
message: &str,
|
||||||
category: &str,
|
category: &str,
|
||||||
link: Option<&str>,
|
link: Option<&str>,
|
||||||
action_after_reading: Option<&str>,
|
|
||||||
) {
|
) {
|
||||||
let mut tx = db.begin().await.unwrap();
|
let mut tx = db.begin().await.unwrap();
|
||||||
Self::create_with_tx(&mut tx, user, message, category, link, action_after_reading).await;
|
Self::create_with_tx(&mut tx, user, message, category, link).await;
|
||||||
tx.commit().await.unwrap();
|
tx.commit().await.unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -66,12 +61,11 @@ impl Notification {
|
|||||||
message: &str,
|
message: &str,
|
||||||
category: &str,
|
category: &str,
|
||||||
link: Option<&str>,
|
link: Option<&str>,
|
||||||
action_after_reading: Option<&str>,
|
|
||||||
) {
|
) {
|
||||||
let users = User::all_with_role_tx(db, role).await;
|
let users = User::all_with_role_tx(db, role).await;
|
||||||
|
|
||||||
for user in users {
|
for user in users {
|
||||||
Self::create_with_tx(db, &user, message, category, link, action_after_reading).await;
|
Self::create_with_tx(db, &user, message, category, link).await;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -81,18 +75,16 @@ impl Notification {
|
|||||||
message: &str,
|
message: &str,
|
||||||
category: &str,
|
category: &str,
|
||||||
link: Option<&str>,
|
link: Option<&str>,
|
||||||
action_after_reading: Option<&str>,
|
|
||||||
) {
|
) {
|
||||||
let mut tx = db.begin().await.unwrap();
|
let mut tx = db.begin().await.unwrap();
|
||||||
Self::create_for_role_tx(&mut tx, role, message, category, link, action_after_reading)
|
Self::create_for_role_tx(&mut tx, role, message, category, link).await;
|
||||||
.await;
|
|
||||||
tx.commit().await.unwrap();
|
tx.commit().await.unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn for_user(db: &SqlitePool, user: &User) -> Vec<Self> {
|
pub async fn for_user(db: &SqlitePool, user: &User) -> Vec<Self> {
|
||||||
let rows = sqlx::query!(
|
let rows = sqlx::query!(
|
||||||
"
|
"
|
||||||
SELECT id, user_id, message, read_at, datetime(created_at, 'localtime') as created_at, category, link, action_after_reading FROM notification
|
SELECT id, user_id, message, read_at, datetime(created_at, 'localtime') as created_at, category, link FROM notification
|
||||||
WHERE
|
WHERE
|
||||||
user_id = ?
|
user_id = ?
|
||||||
AND (
|
AND (
|
||||||
@ -121,7 +113,6 @@ ORDER BY read_at DESC, created_at DESC;
|
|||||||
.unwrap(),
|
.unwrap(),
|
||||||
category: rec.category,
|
category: rec.category,
|
||||||
link: rec.link,
|
link: rec.link,
|
||||||
action_after_reading: rec.action_after_reading,
|
|
||||||
})
|
})
|
||||||
.collect()
|
.collect()
|
||||||
}
|
}
|
||||||
@ -134,24 +125,5 @@ ORDER BY read_at DESC, created_at DESC;
|
|||||||
.execute(db)
|
.execute(db)
|
||||||
.await
|
.await
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
if let Some(action) = self.action_after_reading.as_ref() {
|
|
||||||
// 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) {
|
|
||||||
if let Some(matched) = caps.get(1) {
|
|
||||||
if let Ok(number) = matched.as_str().parse::<i32>() {
|
|
||||||
let _ = sqlx::query!(
|
|
||||||
"DELETE FROM user_trip WHERE user_id = ? AND trip_details_id = ?",
|
|
||||||
self.user_id,
|
|
||||||
number
|
|
||||||
)
|
|
||||||
.execute(db)
|
|
||||||
.await
|
|
||||||
.unwrap();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -80,7 +80,6 @@ impl Trip {
|
|||||||
),
|
),
|
||||||
"Neue Ausfahrt zur selben Zeit",
|
"Neue Ausfahrt zur selben Zeit",
|
||||||
None,
|
None,
|
||||||
None,
|
|
||||||
)
|
)
|
||||||
.await;
|
.await;
|
||||||
}
|
}
|
||||||
@ -210,9 +209,10 @@ WHERE day=?
|
|||||||
let rowers = TripWithUserAndType::from(db, trip.clone()).await.rower;
|
let rowers = TripWithUserAndType::from(db, trip.clone()).await.rower;
|
||||||
for user in rowers {
|
for user in rowers {
|
||||||
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 notes {
|
let notes = if let Some(notes) = notes {
|
||||||
Some(n) if !n.is_empty() => n,
|
format!(": {notes}")
|
||||||
_ => ".",
|
} else {
|
||||||
|
String::from(".")
|
||||||
};
|
};
|
||||||
|
|
||||||
Notification::create(
|
Notification::create(
|
||||||
@ -224,10 +224,6 @@ WHERE day=?
|
|||||||
),
|
),
|
||||||
"Absage Ausfahrt",
|
"Absage Ausfahrt",
|
||||||
None,
|
None,
|
||||||
Some(&format!(
|
|
||||||
"remove_user_trip_with_trip_details_id:{}",
|
|
||||||
trip_details_id
|
|
||||||
)),
|
|
||||||
)
|
)
|
||||||
.await;
|
.await;
|
||||||
}
|
}
|
||||||
|
@ -120,7 +120,7 @@ WHERE day = ? AND planned_starting_time = ?
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
Notification::create(db, &user, &format!("Du hast dich als Ruderer bei der Ausfahrt von {} am {} um {} angemeldet. Bei allen Ausfahrten zu dieser Zeit sind nun alle Plätze ausgebucht. Damit noch mehr (Nicht-Steuerleute) mitfahren können, wäre es super, wenn du eine eigene Ausfahrt zur selben Zeit ausschreiben könntest.", cox.name, self.day, self.planned_starting_time), "Volle Ausfahrt", None, None).await;
|
Notification::create(db, &user, &format!("Du hast dich als Ruderer bei der Ausfahrt von {} am {} um {} angemeldet. Bei allen Ausfahrten zu dieser Zeit sind nun alle Plätze ausgebucht. Damit noch mehr (Nicht-Steuerleute) mitfahren können, wäre es super, wenn du eine eigene Ausfahrt zur selben Zeit ausschreiben könntest.", cox.name, self.day, self.planned_starting_time), "Volle Ausfahrt", None).await;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -202,7 +202,7 @@ ASKÖ Ruderverein Donau Linz", self.name, SCHECKBUCH/100),
|
|||||||
self.name
|
self.name
|
||||||
),
|
),
|
||||||
"Neues Scheckbuch",
|
"Neues Scheckbuch",
|
||||||
None,None
|
None,
|
||||||
)
|
)
|
||||||
.await;
|
.await;
|
||||||
}
|
}
|
||||||
@ -246,7 +246,6 @@ ASKÖ Ruderverein Donau Linz", self.name),
|
|||||||
),
|
),
|
||||||
"Neues Vereinsmitglied",
|
"Neues Vereinsmitglied",
|
||||||
None,
|
None,
|
||||||
None,
|
|
||||||
)
|
)
|
||||||
.await;
|
.await;
|
||||||
}
|
}
|
||||||
|
@ -76,7 +76,6 @@ impl UserTrip {
|
|||||||
),
|
),
|
||||||
"Registrierung bei deiner Ausfahrt",
|
"Registrierung bei deiner Ausfahrt",
|
||||||
None,
|
None,
|
||||||
None,
|
|
||||||
)
|
)
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
|
@ -76,7 +76,7 @@ async fn send_group(
|
|||||||
};
|
};
|
||||||
|
|
||||||
for user in User::all_with_role(db, &role).await {
|
for user in User::all_with_role(db, &role).await {
|
||||||
Notification::create(db, &user, &d.message, &d.category, None, None).await;
|
Notification::create(db, &user, &d.message, &d.category, None).await;
|
||||||
}
|
}
|
||||||
Log::create(db, "Notification successfully sent".into()).await;
|
Log::create(db, "Notification successfully sent".into()).await;
|
||||||
Flash::success(
|
Flash::success(
|
||||||
@ -102,7 +102,7 @@ async fn send_user(
|
|||||||
return Flash::error(Redirect::to("/admin/notification"), "User gibt's ned");
|
return Flash::error(Redirect::to("/admin/notification"), "User gibt's ned");
|
||||||
};
|
};
|
||||||
|
|
||||||
Notification::create(db, &user, &d.message, &d.category, None, None).await;
|
Notification::create(db, &user, &d.message, &d.category, None).await;
|
||||||
|
|
||||||
Log::create(db, "Notification successfully sent".into()).await;
|
Log::create(db, "Notification successfully sent".into()).await;
|
||||||
Flash::success(
|
Flash::success(
|
||||||
|
Loading…
Reference in New Issue
Block a user