feat: ad engagement, invite gate, sidebar footer, docker setup

Ad interactions (reactions/comments/reposts on ads):
- Schema: AdReaction, AdComment, AdRepost models with RLS enabled
- tRPC: new ads router (getFeedData, toggleReaction, addComment, listComments, toggleRepost)
- AdCard: fully interactive card with paw, comment sheet, repost — mirrors PostCard style
- getActiveAds includes _count for advertiser engagement metrics

Invite system enforcement:
- proxy.ts: /sign-up blocked without pf_invite cookie
- INVITE_REQUIRED=false env var disables gate for post-beta live launch
- Full invite flow: /join → cookie → /sign-up → consume-invite → 3 codes issued to new user
- Admin: listInviteCodes, createRootInvite, revokeInvite procedures

Sidebar mini-footer:
- Impressum + Datenschutz links always visible at sidebar bottom
- PawFeed Alpha-Test copyright line

Docker self-hosting:
- docker/Dockerfile: 3-stage build using Next.js standalone output
- docker/docker-compose.yml: env_file + build-args for NEXT_PUBLIC_ vars
- .dockerignore at project root
- next.config.ts: output standalone for minimal image
- .env.example: documented INVITE_REQUIRED
This commit is contained in:
admin committed 2026-06-21 18:12:13 +02:00
1 parent a9793a5ad2
commit 5800e06cd9
24 files changed
+1162 -108

No files matched your search

+56
View File
@@ -0,0 +1,56 @@
import { auth } from "@clerk/nextjs/server";
import { cookies } from "next/headers";
import { redirect } from "next/navigation";
import { prisma } from "@/lib/prisma";
import { generateInviteCode, INVITE_CODES_PER_USER } from "@/lib/invite-codes";
export async function GET() {
const { userId } = await auth();
if (!userId) redirect("/log-in");
const cookieStore = await cookies();
const inviteCode = cookieStore.get("pf_invite")?.value;
if (inviteCode) {
await consumeInviteCode(userId, inviteCode);
cookieStore.delete("pf_invite");
}
redirect("/");
}
async function consumeInviteCode(userId: string, code: string) {
const invite = await prisma.inviteCode.findUnique({ where: { code } });
if (!invite || invite.usedById || invite.revoked) return;
await prisma.$transaction(async (tx) => {
await tx.inviteCode.update({
where: { code },
data: { usedById: userId, usedAt: new Date() },
});
await tx.owner.upsert({
where: { id: userId },
create: {
id: userId,
invitedById: invite.issuedById ?? null,
},
update: {
invitedById: invite.issuedById ?? undefined,
},
});
const existingCodes = await tx.inviteCode.count({
where: { issuedById: userId },
});
if (existingCodes === 0) {
await tx.inviteCode.createMany({
data: Array.from({ length: INVITE_CODES_PER_USER }, () => ({
code: generateInviteCode(),
issuedById: userId,
})),
});
}
});
}