Skip to content

armgit / kaneo

Public Imported from GitHub
0

⚡ Project management that doesn't become the project. Boards, Gantt charts, and GitHub integration. Self-host it or use Kaneo Cloud.

fix(api): restore atomic ownership check on activity comment writes

Andrej12e9b942a1e7
diff --git a/apps/api/src/activity/controllers/delete-comment.ts b/apps/api/src/activity/controllers/delete-comment.ts
index 9c73c610d..f7d06c740 100644
--- a/apps/api/src/activity/controllers/delete-comment.ts
+++ b/apps/api/src/activity/controllers/delete-comment.ts
@@ -24,7 +24,7 @@ async function deleteComment(userId: string, id: string) {
const [deletedComment] = await db
.delete(activityTable)
- .where(eq(activityTable.id, id))
+ .where(and(eq(activityTable.id, id), eq(activityTable.userId, userId)))
.returning();
if (!deletedComment) {
diff --git a/apps/api/src/activity/controllers/update-comment.ts b/apps/api/src/activity/controllers/update-comment.ts
index b09d96a63..179e60985 100644
--- a/apps/api/src/activity/controllers/update-comment.ts
+++ b/apps/api/src/activity/controllers/update-comment.ts
@@ -25,7 +25,7 @@ async function updateComment(userId: string, id: string, content: string) {
const [updated] = await db
.update(activityTable)
.set({ content })
- .where(eq(activityTable.id, id))
+ .where(and(eq(activityTable.id, id), eq(activityTable.userId, userId)))
.returning();
if (!updated) {