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:
@@ -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)
|
||||
|
||||
@@ -230,6 +230,7 @@ struct AuthorRow {
|
||||
roles: Vec<String>,
|
||||
listener: bool,
|
||||
supporter: bool,
|
||||
founder: bool,
|
||||
}
|
||||
|
||||
/// How members appear next to what they wrote: nickname, avatar, rank,
|
||||
@@ -243,7 +244,7 @@ pub async fn authors(db: &PgPool, ids: impl IntoIterator<Item = Uuid>) -> Result
|
||||
}
|
||||
let rows: Vec<AuthorRow> = sqlx::query_as(
|
||||
"SELECT m.user_id, m.nickname, m.avatar, m.points, m.created_at, m.invisible, m.last_seen_at, \
|
||||
m.chart_share, u.roles, m.listener, \
|
||||
m.chart_share, u.roles, m.listener, m.founder, \
|
||||
m.supporter_badge AND EXISTS (SELECT 1 FROM package_orders o \
|
||||
WHERE o.user_id = m.user_id AND o.source = 'stripe') AS supporter \
|
||||
FROM forum.members m JOIN users u ON u.id = m.user_id WHERE m.user_id = ANY($1)",
|
||||
@@ -270,6 +271,7 @@ pub async fn authors(db: &PgPool, ids: impl IntoIterator<Item = Uuid>) -> Result
|
||||
"signs": shown,
|
||||
"listener": r.listener,
|
||||
"supporter": r.supporter,
|
||||
"founder": r.founder,
|
||||
});
|
||||
(r.user_id, value)
|
||||
})
|
||||
|
||||
@@ -1314,3 +1314,26 @@ async fn a_question_about_ones_chart(pool: PgPool) {
|
||||
.unwrap();
|
||||
assert!(revoked);
|
||||
}
|
||||
|
||||
#[sqlx::test(migrator = "db::MIGRATOR")]
|
||||
async fn the_first_hundred_are_founders(pool: PgPool) {
|
||||
let app = TestApp::new(pool);
|
||||
let anna = app.member("anna@example.com", "Csendesvíz", &["user"]).await;
|
||||
// Ninety-nine more founders already (made up), then Bea comes too late.
|
||||
sqlx::query(
|
||||
"WITH u AS (INSERT INTO users (id, email, display_name) \
|
||||
SELECT gen_random_uuid(), 'f' || n || '@example.invalid', 'F' FROM generate_series(1, 99) n \
|
||||
RETURNING id, email) \
|
||||
INSERT INTO forum.members (user_id, nickname, nickname_key, avatar, founder) \
|
||||
SELECT id, 'Alapito ' || email, 'alapito ' || email, 'hold-ejkek', true FROM u",
|
||||
)
|
||||
.execute(&app.pool)
|
||||
.await
|
||||
.unwrap();
|
||||
let bea = app.member("bea@example.com", "Holdfény", &["user"]).await;
|
||||
let thread = app.thread(&anna, "torzsasztal", "Sziasztok").await;
|
||||
app.reply(&bea, thread, "Szia!", None).await;
|
||||
let shown = app.get(&format!("/v1/forum/threads/{thread}"), None).await;
|
||||
assert_eq!(shown["posts"][0]["author"]["founder"], true);
|
||||
assert_eq!(shown["posts"][1]["author"]["founder"], false);
|
||||
}
|
||||
|
||||
@@ -152,8 +152,8 @@ export default async function PrivacyPage() {
|
||||
Fórumprofilod: az álneved (a korábbiakat 90 napig, hogy más ne vehesse fel), az avatarod vagy a
|
||||
feltöltött saját képed (kicsinyítve, a kép rejtett adatai, például a helyszín nélkül), a
|
||||
bemutatkozásod, a képletedből megosztott jegyek, hogy önkéntes kísérő vagy-e, a Támogató
|
||||
jelvény (ha bekapcsolod, mások látják, hogy vásároltál), a láthatatlan mód és az e-mail-értesítések
|
||||
beállítása
|
||||
jelvény (ha bekapcsolod, mások látják, hogy vásároltál), hogy az első száz tag közé tartozol-e
|
||||
(Alapító tag), a láthatatlan mód és az e-mail-értesítések beállítása
|
||||
</td>
|
||||
<td>Részvétel a fórumon; a jegyek megosztása és a jelvények a saját döntésed</td>
|
||||
<td>Szerződés teljesítése</td>
|
||||
|
||||
@@ -567,6 +567,7 @@ body:has(.forum[data-theme="light"]) .site-footer { background: #0d1220; }
|
||||
.fp-mention:hover { color: var(--gold-hover); }
|
||||
.fa-badge-listener { color: var(--harmonic); background: var(--f-blue-tint); }
|
||||
.fa-badge-supporter { color: var(--gold); background: var(--f-tint); }
|
||||
.fa-badge-founder { color: var(--ok); border: 1px solid var(--line-2); }
|
||||
|
||||
/* --- own pictures and the site's mark --- */
|
||||
.av-picture img { display: block; width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }
|
||||
|
||||
@@ -49,6 +49,7 @@ export default async function MemberPage({ params }: Props) {
|
||||
<span className="fmember-badges">
|
||||
<RankBadge rank={a.rank} name={a.rank_name} />
|
||||
{a.moderator && <Badge kind="mod" />}
|
||||
{a.founder && <Badge kind="founder" />}
|
||||
{a.listener && <Badge kind="listener" />}
|
||||
{a.supporter && <Badge kind="supporter" />}
|
||||
</span>
|
||||
|
||||
@@ -85,7 +85,7 @@ const DATA: [string, string, string][] = [
|
||||
"Legitimate interest (Art. 6(1)(f))",
|
||||
],
|
||||
[
|
||||
"Your forum profile: your nickname (earlier ones for 90 days, so nobody else can take them), your avatar or the picture you uploaded (made smaller, without its hidden data such as the location), introduction, the signs of your chart you share, whether you are a volunteer companion (Kísérő), the Támogató (supporter) badge (if you switch it on, others see that you bought something), the invisible mode and your e-mail notification settings",
|
||||
"Your forum profile: your nickname (earlier ones for 90 days, so nobody else can take them), your avatar or the picture you uploaded (made smaller, without its hidden data such as the location), introduction, the signs of your chart you share, whether you are a volunteer companion (Kísérő), the Támogató (supporter) badge (if you switch it on, others see that you bought something), whether you were among the first hundred members (Alapító tag – founder), the invisible mode and your e-mail notification settings",
|
||||
"Taking part in the forum; sharing the signs and the badges is your choice",
|
||||
"Performance of the contract",
|
||||
],
|
||||
|
||||
@@ -103,6 +103,7 @@ export function AuthorLine({
|
||||
{author.online && <span className="sr-only">(online)</span>}
|
||||
<RankBadge rank={author.rank} name={author.rank_name} />
|
||||
{author.moderator && <Badge kind="mod" />}
|
||||
{author.founder && <Badge kind="founder" />}
|
||||
{author.listener && <Badge kind="listener" />}
|
||||
{author.supporter && <Badge kind="supporter" />}
|
||||
{badges}
|
||||
|
||||
@@ -43,7 +43,7 @@ const RANK_ICONS: Record<Rank, React.ReactNode> = {
|
||||
),
|
||||
};
|
||||
|
||||
export type BadgeKind = "mod" | "listener" | "supporter" | "starter" | "sky";
|
||||
export type BadgeKind = "mod" | "founder" | "listener" | "supporter" | "starter" | "sky";
|
||||
|
||||
const BADGES: Record<BadgeKind, { label: string; title: string; icon: React.ReactNode }> = {
|
||||
// A shield with a tick.
|
||||
@@ -57,6 +57,19 @@ const BADGES: Record<BadgeKind, { label: string; title: string; icon: React.Reac
|
||||
</>
|
||||
),
|
||||
},
|
||||
// A sprout: there from the beginning.
|
||||
founder: {
|
||||
label: "Alapító tag",
|
||||
title: "A fórum első száz tagja közül való",
|
||||
icon: (
|
||||
<>
|
||||
<path d="M12 20.5V11" />
|
||||
<path d="M12 12.5c0-4 2.8-6.5 7-6.5 0 4-2.8 6.5-7 6.5z" />
|
||||
<path d="M12 14.5c0-3.2-2.4-5.5-6-5.5 0 3.2 2.4 5.5 6 5.5z" />
|
||||
<path d="M8 20.5h8" />
|
||||
</>
|
||||
),
|
||||
},
|
||||
// Two walking side by side.
|
||||
listener: {
|
||||
label: "Kísérő",
|
||||
@@ -118,7 +131,7 @@ export function RankBadge({ rank, name }: { rank: Rank; name: string }) {
|
||||
);
|
||||
}
|
||||
|
||||
/** A badge (Moderátor, Kísérő, Támogató, Szálindító, napi égbolt), with its icon. */
|
||||
/** A badge (Moderátor, Alapító tag, Kísérő, Támogató, Szálindító, napi égbolt), with its icon. */
|
||||
export function Badge({ kind }: { kind: BadgeKind }) {
|
||||
const b = BADGES[kind];
|
||||
return (
|
||||
|
||||
@@ -285,6 +285,7 @@ function PostCard({
|
||||
{author && <RankBadge rank={author.rank} name={author.rank_name} />}
|
||||
{post.system && <Badge kind="sky" />}
|
||||
{author?.moderator && <Badge kind="mod" />}
|
||||
{author?.founder && !nested && <Badge kind="founder" />}
|
||||
{author?.listener && <Badge kind="listener" />}
|
||||
{author?.supporter && <Badge kind="supporter" />}
|
||||
{starter && !post.is_opening && <Badge kind="starter" />}
|
||||
|
||||
@@ -23,6 +23,8 @@ export interface ForumAuthor {
|
||||
listener?: boolean;
|
||||
/** Bought a package and shows the "Támogató" badge. */
|
||||
supporter?: boolean;
|
||||
/** One of the first hundred members ("Alapító tag"). */
|
||||
founder?: boolean;
|
||||
}
|
||||
|
||||
export interface ForumViewer {
|
||||
|
||||
Reference in New Issue
Block a user