mirror of
https://github.com/docmost/docmost.git
synced 2026-05-20 00:14:10 +08:00
clean up ws
This commit is contained in:
@@ -65,12 +65,10 @@ export class WsGateway
|
|||||||
async handleMessage(client: Socket, data: any): Promise<void> {
|
async handleMessage(client: Socket, data: any): Promise<void> {
|
||||||
if (this.wsService.isTreeEvent(data)) {
|
if (this.wsService.isTreeEvent(data)) {
|
||||||
await this.wsService.handleTreeEvent(client, data);
|
await this.wsService.handleTreeEvent(client, data);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
client.broadcast.emit('message', data);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
@SubscribeMessage('join-room')
|
@SubscribeMessage('join-room')
|
||||||
handleJoinRoom(client: Socket, @MessageBody() roomName: string): void {
|
handleJoinRoom(client: Socket, @MessageBody() roomName: string): void {
|
||||||
// if room is a space, check if user has permissions
|
// if room is a space, check if user has permissions
|
||||||
@@ -81,6 +79,7 @@ export class WsGateway
|
|||||||
handleLeaveRoom(client: Socket, @MessageBody() roomName: string): void {
|
handleLeaveRoom(client: Socket, @MessageBody() roomName: string): void {
|
||||||
client.leave(roomName);
|
client.leave(roomName);
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
onModuleDestroy() {
|
onModuleDestroy() {
|
||||||
if (this.server) {
|
if (this.server) {
|
||||||
|
|||||||
@@ -27,6 +27,15 @@ export class WsService {
|
|||||||
async handleTreeEvent(client: Socket, data: any): Promise<void> {
|
async handleTreeEvent(client: Socket, data: any): Promise<void> {
|
||||||
const room = getSpaceRoomName(data.spaceId);
|
const room = getSpaceRoomName(data.spaceId);
|
||||||
|
|
||||||
|
if (!client.rooms.has(room)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (data.operation === 'refetchRootTreeNodeEvent') {
|
||||||
|
client.broadcast.to(room).emit('message', data);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const hasRestrictions = await this.spaceHasRestrictions(data.spaceId);
|
const hasRestrictions = await this.spaceHasRestrictions(data.spaceId);
|
||||||
if (!hasRestrictions) {
|
if (!hasRestrictions) {
|
||||||
client.broadcast.to(room).emit('message', data);
|
client.broadcast.to(room).emit('message', data);
|
||||||
|
|||||||
@@ -14,4 +14,5 @@ export const TREE_EVENTS = new Set([
|
|||||||
'addTreeNode',
|
'addTreeNode',
|
||||||
'moveTreeNode',
|
'moveTreeNode',
|
||||||
'deleteTreeNode',
|
'deleteTreeNode',
|
||||||
|
'refetchRootTreeNodeEvent',
|
||||||
]);
|
]);
|
||||||
|
|||||||
Reference in New Issue
Block a user