fix: remaining MEDIUM/LOW findings from 2026-07-21 audit rerun

- consume-invite: check-then-act race on single-use invite redemption —
  two concurrent redemptions could both pass the pre-check. Now guarded
  with an atomic updateMany(where: {code, usedById: null, revoked: false}).
- schema.prisma: added missing index on Report.targetPostId (used by
  admin.ts's groupBy/filter).
- RepostCard.tsx: reposter link used a raw <a> (full page reload) instead
  of next/link; the original poster's header had no link at all.
- Sidebar.tsx/MobileNav.tsx: removed the duplicated "set active pet on
  first load" effect — ActivePetInitializer already does this centrally
  and is mounted alongside both in the app layout.
- prisma.ts: removed the dead Vercel/Prisma Accelerate code path
  (PRISMA_ACCELERATE_URL is never set — this is a self-hosted Docker
  deployment) and the now-unused @prisma/extension-accelerate dependency.
- .env.example: corrected the NEXT_PUBLIC_APP_URL comment (Mux cors_origin
  is intentionally "*", not wired to it) and documented CRON_SECRET,
  which was missing despite both cron routes requiring it.
- reactions.ts: removed hasReacted/getCount — dead code with no frontend
  callers; getCount also duplicated the denormalized Post.reactionCount.
This commit is contained in:
admin committed 2026-07-22 19:34:18 +02:00
1 parent bf49024ace
commit 4fcde7eb2a
11 files changed
+358 -749

No files matched your search

+8 -4
View File
@@ -1,6 +1,7 @@
"use client";
import { useState, useEffect } from "react";
import Link from "next/link";
import { PawPrint } from "lucide-react";
import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar";
import { Separator } from "@/components/ui/separator";
@@ -81,16 +82,19 @@ function RepostCardInner({
<PawPrint className="h-3.5 w-3.5 text-orange-400" aria-hidden="true" />
<span className="text-xs text-muted-foreground">
Pawed-back by{" "}
<a href={`/pets/${post.pet.id}`} className="font-medium hover:underline">
<Link href={`/pets/${post.pet.id}`} className="font-medium hover:underline">
@{reposterName}
</a>
</Link>
</span>
</div>
<Separator className="mx-4" />
{/* Original pet header */}
<div className="flex items-center gap-3 px-4 py-3">
<Link
href={`/pets/${origPet.id}`}
className="flex items-center gap-3 px-4 py-3 hover:opacity-80 transition-opacity"
>
<Avatar className="w-8 h-8">
{origAvatarUrl && (
<AvatarImage src={origAvatarUrl} alt={origPet.name} />
@@ -102,7 +106,7 @@ function RepostCardInner({
<p className="text-base font-semibold text-foreground leading-tight truncate">
{origPet.name}
</p>
</div>
</Link>
{/* Original images */}
{origImages.length > 0 && (
+3 -6
View File
@@ -1,6 +1,6 @@
"use client";
import { useState, useEffect } from "react";
import { useState } from "react";
import Link from "next/link";
import { usePathname, useRouter } from "next/navigation";
import {
@@ -61,11 +61,8 @@ export function MobileNav({ pets }: MobileNavProps) {
const activePet = pets.find((p) => p.id === activePetId) ?? pets[0];
const [postTypeSheetOpen, setPostTypeSheetOpen] = useState(false);
useEffect(() => {
if (!activePetId && pets.length > 0) {
setActivePet(pets[0].id);
}
}, [activePetId, pets, setActivePet]);
// First-load fallback is handled once, centrally, by ActivePetInitializer
// (mounted alongside Sidebar/MobileNav in the app layout) — don't duplicate it here.
// D-05: Home → /feed; also highlight when on / (which redirects to /feed)
const isHomePage = pathname === "/feed" || pathname === "/";
+3 -6
View File
@@ -1,6 +1,6 @@
"use client";
import { useState, useEffect } from "react";
import { useState } from "react";
import Link from "next/link";
import { usePathname, useRouter } from "next/navigation";
import {
@@ -79,11 +79,8 @@ export function Sidebar({ pets }: SidebarProps) {
const activePet = pets.find((p) => p.id === activePetId) ?? pets[0];
const [postTypeSheetOpen, setPostTypeSheetOpen] = useState(false);
useEffect(() => {
if (!activePetId && pets.length > 0) {
setActivePet(pets[0].id);
}
}, [activePetId, pets, setActivePet]);
// First-load fallback is handled once, centrally, by ActivePetInitializer
// (mounted alongside Sidebar/MobileNav in the app layout) — don't duplicate it here.
return (
<nav className="hidden lg:flex flex-col w-[240px] h-screen sticky top-0 bg-card border-r border shrink-0 overflow-y-auto">