From ff28a38c884bd20ab921d21dd26baa6f03c5bff1 Mon Sep 17 00:00:00 2001 From: Philipinho <16838612+Philipinho@users.noreply.github.com> Date: Mon, 24 Aug 2026 20:19:43 +0100 Subject: [PATCH] fix: scope comment endpoints to workspace and skip trashed pages --- .../src/core/comment/comment.controller.ts | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/apps/server/src/core/comment/comment.controller.ts b/apps/server/src/core/comment/comment.controller.ts index 22458848b..132fc6e77 100644 --- a/apps/server/src/core/comment/comment.controller.ts +++ b/apps/server/src/core/comment/comment.controller.ts @@ -54,7 +54,7 @@ export class CommentController { @AuthWorkspace() workspace: Workspace, ) { const page = await this.pageRepo.findById(createCommentDto.pageId); - if (!page || page.deletedAt) { + if (!page || page.workspaceId !== workspace.id || page.deletedAt) { throw new NotFoundException('Page not found'); } @@ -89,9 +89,10 @@ export class CommentController { @Body() pagination: PaginationOptions, @AuthUser() user: User, + @AuthWorkspace() workspace: Workspace, ) { const page = await this.pageRepo.findById(input.pageId); - if (!page) { + if (!page || page.workspaceId !== workspace.id || page.deletedAt) { throw new NotFoundException('Page not found'); } @@ -102,14 +103,18 @@ export class CommentController { @HttpCode(HttpStatus.OK) @Post('info') - async findOne(@Body() input: CommentIdDto, @AuthUser() user: User) { + async findOne( + @Body() input: CommentIdDto, + @AuthUser() user: User, + @AuthWorkspace() workspace: Workspace, + ) { const comment = await this.commentRepo.findById(input.commentId); if (!comment) { throw new NotFoundException('Comment not found'); } const page = await this.pageRepo.findById(comment.pageId); - if (!page) { + if (!page || page.workspaceId !== workspace.id || page.deletedAt) { throw new NotFoundException('Page not found'); } @@ -130,7 +135,7 @@ export class CommentController { } const page = await this.pageRepo.findById(comment.pageId); - if (!page) { + if (!page || page.workspaceId !== workspace.id || page.deletedAt) { throw new NotFoundException('Page not found'); } @@ -148,7 +153,7 @@ export class CommentController { } const page = await this.pageRepo.findById(comment.pageId); - if (!page) { + if (!page || page.workspaceId !== workspace.id || page.deletedAt) { throw new NotFoundException('Page not found'); }