Yuki Takei 1 год назад
Родитель
Сommit
8552cc03d1

+ 10 - 11
apps/app/src/pages/[[...path]].page.tsx

@@ -175,7 +175,6 @@ type Props = CommonProps & {
   isAclEnabled: boolean,
   // hasSlackConfig: boolean,
   drawioUri: string | null,
-  noCdn: string,
   // highlightJsStyle: string,
   isAllReplyShown: boolean,
   isContainerFluid: boolean,
@@ -233,7 +232,6 @@ const Page: NextPageWithLayout<Props> = (props: Props) => {
   // useIsMailerSetup(props.isMailerSetup);
   useIsAclEnabled(props.isAclEnabled);
   // useHasSlackConfig(props.hasSlackConfig);
-  // useNoCdn(props.noCdn);
   useDefaultIndentSize(props.adminPreferredIndentSize);
   useIsIndentSizeForced(props.isIndentSizeForced);
   useDisableLinkSharing(props.disableLinkSharing);
@@ -475,7 +473,7 @@ async function injectPageData(context: GetServerSidePropsContext, props: Props):
     }
   }
 
-  const pageWithMeta: IPageToShowRevisionWithMeta | null = await pageService.findPageAndMetaDataByViewer(pageId, currentPathname, user, true); // includeEmpty = true, isSharedPage = false
+  const pageWithMeta = await pageService.findPageAndMetaDataByViewer(pageId, currentPathname, user, true); // includeEmpty = true, isSharedPage = false
   const page = pageWithMeta?.data as unknown as PageDocument;
 
   // add user to seen users
@@ -484,15 +482,16 @@ async function injectPageData(context: GetServerSidePropsContext, props: Props):
   }
 
   // populate & check if the revision is latest
+  let populated;
   if (page != null) {
     page.initLatestRevisionField(revisionId);
     props.isLatestRevision = page.isLatestRevision();
     const ssrMaxRevisionBodyLength = configManager.getConfig('crowi', 'app:ssrMaxRevisionBodyLength');
     props.skipSSR = await skipSSR(page, ssrMaxRevisionBodyLength);
-    await page.populateDataToShowRevision(props.skipSSR); // shouldExcludeBody = skipSSR
+    populated = await page.populateDataToShowRevision(props.skipSSR); // shouldExcludeBody = skipSSR
   }
 
