Forum: founders are the first fifteen; the admin can take or give the badge

The site has few members yet, some of them test accounts: the badge goes to
the first fifteen, and the admin can take it from a test account on its
profile (the place goes to the next newcomer) or give it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012vLHzh5qUhFtmJhzkcTbXL
This commit is contained in:
feco
2026-11-26 15:46:44 +00:00
co-authored by Claude Opus 5.5
parent 8fc550662e
commit 493539bf56
10 changed files with 106 additions and 11 deletions
+1 -1
View File
@@ -17,7 +17,7 @@ use crate::error::{ApiError, ApiResult};
use crate::text;
/// The first this many members get the "Alapító tag" badge for good.
const FOUNDERS: i64 = 100;
pub const FOUNDERS: i64 = 15;
/// A nickname may change once in this many days (spelling fixes that keep the
/// same folded form any time).
+1
View File
@@ -91,6 +91,7 @@ pub fn router(state: Arc<AppState>) -> Router {
.route("/v1/forum/members/search", get(mentions::search))
.route("/v1/forum/members/{nickname}", get(members::profile))
.route("/v1/forum/members/{nickname}/mute", put(mutes::mute).delete(mutes::unmute))
.route("/v1/forum/members/{nickname}/founder", put(mutes::set_founder))
.route("/v1/forum/me/mutes", get(mutes::list))
.route("/v1/forum/members/{nickname}/ban", post(moderation::ban).delete(moderation::unban))
.route("/v1/forum/mod/log", get(moderation::log))
+27
View File
@@ -2,6 +2,7 @@
//! muter's lists, their posts fold up (one click shows them), their replies
//! and mentions no longer notify, and they drop out of "Most itt vannak".
//! The muted member is not told, and can still be reported.
//! (Also here: the admin's switch for the "Alapító tag" badge.)
use axum::Json;
use axum::extract::{Path, State};
@@ -65,3 +66,29 @@ pub async fn list(State(state): St, viewer: Viewer) -> ApiResult<Json<Value>> {
muted.sort_by(|a, b| a["nickname"].as_str().cmp(&b["nickname"].as_str()));
Ok(Json(json!({ "muted": muted })))
}
/// The admin takes the "Alapító tag" badge from a member (a test account) or
/// gives it; a place taken away goes to the next newcomer.
pub async fn set_founder(
State(state): St,
viewer: Viewer,
WithRejection(Path(nickname), _): WithRejection<Path<String>, ApiError>,
WithRejection(axum::Json(req), _): WithRejection<axum::Json<FounderChange>, ApiError>,
) -> ApiResult<StatusCode> {
viewer.require_user()?;
if !viewer.is_admin() {
return Err(ApiError::Forbidden("Ezt csak az admin teheti meg.".into()));
}
let target = member_id(&state, &nickname).await?;
sqlx::query("UPDATE forum.members SET founder = $2 WHERE user_id = $1")
.bind(target)
.bind(req.founder)
.execute(&state.db)
.await?;
Ok(StatusCode::NO_CONTENT)
}
#[derive(serde::Deserialize)]
pub struct FounderChange {
founder: bool,
}