mirror of
https://github.com/Memo-2023/mana-monorepo.git
synced 2026-05-19 09:21:24 +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
|
|
@ -53,6 +53,14 @@ export const users = authSchema.table('users', {
|
|||
// → Look → Templates). The flow is skippable, but even a skip sets
|
||||
// this timestamp so we don't re-prompt. See docs/plans/onboarding-flow.md.
|
||||
onboardingCompletedAt: timestamp('onboarding_completed_at', { withTimezone: true }),
|
||||
// Community-Hub identity opt-ins (Phase 3.C of feedback-rewards-and-identity).
|
||||
// Off by default — users stay anonymous as their tier-pseudonym ("Wachsame
|
||||
// Eule #4528"). Opt-in shows the real `name` next to the pseudonym in the
|
||||
// auth-required community feed only; the public-mirror NEVER exposes it.
|
||||
communityShowRealName: boolean('community_show_real_name').default(false).notNull(),
|
||||
// Karma += 1 per reaction received from another user, decremented on unreact.
|
||||
// Drives the public Bronze/Silver/Gold/Platinum-Eulen tier badge.
|
||||
communityKarma: integer('community_karma').default(0).notNull(),
|
||||
});
|
||||
|
||||
// Sessions table (Better Auth schema)
|
||||
|
|
|
|||
|
|
@ -72,9 +72,15 @@ export function createMeRoutes(userDataService: UserDataService, db: Database) {
|
|||
const body = (await c.req.json().catch(() => ({}))) as {
|
||||
name?: unknown;
|
||||
image?: unknown;
|
||||
communityShowRealName?: unknown;
|
||||
};
|
||||
|
||||
const patch: { name?: string; image?: string; updatedAt: Date } = {
|
||||
const patch: {
|
||||
name?: string;
|
||||
image?: string;
|
||||
communityShowRealName?: boolean;
|
||||
updatedAt: Date;
|
||||
} = {
|
||||
updatedAt: new Date(),
|
||||
};
|
||||
if (typeof body.name === 'string') {
|
||||
|
|
@ -87,8 +93,11 @@ export function createMeRoutes(userDataService: UserDataService, db: Database) {
|
|||
if (typeof body.image === 'string') {
|
||||
patch.image = body.image;
|
||||
}
|
||||
if (typeof body.communityShowRealName === 'boolean') {
|
||||
patch.communityShowRealName = body.communityShowRealName;
|
||||
}
|
||||
|
||||
if (!('name' in patch) && !('image' in patch)) {
|
||||
if (!('name' in patch) && !('image' in patch) && !('communityShowRealName' in patch)) {
|
||||
return c.json({ error: 'no fields to update' }, 400);
|
||||
}
|
||||
|
||||
|
|
@ -96,10 +105,19 @@ export function createMeRoutes(userDataService: UserDataService, db: Database) {
|
|||
.update(users)
|
||||
.set(patch)
|
||||
.where(eq(users.id, user.userId))
|
||||
.returning({ id: users.id, name: users.name, image: users.image });
|
||||
.returning({
|
||||
id: users.id,
|
||||
name: users.name,
|
||||
image: users.image,
|
||||
communityShowRealName: users.communityShowRealName,
|
||||
});
|
||||
|
||||
if (!updated) return c.json({ error: 'User not found' }, 404);
|
||||
return c.json({ name: updated.name, image: updated.image });
|
||||
return c.json({
|
||||
name: updated.name,
|
||||
image: updated.image,
|
||||
communityShowRealName: updated.communityShowRealName,
|
||||
});
|
||||
})
|
||||
);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue