big features

This commit is contained in:
Mateusz Gruszczyński
2026-07-22 11:03:50 +02:00
parent 0d77624adc
commit 1be2023e36
30 changed files with 1077 additions and 77 deletions
+7 -2
View File
@@ -4,6 +4,9 @@ use tokio::sync::{broadcast, RwLock};
const CHANNEL_CAPACITY: usize = 256;
#[derive(Debug, Clone)]
pub struct SmtpConfig { pub host: String, pub port: u16, pub username: String, pub password: String, pub from: String, pub public_url: String }
#[derive(Debug, Clone)]
pub struct NoteUpdate {
pub content: String,
@@ -19,12 +22,14 @@ pub struct AppState {
pub asset_version: String,
pub files_dir: String,
pub upload_max_size_bytes: usize,
pub smtp: Option<SmtpConfig>,
pub registration_enabled: bool,
channels: RwLock<HashMap<String, broadcast::Sender<NoteUpdate>>>,
}
impl AppState {
pub fn new(db: Database, asset_version: String, files_dir: String, upload_max_size_bytes: usize) -> Self {
Self { db, asset_version, files_dir, upload_max_size_bytes, channels: RwLock::new(HashMap::new()) }
pub fn new(db: Database, asset_version: String, files_dir: String, upload_max_size_bytes: usize, smtp: Option<SmtpConfig>, registration_enabled: bool) -> Self {
Self { db, asset_version, files_dir, upload_max_size_bytes, smtp, registration_enabled, channels: RwLock::new(HashMap::new()) }
}
async fn channel_for_key(&self, key: String) -> broadcast::Sender<NoteUpdate> {
if let Some(sender) = self.channels.read().await.get(&key) { return sender.clone(); }