Compare commits

...

3 Commits

Author SHA1 Message Date
Philipinho 1615e0f4ad v0.22.2 2025-08-01 16:15:02 -07:00
Philip Okugbe 1cb2535de3 fix trash in search (#1439)
- delete share if page is trashed
2025-08-02 00:14:00 +01:00
Philipinho 83bc273cb0 cleanup 2025-08-01 07:05:25 -07:00
8 changed files with 31 additions and 22 deletions
+1 -1
View File
@@ -1,7 +1,7 @@
{ {
"name": "client", "name": "client",
"private": true, "private": true,
"version": "0.22.1", "version": "0.22.2",
"scripts": { "scripts": {
"dev": "vite", "dev": "vite",
"build": "tsc && vite build", "build": "tsc && vite build",
@@ -47,10 +47,6 @@ function CommentListWithTabs() {
SpaceCaslSubject.Page SpaceCaslSubject.Page
); );
console.log(spaceAbility)
console.log('can comment', canComment);
// Separate active and resolved comments // Separate active and resolved comments
const { activeComments, resolvedComments } = useMemo(() => { const { activeComments, resolvedComments } = useMemo(() => {
if (!comments?.items) { if (!comments?.items) {
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "server", "name": "server",
"version": "0.22.1", "version": "0.22.2",
"description": "", "description": "",
"author": "", "author": "",
"private": true, "private": true,
@@ -43,7 +43,7 @@ export class CommentController {
@AuthWorkspace() workspace: Workspace, @AuthWorkspace() workspace: Workspace,
) { ) {
const page = await this.pageRepo.findById(createCommentDto.pageId); const page = await this.pageRepo.findById(createCommentDto.pageId);
if (!page) { if (!page || page.deletedAt) {
throw new NotFoundException('Page not found'); throw new NotFoundException('Page not found');
} }
@@ -90,7 +90,10 @@ export class CommentController {
throw new NotFoundException('Comment not found'); throw new NotFoundException('Comment not found');
} }
const ability = await this.spaceAbility.createForUser(user, comment.spaceId); const ability = await this.spaceAbility.createForUser(
user,
comment.spaceId,
);
if (ability.cannot(SpaceCaslAction.Read, SpaceCaslSubject.Page)) { if (ability.cannot(SpaceCaslAction.Read, SpaceCaslSubject.Page)) {
throw new ForbiddenException(); throw new ForbiddenException();
} }
@@ -59,6 +59,7 @@ export class SearchService {
.$if(Boolean(searchParams.creatorId), (qb) => .$if(Boolean(searchParams.creatorId), (qb) =>
qb.where('creatorId', '=', searchParams.creatorId), qb.where('creatorId', '=', searchParams.creatorId),
) )
.where('deletedAt', 'is', null)
.orderBy('rank', 'desc') .orderBy('rank', 'desc')
.limit(searchParams.limit | 20) .limit(searchParams.limit | 20)
.offset(searchParams.offset || 0); .offset(searchParams.offset || 0);
@@ -191,6 +192,7 @@ export class SearchService {
sql`LOWER(f_unaccent(${`%${query}%`}))`, sql`LOWER(f_unaccent(${`%${query}%`}))`,
), ),
) )
.where('deletedAt', 'is', null)
.where('workspaceId', '=', workspaceId) .where('workspaceId', '=', workspaceId)
.limit(limit); .limit(limit);
+6 -4
View File
@@ -108,12 +108,12 @@ export class ShareService {
includeCreator: true, includeCreator: true,
}); });
page.content = await this.updatePublicAttachments(page); if (!page || page.deletedAt) {
if (!page) {
throw new NotFoundException('Shared page not found'); throw new NotFoundException('Shared page not found');
} }
page.content = await this.updatePublicAttachments(page);
return { page, share }; return { page, share };
} }
@@ -132,6 +132,7 @@ export class ShareService {
sql`0`.as('level'), sql`0`.as('level'),
]) ])
.where(isValidUUID(pageId) ? 'id' : 'slugId', '=', pageId) .where(isValidUUID(pageId) ? 'id' : 'slugId', '=', pageId)
.where('deletedAt', 'is', null)
.unionAll((union) => .unionAll((union) =>
union union
.selectFrom('pages as p') .selectFrom('pages as p')
@@ -144,7 +145,8 @@ export class ShareService {
// Increase the level by 1 for each ancestor. // Increase the level by 1 for each ancestor.
sql`ph.level + 1`.as('level'), sql`ph.level + 1`.as('level'),
]) ])
.innerJoin('page_hierarchy as ph', 'ph.parentPageId', 'p.id'), .innerJoin('page_hierarchy as ph', 'ph.parentPageId', 'p.id')
.where('p.deletedAt', 'is', null),
), ),
) )
.selectFrom('page_hierarchy') .selectFrom('page_hierarchy')
@@ -1,7 +1,7 @@
import { Injectable } from '@nestjs/common'; import { Injectable } from '@nestjs/common';
import { InjectKysely } from 'nestjs-kysely'; import { InjectKysely } from 'nestjs-kysely';
import { KyselyDB, KyselyTransaction } from '../../types/kysely.types'; import { KyselyDB, KyselyTransaction } from '../../types/kysely.types';
import { dbOrTx } from '../../utils'; import { dbOrTx, executeTx } from '../../utils';
import { import {
InsertablePage, InsertablePage,
Page, Page,
@@ -183,14 +183,20 @@ export class PageRepo {
const pageIds = descendants.map((d) => d.id); const pageIds = descendants.map((d) => d.id);
await this.db if (pageIds.length > 0) {
.updateTable('pages') await executeTx(this.db, async (trx) => {
.set({ await trx
deletedById: deletedById, .updateTable('pages')
deletedAt: currentDate, .set({
}) deletedById: deletedById,
.where('id', 'in', pageIds) deletedAt: currentDate,
.execute(); })
.where('id', 'in', pageIds)
.execute();
await trx.deleteFrom('shares').where('pageId', 'in', pageIds).execute();
});
}
} }
async restorePage(pageId: string): Promise<void> { async restorePage(pageId: string): Promise<void> {
+1 -1
View File
@@ -1,7 +1,7 @@
{ {
"name": "docmost", "name": "docmost",
"homepage": "https://docmost.com", "homepage": "https://docmost.com",
"version": "0.22.1", "version": "0.22.2",
"private": true, "private": true,
"scripts": { "scripts": {
"build": "nx run-many -t build", "build": "nx run-many -t build",