Forum: the "Alapító tag" badge for the first hundred members

The first hundred members (in the order they chose a nickname) keep it for
good; joining is serialised so there are never more than a hundred. Shown
next to the nickname in posts, author lines and profiles; the privacy
notice mentions 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:43:24 +00:00
co-authored by Claude Opus 5.5
parent 863002c1e7
commit 8fc550662e
12 changed files with 64 additions and 10 deletions
+9 -4
View File
@@ -16,6 +16,9 @@ use crate::auth::{self, Viewer};
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;
/// A nickname may change once in this many days (spelling fixes that keep the
/// same folded form any time).
const NICKNAME_CHANGE_DAYS: i64 = 30;
@@ -177,10 +180,12 @@ pub async fn save_me(
let mut tx = state.db.begin().await?;
let result = match &viewer.member {
None => {
sqlx::query(
"INSERT INTO forum.members (user_id, nickname, nickname_key, avatar, bio, chart_share, invisible) \
VALUES ($1, $2, $3, $4, $5, $6, $7)",
)
// One newcomer at a time, so the hundredth founder is the last.
sqlx::query("SELECT pg_advisory_xact_lock(hashtext('forum_founders'))").execute(&mut *tx).await?;
sqlx::query(&format!(
"INSERT INTO forum.members (user_id, nickname, nickname_key, avatar, bio, chart_share, invisible, founder) \
VALUES ($1, $2, $3, $4, $5, $6, $7, (SELECT count(*) < {FOUNDERS} FROM forum.members WHERE founder))"
))
.bind(user.id)
.bind(&nickname)
.bind(&key)