|
@@ -20,6 +20,7 @@ import { V5ConversionErrCode } from '~/interfaces/errors/v5-conversion-error';
|
|
|
import {
|
|
import {
|
|
|
PageDeleteConfigValue, IPageDeleteConfigValueToProcessValidation,
|
|
PageDeleteConfigValue, IPageDeleteConfigValueToProcessValidation,
|
|
|
} from '~/interfaces/page-delete-config';
|
|
} from '~/interfaces/page-delete-config';
|
|
|
|
|
+import { PopulatedGrantedGroup } from '~/interfaces/page-grant';
|
|
|
import {
|
|
import {
|
|
|
IPageOperationProcessInfo, IPageOperationProcessData, PageActionStage, PageActionType,
|
|
IPageOperationProcessInfo, IPageOperationProcessData, PageActionStage, PageActionType,
|
|
|
} from '~/interfaces/page-operation';
|
|
} from '~/interfaces/page-operation';
|
|
@@ -2251,6 +2252,18 @@ class PageService {
|
|
|
await PageOperation.findByIdAndDelete(pageOpId);
|
|
await PageOperation.findByIdAndDelete(pageOpId);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /*
|
|
|
|
|
+ * get all groups of Page that user is related to
|
|
|
|
|
+ */
|
|
|
|
|
+ async getUserRelatedGrantedGroups(page: PageDocument, user): Promise<PopulatedGrantedGroup[]> {
|
|
|
|
|
+ const populatedPage = await page.populate<{grantedGroups: PopulatedGrantedGroup[] | null}>('grantedGroups.item');
|
|
|
|
|
+ const userRelatedGroupIds = [
|
|
|
|
|
+ ...(await UserGroupRelation.findAllGroupsForUser(user)).map(ugr => ugr._id.toString()),
|
|
|
|
|
+ ...(await ExternalUserGroupRelation.findAllGroupsForUser(user)).map(eugr => eugr._id.toString()),
|
|
|
|
|
+ ];
|
|
|
|
|
+ return populatedPage.grantedGroups?.filter(group => userRelatedGroupIds.includes(group.item._id.toString())) || [];
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
private async revertDeletedPageV4(page, user, options = {}, isRecursively = false) {
|
|
private async revertDeletedPageV4(page, user, options = {}, isRecursively = false) {
|
|
|
const Page = this.crowi.model('Page');
|
|
const Page = this.crowi.model('Page');
|
|
|
const PageTagRelation = this.crowi.model('PageTagRelation');
|
|
const PageTagRelation = this.crowi.model('PageTagRelation');
|
|
@@ -3342,15 +3355,6 @@ class PageService {
|
|
|
this.emitUpdateDescCount(updateDescCountData);
|
|
this.emitUpdateDescCount(updateDescCountData);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- async getUserRelatedGrantedGroups(page, user) {
|
|
|
|
|
- await page.populate('grantedGroups.item');
|
|
|
|
|
- const userRelatedGroupIds = [
|
|
|
|
|
- ...(await UserGroupRelation.findAllGroupsForUser(user)).map(ugr => ugr._id.toString()),
|
|
|
|
|
- ...(await ExternalUserGroupRelation.findAllGroupsForUser(user)).map(eugr => eugr._id.toString()),
|
|
|
|
|
- ];
|
|
|
|
|
- return page.grantedGroups.filter(group => userRelatedGroupIds.includes(group.item._id.toString()));
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
private emitUpdateDescCount(data: UpdateDescCountRawData): void {
|
|
private emitUpdateDescCount(data: UpdateDescCountRawData): void {
|
|
|
const socket = this.crowi.socketIoService.getDefaultSocket();
|
|
const socket = this.crowi.socketIoService.getDefaultSocket();
|
|
|
|
|
|