mirror of
https://github.com/docmost/docmost.git
synced 2026-08-30 10:26:25 +08:00
feat(ee): page-level access/permissions (#1971)
* Add page_hierarchy table * feat(ee): page-level permissions * pagination * rename migration fixes * fix * tabs * fix theme * cleanup * sync * page permissions notification * other fixes * sharing disbled * fix column nodes * toggle error handling
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { Page } from '@docmost/db/types/entity.types';
|
||||
import { WsService } from './ws.service';
|
||||
|
||||
@Injectable()
|
||||
export class WsTreeService {
|
||||
constructor(private readonly wsService: WsService) {}
|
||||
|
||||
async notifyPageRestricted(page: Page, excludeUserId: string): Promise<void> {
|
||||
await this.wsService.emitToSpaceExceptUsers(page.spaceId, [excludeUserId], {
|
||||
operation: 'deleteTreeNode',
|
||||
spaceId: page.spaceId,
|
||||
payload: {
|
||||
node: {
|
||||
id: page.id,
|
||||
slugId: page.slugId,
|
||||
},
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
async notifyPermissionGranted(page: Page, userIds: string[]): Promise<void> {
|
||||
if (userIds.length === 0) return;
|
||||
|
||||
await this.wsService.emitToUsers(userIds, {
|
||||
operation: 'addTreeNode',
|
||||
spaceId: page.spaceId,
|
||||
payload: {
|
||||
parentId: page.parentPageId ?? null,
|
||||
index: 0,
|
||||
data: {
|
||||
id: page.id,
|
||||
slugId: page.slugId,
|
||||
name: page.title ?? '',
|
||||
title: page.title,
|
||||
icon: page.icon,
|
||||
position: page.position,
|
||||
spaceId: page.spaceId,
|
||||
parentPageId: page.parentPageId,
|
||||
creatorId: page.creatorId,
|
||||
hasChildren: false,
|
||||
children: [],
|
||||
},
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user