mirror of
https://github.com/docmost/docmost.git
synced 2026-05-15 05:04:06 +08:00
59e945562d
* 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
48 lines
1.3 KiB
TypeScript
48 lines
1.3 KiB
TypeScript
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: [],
|
|
},
|
|
},
|
|
});
|
|
}
|
|
}
|