add: products ui

This commit is contained in:
trisua 2025-08-08 02:17:06 -04:00
parent 8f76578f1b
commit fd529d3847
31 changed files with 1041 additions and 49 deletions

View file

@ -1,5 +1,6 @@
use std::collections::HashMap;
use crate::model::auth::Notification;
use crate::model::{auth::User, mail::Letter, permissions::SecondaryPermission, Error, Result};
use crate::{auto_method, DataManager};
use oiseau::{cache::Cache, execute, get, params, query_rows, PostgresRow};
@ -160,6 +161,9 @@ impl DataManager {
return Err(Error::DataTooLong("receivers".to_string()));
}
// get sender
let sender = self.get_user_by_id(data.owner).await?;
// ...
let conn = match self.0.connect().await {
Ok(c) => c,
@ -185,6 +189,20 @@ impl DataManager {
return Err(Error::DatabaseError(e.to_string()));
}
// send notifications
for x in &data.receivers {
self.create_notification(Notification::new(
"You've got mail!".to_string(),
format!(
"[@{}](/api/v1/auth/user/find/{}) has sent you a [letter](/mail/letter/{}).",
sender.username, sender.id, data.id
),
*x,
))
.await?;
}
// ...
Ok(data)
}