-  props.pageWithMeta = pageWithMeta;
+  props.pageWithMeta = populated;
 }
 
 async function injectRoutingInformation(context: GetServerSidePropsContext, props: Props): Promise<void> {
@@ -557,7 +556,8 @@ function injectServerConfigurations(context: GetServerSidePropsContext, props: P
   const req: CrowiRequest = context.req as CrowiRequest;
   const { crowi } = req;
   const {
-    configManager, searchService, aclService,
+    configManager, searchService, aclService, fileUploadService,
+    slackIntegrationService, passportService,
   } = crowi;
 
   props.aiEnabled = configManager.getConfig('crowi', 'app:aiEnabled');
@@ -569,21 +569,20 @@ function injectServerConfigurations(context: GetServerSidePropsContext, props: P
 
   props.isRomUserAllowedToComment = configManager.getConfig('crowi', 'security:isRomUserAllowedToComment');
 
-  props.isSlackConfigured = crowi.slackIntegrationService.isSlackConfigured;
+  props.isSlackConfigured = slackIntegrationService.isSlackConfigured;
   // props.isMailerSetup = mailService.isMailerSetup;
   props.isAclEnabled = aclService.isAclEnabled();
   // props.hasSlackConfig = slackNotificationService.hasSlackConfig();
   props.drawioUri = configManager.getConfig('crowi', 'app:drawioUri');
-  props.noCdn = configManager.getConfig('crowi', 'app:noCdn');
   // props.highlightJsStyle = configManager.getConfig('crowi', 'customize:highlightJsStyle');
   props.isAllReplyShown = configManager.getConfig('crowi', 'customize:isAllReplyShown');
   props.isContainerFluid = configManager.getConfig('crowi', 'customize:isContainerFluid');
   props.isEnabledStaleNotification = configManager.getConfig('crowi', 'customize:isEnabledStaleNotification');
   props.disableLinkSharing = configManager.getConfig('crowi', 'security:disableLinkSharing');
-  props.isUploadAllFileAllowed = crowi.fileUploadService.getFileUploadEnabled();
-  props.isUploadEnabled = crowi.fileUploadService.getIsUploadable();
+  props.isUploadAllFileAllowed = fileUploadService.getFileUploadEnabled();
+  props.isUploadEnabled = fileUploadService.getIsUploadable();
 
-  props.isLocalAccountRegistrationEnabled = crowi.passportService.isLocalStrategySetup
+  props.isLocalAccountRegistrationEnabled = passportService.isLocalStrategySetup
   && configManager.getConfig('crowi', 'security:registrationMode') !== RegistrationMode.CLOSED;
 
   props.adminPreferredIndentSize = configManager.getConfig('markdown', 'markdown:adminPreferredIndentSize');

+ 16 - 4
apps/app/src/server/crowi/index.js

@@ -62,21 +62,33 @@ class Crowi {
   /** @type {import('../service/config-manager').IConfigManagerForApp} */
   configManager;
 
+  /** @type {import('../service/acl').AclService} */
+  aclService;
+
   /** @type {AppService} */
   appService;
 
+  /** @type {FileUploader} */
+  fileUploadService;
+
   /** @type {import('../service/page').IPageService} */
   pageService;
 
-  /** @type UserNotificationService */
-  userNotificationService;
+  /** @type {PassportService} */
+  passportService;
 
-  /** @type {FileUploader} */
-  fileUploadService;
+  /** @type {SearchService} */
+  searchService;
+
+  /** @type {SlackIntegrationService} */
+  slackIntegrationService;
 
   /** @type {SocketIoService} */
   socketIoService;
 
+  /** @type UserNotificationService */
+  userNotificationService;
+
   constructor() {
     this.version = pkg.version;
 

+ 1 - 1
apps/app/src/server/service/config-manager/config-definition.ts

@@ -881,7 +881,7 @@ export const CONFIG_DEFINITIONS = {
   'markdown:rehypeSanitize:isEnabledPrevention': defineConfig<boolean>({
     defaultValue: true,
   }),
-  'markdown:rehypeSanitize:option': defineConfig<string>({
+  'markdown:rehypeSanitize:option': defineConfig<RehypeSanitizeType>({
     defaultValue: RehypeSanitizeType.RECOMMENDED,
   }),
   'markdown:rehypeSanitize:tagNames': defineConfig<string[]>({

+ 1 - 1
apps/app/src/server/service/page/index.ts

@@ -404,7 +404,7 @@ class PageService implements IPageService {
 
   // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
   async findPageAndMetaDataByViewer(
-      pageId: string, path: string, user: IUserHasId, includeEmpty = false, isSharedPage = false,
+      pageId: string | null, path: string, user?: HydratedDocument<IUser>, includeEmpty = false, isSharedPage = false,
   ): Promise<IDataWithMeta<HydratedDocument<PageDocument>, IPageInfoAll>|null> {
 
     const Page = mongoose.model<HydratedDocument<PageDocument>, PageModel>('Page');

+ 5 - 1
apps/app/src/server/service/page/page-service.ts

@@ -2,7 +2,8 @@ import type EventEmitter from 'events';
 
 import type {
   HasObjectId,
-  IPageInfo, IPageInfoForEntity, IUser,
+  IDataWithMeta,
+  IPageInfo, IPageInfoAll, IPageInfoForEntity, IUser,
 } from '@growi/core';
 import type { HydratedDocument, Types } from 'mongoose';
 
@@ -22,6 +23,9 @@ export interface IPageService {
   deleteCompletelyOperation: (pageIds: ObjectIdLike[], pagePaths: string[]) => Promise<void>,
   getEventEmitter: () => EventEmitter,
   deleteMultipleCompletely: (pages: ObjectIdLike[], user: IUser | undefined) => Promise<void>,
+  findPageAndMetaDataByViewer(
+      pageId: string | null, path: string, user?: HydratedDocument<IUser>, includeEmpty?: boolean, isSharedPage?: boolean,
+  ): Promise<IDataWithMeta<HydratedDocument<PageDocument>, IPageInfoAll>|null>
   findAncestorsChildrenByPathAndViewer(path: string, user, userGroups?): Promise<Record<string, PageDocument[]>>,
   findChildrenByParentPathOrIdAndViewer(
     parentPathOrId: string, user, userGroups?, showPagesRestrictedByOwner?: boolean, showPagesRestrictedByGroup?: boolean,