From a81ba2e54a2559c80046b6b647bc2f7afec36c24 Mon Sep 17 00:00:00 2001 From: chahinebrini Date: Sat, 9 May 2026 22:28:07 +0200 Subject: [PATCH] feat(community): Post.gameName + GameShareBanner-rendering chain Adds optional `gameName` column to community_posts so game-share posts can render with the game-banner above the post-content (Snake/Tetris/ Memory/TTT visual indicator). - prisma/schema.prisma: CommunityPost.gameName String? @map("game_name") - migration: ALTER TABLE rebreak.community_posts ADD COLUMN game_name - db/community.ts: createPost() accepts gameName param - api/community/post.post.ts: extracts gameName from body - api/community/posts.get.ts: returns gameName, prefers DB over content-parse Frontend (already in flight on upgrade/sdk-54): PostCard.tsx renders GameShareBanner when post.category === 'game_share' && post.gameName. Co-Authored-By: Claude Opus 4.7 (1M context) --- .../migrations/20260509_add_post_game_name/migration.sql | 3 +++ backend/prisma/schema.prisma | 1 + backend/server/api/community/post.post.ts | 5 +++-- backend/server/api/community/posts.get.ts | 4 ++-- backend/server/db/community.ts | 2 ++ 5 files changed, 11 insertions(+), 4 deletions(-) create mode 100644 backend/prisma/migrations/20260509_add_post_game_name/migration.sql diff --git a/backend/prisma/migrations/20260509_add_post_game_name/migration.sql b/backend/prisma/migrations/20260509_add_post_game_name/migration.sql new file mode 100644 index 0000000..761a80e --- /dev/null +++ b/backend/prisma/migrations/20260509_add_post_game_name/migration.sql @@ -0,0 +1,3 @@ +-- Migration: add game_name column to community_posts +-- Generated: 2026-05-09 +ALTER TABLE "rebreak"."community_posts" ADD COLUMN "game_name" TEXT; diff --git a/backend/prisma/schema.prisma b/backend/prisma/schema.prisma index 518c1f3..644b2af 100644 --- a/backend/prisma/schema.prisma +++ b/backend/prisma/schema.prisma @@ -160,6 +160,7 @@ model CommunityPost { deletedAt DateTime? @map("deleted_at") /// Wann der Post zum ersten Mal gemeldet wurde (queue-Sortierung). reportedAt DateTime? @map("reported_at") + gameName String? @map("game_name") repostOfId String? @map("repost_of_id") @db.Uuid challengeId String? @map("challenge_id") @db.Uuid createdAt DateTime @default(now()) @map("created_at") diff --git a/backend/server/api/community/post.post.ts b/backend/server/api/community/post.post.ts index e9719a4..bd53c0f 100644 --- a/backend/server/api/community/post.post.ts +++ b/backend/server/api/community/post.post.ts @@ -14,10 +14,11 @@ export default defineEventHandler(async (event) => { const user = await requireUser(event); const body = await readBody(event); - const { category, content, imageUrl } = body as { + const { category, content, imageUrl, gameName } = body as { category: string; content: string; imageUrl?: string; + gameName?: string | null; }; if (!content?.trim() || !category) { @@ -72,7 +73,7 @@ export default defineEventHandler(async (event) => { } } - const data = await createPost(user.id, category, content.trim(), imageUrl); + const data = await createPost(user.id, category, content.trim(), imageUrl, gameName ?? null); // Punkte vergeben await awardPoints(user.id, "post_created", { post_id: data.id }); diff --git a/backend/server/api/community/posts.get.ts b/backend/server/api/community/posts.get.ts index df1bf93..47162b1 100644 --- a/backend/server/api/community/posts.get.ts +++ b/backend/server/api/community/posts.get.ts @@ -64,9 +64,9 @@ export default defineEventHandler(async (event) => { : null, gameName: (p as any).challengeId ? challengeStatuses[(p as any).challengeId]?.gameType ?? null - : p.category === "game_share" + : (p as any).gameName ?? (p.category === "game_share" ? p.content.split("\n")[0] ?? null - : null, + : null), opponentName: (p as any).challengeId ? challengeStatuses[(p as any).challengeId]?.opponentName ?? null : null, diff --git a/backend/server/db/community.ts b/backend/server/db/community.ts index 84dee20..85887c6 100644 --- a/backend/server/db/community.ts +++ b/backend/server/db/community.ts @@ -256,6 +256,7 @@ export async function createPost( category: string, content: string, imageUrl?: string, + gameName?: string | null, ) { const db = usePrisma(); return db.communityPost.create({ @@ -264,6 +265,7 @@ export async function createPost( category, content, imageUrl: imageUrl || null, + gameName: gameName ?? null, isAnonymous: false, isModerated: false, },