From dacc26dea7b4838a0a601ead4d0f521c6b52563e Mon Sep 17 00:00:00 2001 From: Philipinho <16838612+Philipinho@users.noreply.github.com> Date: Tue, 10 Feb 2026 17:17:24 -0800 Subject: [PATCH] soft deleted page checks --- .../extensions/authentication.extension.ts | 6 +++++- apps/server/src/core/page/page.controller.ts | 11 ++++++++--- apps/server/src/core/page/services/page.service.ts | 12 ++++++++++-- 3 files changed, 23 insertions(+), 6 deletions(-) diff --git a/apps/server/src/collaboration/extensions/authentication.extension.ts b/apps/server/src/collaboration/extensions/authentication.extension.ts index da8b5562..ab12ed77 100644 --- a/apps/server/src/collaboration/extensions/authentication.extension.ts +++ b/apps/server/src/collaboration/extensions/authentication.extension.ts @@ -54,7 +54,7 @@ export class AuthenticationExtension implements Extension { const page = await this.pageRepo.findById(pageId); if (!page) { - this.logger.warn(`Page not found: ${pageId}`); + this.logger.debug(`Page not found: ${pageId}`); throw new NotFoundException('Page not found'); } @@ -96,6 +96,10 @@ export class AuthenticationExtension implements Extension { } } + if (page.deletedAt) { + data.connectionConfig.readOnly = true; + } + this.logger.debug(`Authenticated user ${user.id} on page ${pageId}`); return { diff --git a/apps/server/src/core/page/page.controller.ts b/apps/server/src/core/page/page.controller.ts index 479f0579..020e0fa3 100644 --- a/apps/server/src/core/page/page.controller.ts +++ b/apps/server/src/core/page/page.controller.ts @@ -80,7 +80,11 @@ export class PageController { const parentPage = await this.pageRepo.findById( createPageDto.parentPageId, ); - if (!parentPage || parentPage.spaceId !== createPageDto.spaceId) { + if ( + !parentPage || + parentPage.deletedAt || + parentPage.spaceId !== createPageDto.spaceId + ) { throw new NotFoundException('Parent page not found'); } await this.pageAccessService.validateCanEdit(parentPage, user); @@ -411,9 +415,10 @@ export class PageController { // If moving to a new parent, check permission on the target parent if (dto.parentPageId && dto.parentPageId !== movedPage.parentPageId) { const targetParent = await this.pageRepo.findById(dto.parentPageId); - if (targetParent) { - await this.pageAccessService.validateCanEdit(targetParent, user); + if (!targetParent || targetParent.deletedAt) { + throw new NotFoundException('Target parent page not found'); } + await this.pageAccessService.validateCanEdit(targetParent, user); } return this.pageService.movePage(dto, movedPage); diff --git a/apps/server/src/core/page/services/page.service.ts b/apps/server/src/core/page/services/page.service.ts index af08e26e..85e3ae7f 100644 --- a/apps/server/src/core/page/services/page.service.ts +++ b/apps/server/src/core/page/services/page.service.ts @@ -83,7 +83,11 @@ export class PageService { createPageDto.parentPageId, ); - if (!parentPage || parentPage.spaceId !== createPageDto.spaceId) { + if ( + !parentPage || + parentPage.deletedAt || + parentPage.spaceId !== createPageDto.spaceId + ) { throw new NotFoundException('Parent page not found'); } @@ -600,7 +604,11 @@ export class PageService { // changing the page's parent if (dto.parentPageId) { const parentPage = await this.pageRepo.findById(dto.parentPageId); - if (!parentPage || parentPage.spaceId !== movedPage.spaceId) { + if ( + !parentPage || + parentPage.deletedAt || + parentPage.spaceId !== movedPage.spaceId + ) { throw new NotFoundException('Parent page not found'); } parentPageId = parentPage.id;