soft deleted page checks

This commit is contained in:
Philipinho
2026-02-10 17:17:24 -08:00
parent 7610e8458b
commit dacc26dea7
3 changed files with 23 additions and 6 deletions
@@ -54,7 +54,7 @@ export class AuthenticationExtension implements Extension {
const page = await this.pageRepo.findById(pageId); const page = await this.pageRepo.findById(pageId);
if (!page) { if (!page) {
this.logger.warn(`Page not found: ${pageId}`); this.logger.debug(`Page not found: ${pageId}`);
throw new NotFoundException('Page not found'); 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}`); this.logger.debug(`Authenticated user ${user.id} on page ${pageId}`);
return { return {
+8 -3
View File
@@ -80,7 +80,11 @@ export class PageController {
const parentPage = await this.pageRepo.findById( const parentPage = await this.pageRepo.findById(
createPageDto.parentPageId, createPageDto.parentPageId,
); );
if (!parentPage || parentPage.spaceId !== createPageDto.spaceId) { if (
!parentPage ||
parentPage.deletedAt ||
parentPage.spaceId !== createPageDto.spaceId
) {
throw new NotFoundException('Parent page not found'); throw new NotFoundException('Parent page not found');
} }
await this.pageAccessService.validateCanEdit(parentPage, user); 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 moving to a new parent, check permission on the target parent
if (dto.parentPageId && dto.parentPageId !== movedPage.parentPageId) { if (dto.parentPageId && dto.parentPageId !== movedPage.parentPageId) {
const targetParent = await this.pageRepo.findById(dto.parentPageId); const targetParent = await this.pageRepo.findById(dto.parentPageId);
if (targetParent) { if (!targetParent || targetParent.deletedAt) {
await this.pageAccessService.validateCanEdit(targetParent, user); throw new NotFoundException('Target parent page not found');
} }
await this.pageAccessService.validateCanEdit(targetParent, user);
} }
return this.pageService.movePage(dto, movedPage); return this.pageService.movePage(dto, movedPage);
@@ -83,7 +83,11 @@ export class PageService {
createPageDto.parentPageId, createPageDto.parentPageId,
); );
if (!parentPage || parentPage.spaceId !== createPageDto.spaceId) { if (
!parentPage ||
parentPage.deletedAt ||
parentPage.spaceId !== createPageDto.spaceId
) {
throw new NotFoundException('Parent page not found'); throw new NotFoundException('Parent page not found');
} }
@@ -600,7 +604,11 @@ export class PageService {
// changing the page's parent // changing the page's parent
if (dto.parentPageId) { if (dto.parentPageId) {
const parentPage = await this.pageRepo.findById(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'); throw new NotFoundException('Parent page not found');
} }
parentPageId = parentPage.id; parentPageId = parentPage.id;