Rate-limiting on messages.send, reports.create, reactions.toggle, follows.create, reposts.create. Unique constraints on Report to stop report-flooding. Mux webhook now fails hard in production without a signing secret instead of skipping verification. Admin-panel outline buttons fixed on 4 more pages (same white-on-dark bug as the Users page). Timing-safe comparison for ADMIN_SECRET/CRON_SECRET. Fixed duplicate HSTS header (Cloudflare's stronger one was being shadowed by the app's own). tRPC now returns clean JSON 401s instead of HTML redirects when unauthenticated, and no longer blocks public procedures for logged-out visitors. 14 previously-silent catch blocks now log to GlitchTip. invite/page.tsx and EmergencyVetSection.tsx fully localized (were 100% hardcoded German). Stale TODO comments removed, auth.test.ts scaffold rewritten to match the actual lazy-upsert pattern instead of a Clerk webhook flow that was never built.
23 lines
835 B
TypeScript
23 lines
835 B
TypeScript
import "server-only";
|
|
import type { PrismaClient, NotificationType } from "@prisma/client";
|
|
|
|
interface NotifyParams {
|
|
recipientPetId: string;
|
|
type: NotificationType;
|
|
actorPetId?: string;
|
|
postId?: string;
|
|
commentId?: string;
|
|
}
|
|
|
|
/**
|
|
* Fire-and-forget notification create — never blocks or fails the caller.
|
|
* Use for user-triggered notifications (follow, reaction, comment, repost,
|
|
* message, mention) where a notification failure must not fail the
|
|
* underlying action. For notifications that must be awaited (e.g. batch
|
|
* cron jobs that track a created-count), call prisma.notification.create
|
|
* directly instead.
|
|
*/
|
|
export function notify(prisma: Pick<PrismaClient, "notification">, params: NotifyParams): void {
|
|
prisma.notification.create({ data: params }).catch((err) => console.error("[notify] failed", err));
|
|
}
|