Forum: daily sky thread, listeners, mentions, own avatars, restricted topics
- The worker opens a "Mai égbolt" thread every morning from the day's sky (no AI), pinned for the day. - Volunteer listeners (from the Kereső rank) get a badge, a count of the threads asking to be heard that still wait for a reply, and, if they ask, an e-mail after two hours of waiting. - "@Holdfény" names a member (nicknames with spaces too): they follow the thread, hear of it live and, if they asked, by e-mail; a search helps typing it. - From the Kereső rank a member may upload an own avatar: a small square JPEG without metadata in the object storage (now a shared crate with the backend), served by the forum; moderators can put the starter back. - The "Támogató" badge for buyers who switch it on. - The admin creates and edits topics; restricted ones are read by their approved members, who ask to join and moderators decide. - "Most itt vannak" on the front page; the weekly summary e-mail on Sunday evening for those who ask (off by default). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012vLHzh5qUhFtmJhzkcTbXL
This commit is contained in:
@@ -6,7 +6,8 @@
|
||||
//! or `Authorization: Bearer`) is valid here too.
|
||||
//!
|
||||
//! Configuration: `DATABASE_URL`, `PUBLIC_BASE_URL` (the site, for e-mail
|
||||
//! links; default `http://localhost:3001`); `BIND_ADDR` (default `0.0.0.0:8083`),
|
||||
//! links; default `http://localhost:3001`), `S3_*` (avatar uploads, as the
|
||||
//! backend's); `BIND_ADDR` (default `0.0.0.0:8083`),
|
||||
//! `LOG_FORMAT`, `RUST_LOG`, `LOG_DIR`. Database migrations run at startup.
|
||||
//!
|
||||
//! `forum healthcheck` performs a local health check (for Docker).
|
||||
@@ -37,11 +38,19 @@ pub struct AppState {
|
||||
pub base_url: String,
|
||||
/// The live events of this instance (`live::listen` fills it).
|
||||
pub hub: live::Hub,
|
||||
/// Where uploaded avatars are kept (`S3_*`); `None`: no uploads.
|
||||
pub storage: Option<object_storage::Storage>,
|
||||
}
|
||||
|
||||
impl AppState {
|
||||
pub fn new(db: PgPool, base_url: String) -> Self {
|
||||
Self { db, flood_secs: 5, base_url: base_url.trim_end_matches('/').to_string(), hub: live::Hub::default() }
|
||||
pub fn new(db: PgPool, base_url: String, storage: Option<object_storage::Storage>) -> Self {
|
||||
Self {
|
||||
db,
|
||||
flood_secs: 5,
|
||||
base_url: base_url.trim_end_matches('/').to_string(),
|
||||
hub: live::Hub::default(),
|
||||
storage,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -56,7 +65,12 @@ async fn main() -> anyhow::Result<()> {
|
||||
let pool = db::connect(&url).await.context("connecting to the database")?;
|
||||
db::migrate(&pool).await.context("running database migrations")?;
|
||||
let base_url = std::env::var("PUBLIC_BASE_URL").unwrap_or_else(|_| "http://localhost:3001".into());
|
||||
let state = Arc::new(AppState::new(pool, base_url));
|
||||
let storage =
|
||||
object_storage::StorageConfig::from_env().map_err(anyhow::Error::msg)?.map(object_storage::Storage::new);
|
||||
if storage.is_none() {
|
||||
tracing::info!("S3_ENDPOINT is not set: no avatar uploads");
|
||||
}
|
||||
let state = Arc::new(AppState::new(pool, base_url, storage));
|
||||
tokio::spawn(live::listen(state.db.clone(), state.hub.clone()));
|
||||
let app = routes::router(state);
|
||||
let listener = tokio::net::TcpListener::bind(addr).await.with_context(|| format!("binding {addr}"))?;
|
||||
|
||||
Reference in New Issue
Block a user