Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

fix(web): restrict comment deletion to the author's own replies

Richie McIlroy342c97863e15
diff --git a/apps/web/app/api/video/comment/delete/route.ts b/apps/web/app/api/video/comment/delete/route.ts
index 1e6a12db9..46f671827 100644
--- a/apps/web/app/api/video/comment/delete/route.ts
+++ b/apps/web/app/api/video/comment/delete/route.ts
@@ -41,13 +41,18 @@ export async function DELETE(request: NextRequest) {
);
}
- // Delete the comment and all its replies
+ // Delete the comment and only the replies authored by the same user.
+ // Replies written by other users are preserved (never delete others'
+ // content), even though that can leave them visually orphaned.
await db()
.delete(comments)
.where(
- or(
- eq(comments.id, commentId.value),
- eq(comments.parentCommentId, commentId.value),
+ and(
+ eq(comments.authorId, user.id),
+ or(
+ eq(comments.id, commentId.value),
+ eq(comments.parentCommentId, commentId.value),
+ ),
),
);