session lifetime

This commit is contained in:
Mateusz Gruszczyński
2026-07-22 23:49:16 +02:00
parent e998a38e49
commit 3ed74b1eac
20 changed files with 262 additions and 74 deletions
+4 -2
View File
@@ -28,12 +28,14 @@ pub struct AppState {
pub registration_enabled: bool,
pub account_confirmation_required: bool,
pub frontend_log_level: String,
pub anonymous_access_token_ttl_days: i64,
pub user_session_ttl_days: i64,
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, account_confirmation_required: bool, frontend_log_level: String) -> Self {
Self { db, asset_version, files_dir, upload_max_size_bytes, smtp, registration_enabled, account_confirmation_required, frontend_log_level, 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, account_confirmation_required: bool, frontend_log_level: String, anonymous_access_token_ttl_days: i64, user_session_ttl_days: i64) -> Self {
Self { db, asset_version, files_dir, upload_max_size_bytes, smtp, registration_enabled, account_confirmation_required, frontend_log_level, anonymous_access_token_ttl_days, user_session_ttl_days, 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(); }