kaneo (minimalist kanban) fork to experiment adding a tangled integration github.com/usekaneo/kaneo
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

at 39e2dfae265f26c8d6d888a560f50ab2d5d58b3f 36 lines 915 B view raw
1import { eq } from "drizzle-orm"; 2import { HTTPException } from "hono/http-exception"; 3import db from "../../database"; 4import { commentTable } from "../../database/schema"; 5 6async function updateComment(userId: string, id: string, content: string) { 7 const [existing] = await db 8 .select({ userId: commentTable.userId }) 9 .from(commentTable) 10 .where(eq(commentTable.id, id)) 11 .limit(1); 12 13 if (!existing) { 14 throw new HTTPException(404, { message: "Comment not found" }); 15 } 16 17 if (existing.userId !== userId) { 18 throw new HTTPException(403, { 19 message: "Only the author can edit this comment", 20 }); 21 } 22 23 const [updated] = await db 24 .update(commentTable) 25 .set({ content }) 26 .where(eq(commentTable.id, id)) 27 .returning(); 28 29 if (!updated) { 30 throw new HTTPException(500, { message: "Failed to update comment" }); 31 } 32 33 return updated; 34} 35 36export default updateComment;