|
|
@@ -23,10 +23,11 @@ import { Ref } from '~/interfaces/common';
|
|
|
import { HasObjectId } from '~/interfaces/has-object-id';
|
|
|
import { SocketEventName, UpdateDescCountRawData } from '~/interfaces/websocket';
|
|
|
import {
|
|
|
- PageDeleteConfigValue, PageDeleteConfigValueToProcessValidation,
|
|
|
+ PageDeleteConfigValue, IPageDeleteConfigValueToProcessValidation,
|
|
|
} from '~/interfaces/page-delete-config';
|
|
|
import PageOperation, { PageActionStage, PageActionType } from '../models/page-operation';
|
|
|
import ActivityDefine from '../util/activityDefine';
|
|
|
+import { calcRecursiveDeleteConfigValue } from '~/utils/page-delete-config';
|
|
|
|
|
|
const debug = require('debug')('growi:services:page');
|
|
|
|
|
|
@@ -215,7 +216,7 @@ class PageService {
|
|
|
const pageCompleteDeletionAuthority = this.crowi.configManager.getConfig('crowi', 'security:pageCompleteDeletionAuthority');
|
|
|
const pageRecursiveCompleteDeletionAuthority = this.crowi.configManager.getConfig('crowi', 'security:pageRecursiveCompleteDeletionAuthority');
|
|
|
|
|
|
- const recursiveAuthority = this.calcRecursiveDeleteConfigValue(pageCompleteDeletionAuthority, pageRecursiveCompleteDeletionAuthority);
|
|
|
+ const recursiveAuthority = calcRecursiveDeleteConfigValue(pageCompleteDeletionAuthority, pageRecursiveCompleteDeletionAuthority);
|
|
|
|
|
|
return this.canDeleteLogic(creatorId, operator, isRecursively, pageCompleteDeletionAuthority, recursiveAuthority);
|
|
|
}
|
|
|
@@ -224,25 +225,17 @@ class PageService {
|
|
|
const pageDeletionAuthority = this.crowi.configManager.getConfig('crowi', 'security:pageDeletionAuthority');
|
|
|
const pageRecursiveDeletionAuthority = this.crowi.configManager.getConfig('crowi', 'security:pageRecursiveDeletionAuthority');
|
|
|
|
|
|
- const recursiveAuthority = this.calcRecursiveDeleteConfigValue(pageDeletionAuthority, pageRecursiveDeletionAuthority);
|
|
|
+ const recursiveAuthority = calcRecursiveDeleteConfigValue(pageDeletionAuthority, pageRecursiveDeletionAuthority);
|
|
|
|
|
|
return this.canDeleteLogic(creatorId, operator, isRecursively, pageDeletionAuthority, recursiveAuthority);
|
|
|
}
|
|
|
|
|
|
- private calcRecursiveDeleteConfigValue(confForSingle, confForRecursive) {
|
|
|
- if (confForRecursive === PageDeleteConfigValue.Inherit) {
|
|
|
- return confForSingle;
|
|
|
- }
|
|
|
-
|
|
|
- return confForRecursive;
|
|
|
- }
|
|
|
-
|
|
|
private canDeleteLogic(
|
|
|
creatorId: ObjectIdLike,
|
|
|
operator,
|
|
|
isRecursively: boolean,
|
|
|
- authority: PageDeleteConfigValueToProcessValidation | null,
|
|
|
- recursiveAuthority: PageDeleteConfigValueToProcessValidation | null,
|
|
|
+ authority: IPageDeleteConfigValueToProcessValidation | null,
|
|
|
+ recursiveAuthority: IPageDeleteConfigValueToProcessValidation | null,
|
|
|
): boolean {
|
|
|
const isAdmin = operator.admin;
|
|
|
const isOperator = operator?._id == null ? false : operator._id.equals(creatorId);
|
|
|
@@ -254,7 +247,7 @@ class PageService {
|
|
|
return this.compareDeleteConfig(isAdmin, isOperator, authority);
|
|
|
}
|
|
|
|
|
|
- private compareDeleteConfig(isAdmin: boolean, isOperator: boolean, authority: PageDeleteConfigValueToProcessValidation | null): boolean {
|
|
|
+ private compareDeleteConfig(isAdmin: boolean, isOperator: boolean, authority: IPageDeleteConfigValueToProcessValidation | null): boolean {
|
|
|
if (isAdmin) {
|
|
|
return true;
|
|
|
}
|