|
@@ -1,15 +1,16 @@
|
|
|
import type { IPage } from '@growi/core';
|
|
import type { IPage } from '@growi/core';
|
|
|
|
|
+import { serializeUserSecurely } from '@growi/core/dist/models/serializers';
|
|
|
import mongoose from 'mongoose';
|
|
import mongoose from 'mongoose';
|
|
|
|
|
|
|
|
import { SearchDelegatorName } from '~/interfaces/named-query';
|
|
import { SearchDelegatorName } from '~/interfaces/named-query';
|
|
|
-import { ISearchResult } from '~/interfaces/search';
|
|
|
|
|
-import { PageModel, PageDocument, PageQueryBuilder } from '~/server/models/page';
|
|
|
|
|
|
|
+import type { ISearchResult } from '~/interfaces/search';
|
|
|
|
|
+import type { PageModel, PageDocument, PageQueryBuilder } from '~/server/models/page';
|
|
|
|
|
+import { serializePageSecurely } from '~/server/models/serializers';
|
|
|
|
|
|
|
|
-import {
|
|
|
|
|
|
|
+import type {
|
|
|
QueryTerms, MongoTermsKey,
|
|
QueryTerms, MongoTermsKey,
|
|
|
SearchableData, SearchDelegator, UnavailableTermsKey, MongoQueryTerms,
|
|
SearchableData, SearchDelegator, UnavailableTermsKey, MongoQueryTerms,
|
|
|
} from '../../interfaces/search';
|
|
} from '../../interfaces/search';
|
|
|
-import { serializeUserSecurely } from '../../models/serializers/user-serializer';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const AVAILABLE_KEYS = ['match', 'not_match', 'prefix', 'not_prefix'];
|
|
const AVAILABLE_KEYS = ['match', 'not_match', 'prefix', 'not_prefix'];
|
|
@@ -47,21 +48,15 @@ class PrivateLegacyPagesDelegator implements SearchDelegator<IPage, MongoTermsKe
|
|
|
|
|
|
|
|
const total = await countQueryBuilder.query.count();
|
|
const total = await countQueryBuilder.query.count();
|
|
|
|
|
|
|
|
- const _pages: PageDocument[] = await findQueryBuilder
|
|
|
|
|
|
|
+ const pages: PageDocument[] = await findQueryBuilder
|
|
|
.addConditionToPagenate(offset, limit)
|
|
.addConditionToPagenate(offset, limit)
|
|
|
.query
|
|
.query
|
|
|
.populate('creator')
|
|
.populate('creator')
|
|
|
.populate('lastUpdateUser')
|
|
.populate('lastUpdateUser')
|
|
|
.exec();
|
|
.exec();
|
|
|
|
|
|
|
|
- const pages = _pages.map((page) => {
|
|
|
|
|
- page.creator = serializeUserSecurely(page.creator);
|
|
|
|
|
- page.lastUpdateUser = serializeUserSecurely(page.lastUpdateUser);
|
|
|
|
|
- return page;
|
|
|
|
|
- });
|
|
|
|
|
-
|
|
|
|
|
return {
|
|
return {
|
|
|
- data: pages,
|
|
|
|
|
|
|
+ data: pages.map(page => serializePageSecurely(page)),
|
|
|
meta: {
|
|
meta: {
|
|
|
total,
|
|
total,
|
|
|
hitsCount: pages.length,
|
|
hitsCount: pages.length,
|