show notification to vorstand if boat entry with 'externes boot' or on multiple days is entered
This commit is contained in:
@ -4,7 +4,7 @@ use chrono::NaiveDateTime;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use sqlx::{FromRow, Sqlite, SqlitePool, Transaction};
|
||||
|
||||
use super::user::User;
|
||||
use super::{role::Role, user::User};
|
||||
|
||||
#[derive(FromRow, Debug, Serialize, Deserialize)]
|
||||
pub struct Notification {
|
||||
@ -55,6 +55,20 @@ impl Notification {
|
||||
tx.commit().await.unwrap();
|
||||
}
|
||||
|
||||
pub async fn create_for_role_tx(
|
||||
db: &mut Transaction<'_, Sqlite>,
|
||||
role: &Role,
|
||||
message: &str,
|
||||
category: &str,
|
||||
link: Option<&str>,
|
||||
) {
|
||||
let users = User::all_with_role_tx(db, role).await;
|
||||
|
||||
for user in users {
|
||||
Self::create_with_tx(db, &user, message, category, link).await;
|
||||
}
|
||||
}
|
||||
|
||||
pub async fn for_user(db: &SqlitePool, user: &User) -> Vec<Self> {
|
||||
sqlx::query_as!(
|
||||
Self,
|
||||
|
Reference in New Issue
Block a user