mirror of
https://github.com/Memo-2023/mana-monorepo.git
synced 2026-05-19 06:41:23 +02:00
feat(community): Phase 3.C — Identität (Avatar + Klarname-Toggle + Karma + Eulen-Profil)
Macht aus den Pseudonymen echte Charaktere ohne Klarnamen-Zwang.
Pixel-Identicon-Avatar (3.C.2):
- generateAvatarSvg(displayHash) — pure-function, deterministisch.
5×5 left-mirrored Identicon mit HSL-Foreground/Background aus dem
Hash. Inline-SVG, kein Storage, kein img-load-Flicker.
- <EulenAvatar> Component im Package, in ItemCard neben dem Pseudonym.
Klarname-Toggle (3.C.1):
- auth.users + community_show_real_name boolean (default off, opt-in).
- PATCH /api/v1/me/profile akzeptiert communityShowRealName.
- mana-analytics LEFT JOINs auth.users → bei opt-in liefert auth-
required /public + /me/reacted Endpoints zusätzlich realName.
- Anonymous /api/v1/public/feedback/* zeigt realName NIE — auch nicht
wenn opted-in. Public-Mirror bleibt für SEO + Privacy safe.
- Migration 008_community_identity.sql lokal + prod eingespielt.
Karma-System (3.C.3):
- auth.users + community_karma int. toggleReaction increment/decrement
am Author-User (Self-Reactions zählen nicht — kein Self-Farming).
- KARMA_THRESHOLDS + tierFromKarma() im Package: Bronze (0-9) /
Silver (10-49) / Gold (50-199) / Platin (200+).
- ItemCard zeigt Tier-Dot neben dem Pseudonym, Title-Tooltip mit
Karma-Zahl. Floor-clamped at 0.
Eulen-Profil (3.C.4):
- GET /api/v1/public/feedback/eule/{hash} — alle public-Posts dieser
Eule + aggregiertes Karma. SHA256-Format-Validation.
- /community/eule/[hash] Public-SSR-Route mit Avatar-Hero, Tier-Badge,
Karma-Counter, Post-Liste. Author-Klick im ItemCard navigiert hin.
- publicFeedbackService.getEulenProfile() im Package.
PublicFeedbackItem erweitert um displayHash (public Pseudonym-ID,
SHA256 ist one-way → safe to expose) + karma + optional realName.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
42e4d58c8c
commit
ee5bb2871c
16 changed files with 760 additions and 23 deletions
|
|
@ -54,6 +54,9 @@ export interface PublicFeedbackItem {
|
|||
status: FeedbackStatus;
|
||||
moduleContext: string | null;
|
||||
parentId: string | null;
|
||||
/** Pseudonym-ID — non-reversible SHA256(userId+secret). Stable
|
||||
* across sessions, used for avatar generation and Eulen-Profil-URLs. */
|
||||
displayHash: string;
|
||||
displayName: string;
|
||||
reactions: Partial<Record<string, number>>;
|
||||
score: number;
|
||||
|
|
@ -62,6 +65,11 @@ export interface PublicFeedbackItem {
|
|||
updatedAt: string;
|
||||
/** Auth-only: which emojis the requesting user has reacted with. */
|
||||
myReactions?: string[];
|
||||
/** Auth-only + opt-in: post-author's real name when they enabled
|
||||
* the Klarname-Toggle. Anonymous public-mirror NEVER includes this. */
|
||||
realName?: string;
|
||||
/** Author's community karma — public, drives the tier-badge. */
|
||||
karma?: number;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -128,6 +136,34 @@ export const FEEDBACK_CATEGORY_LABELS: Record<FeedbackCategory, string> = {
|
|||
other: 'Sonstiges',
|
||||
};
|
||||
|
||||
/**
|
||||
* Karma → Tier-Mapping. Bronze ist Default für jeden, Tier wird sichtbar
|
||||
* neben dem Pseudonym in ItemCard.
|
||||
*/
|
||||
export type KarmaTier = 'bronze' | 'silver' | 'gold' | 'platinum';
|
||||
|
||||
export const KARMA_THRESHOLDS = {
|
||||
bronze: 0,
|
||||
silver: 10,
|
||||
gold: 50,
|
||||
platinum: 200,
|
||||
} as const satisfies Record<KarmaTier, number>;
|
||||
|
||||
export const KARMA_TIER_CONFIG: Record<KarmaTier, { label: string; emoji: string; color: string }> =
|
||||
{
|
||||
bronze: { label: 'Bronze', emoji: '🦉', color: '#a16207' },
|
||||
silver: { label: 'Silver', emoji: '🦉', color: '#737373' },
|
||||
gold: { label: 'Gold', emoji: '🦉', color: '#d97706' },
|
||||
platinum: { label: 'Platin', emoji: '🦉', color: '#7c3aed' },
|
||||
};
|
||||
|
||||
export function tierFromKarma(karma: number): KarmaTier {
|
||||
if (karma >= KARMA_THRESHOLDS.platinum) return 'platinum';
|
||||
if (karma >= KARMA_THRESHOLDS.gold) return 'gold';
|
||||
if (karma >= KARMA_THRESHOLDS.silver) return 'silver';
|
||||
return 'bronze';
|
||||
}
|
||||
|
||||
export const FEEDBACK_STATUS_CONFIG: Record<
|
||||
FeedbackStatus,
|
||||
{ label: string; color: string; icon: string }
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue