import "server-only"; import { TRPCError } from "@trpc/server"; import type { PrismaClient } from "@prisma/client"; /** * Blocks apply in both directions and must gate direct interaction * (comments, reactions, reposts), not just feed visibility — see * blocks.ts's own doc comment on why feed hydration alone isn't enough. */ export async function assertNotBlocked( prisma: PrismaClient, petIdA: string, petIdB: string ) { if (petIdA === petIdB) return; const block = await prisma.block.findFirst({ where: { OR: [ { blockerPetId: petIdA, blockedPetId: petIdB }, { blockerPetId: petIdB, blockedPetId: petIdA }, ], }, }); if (block) { throw new TRPCError({ code: "FORBIDDEN", message: "Cannot interact with this pet's content.", }); } }