This commit is contained in:
Mateusz Gruszczyński
2026-07-22 11:15:01 +02:00
parent 1be2023e36
commit 8bf45938ea
19 changed files with 189 additions and 33 deletions
+3 -2
View File
@@ -24,12 +24,13 @@ pub struct AppState {
pub upload_max_size_bytes: usize,
pub smtp: Option<SmtpConfig>,
pub registration_enabled: bool,
pub frontend_log_level: String,
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, 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()) }
pub fn new(db: Database, asset_version: String, files_dir: String, upload_max_size_bytes: usize, smtp: Option<SmtpConfig>, registration_enabled: bool, frontend_log_level: String) -> Self {
Self { db, asset_version, files_dir, upload_max_size_bytes, smtp, registration_enabled, frontend_log_level, 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(); }