fix: tighten sharing and shadcn composition
CI / checks (push) Successful in 12m55s
CI / build (push) Successful in 15m16s

This commit is contained in:
ginnoir
2026-06-13 05:20:01 -05:00
parent e1774c802d
commit a312d4ce39
42 changed files with 1539 additions and 417 deletions
+17 -3
View File
@@ -1,5 +1,6 @@
import { eq } from "drizzle-orm";
import { and, eq } from "drizzle-orm";
import { db } from "@/lib/db";
import type { PublicShareContext, ShareContext } from "@/modules/_core/module";
import { notes } from "../schema";
export type NoteShareData = {
@@ -10,7 +11,20 @@ export type NoteShareData = {
updatedAt: string;
};
export async function loadNoteForShare(id: string): Promise<NoteShareData | null> {
export async function canShareNote(id: string, ctx: ShareContext): Promise<boolean> {
const [note] = await db
.select({ id: notes.id })
.from(notes)
.where(and(eq(notes.id, id), eq(notes.householdId, ctx.householdId)))
.limit(1);
return !!note;
}
export async function loadNoteForShare(
id: string,
ctx: PublicShareContext,
): Promise<NoteShareData | null> {
const [note] = await db
.select({
id: notes.id,
@@ -20,7 +34,7 @@ export async function loadNoteForShare(id: string): Promise<NoteShareData | null
updatedAt: notes.updatedAt,
})
.from(notes)
.where(eq(notes.id, id))
.where(and(eq(notes.id, id), eq(notes.householdId, ctx.householdId)))
.limit(1);
if (!note) return null;