pub mod actions;
pub mod api;
pub mod auth;
pub mod avatar;
pub mod category_tree;
pub mod client_ip;
pub mod config;
pub mod entities;
pub mod handlers;
pub mod ips;
pub mod lameness;
pub mod links;
pub mod mailer;
pub mod markdown;
pub mod live;
pub mod meta;
pub mod registration;
pub mod seed;
pub mod middleware;
pub mod moderation;
pub mod policy;
pub mod timeutil;
pub mod trust;
pub mod web;
pub use config::{create_db_connection, Config};
use minijinja::Environment;
use std::collections::HashMap;
use std::sync::{Arc, Mutex};
use std::time::Instant;
use uuid::Uuid;
/// Per-`(topic, viewer)` last-bump timestamps, used to rate-limit view-count
/// increments so refreshes don't inflate the count. In-memory (resets on
/// restart, not shared across instances) — fine for this single-process app.
pub type ViewThrottle = Arc<Mutex<HashMap<(Uuid, String), Instant>>>;
pub fn new_view_throttle() -> ViewThrottle {
Arc::new(Mutex::new(HashMap::new()))
}
/// Shared application state handed to every handler via `axum`'s `State`
/// extractor.
#[derive(Clone)]
pub struct AppState {
pub env: Environment<'static>,
pub db: Arc<sea_orm::DatabaseConnection>,
pub config: Arc<Config>,
pub view_throttle: ViewThrottle,
/// Outbound mail: mail-prism when configured, else the log.
pub mailer: Arc<dyn mailer::Mailer>,
/// Live-update events and WebSocket connections (`live`).
pub live: Arc<live::Hub>,
}
neiam
/recourse
public · Issues · Pulls · Labels · Forks · Compare · Actions queued · Badges · Packages
⭐
Log in to mark this repository.
1.4 KiB · text
History
84bfe6e