import { db, notifications } from "@epicure/db"; import { randomUUID } from "crypto"; type NotificationType = "follow" | "comment" | "reply" | "reaction" | "rating" | "mention"; export async function createNotification(opts: { userId: string; type: NotificationType; actorId: string; recipeId?: string; commentId?: string; }): Promise { if (opts.userId === opts.actorId) return; // never notify yourself await db.insert(notifications).values({ id: randomUUID(), userId: opts.userId, type: opts.type, actorId: opts.actorId, recipeId: opts.recipeId, commentId: opts.commentId, }); }