mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-19 15:26:59 +08:00
chore(server): ignore erorr when join joint room (#10354)
This commit is contained in:
@@ -11,7 +11,6 @@ import { ClsInterceptor } from 'nestjs-cls';
|
|||||||
import { Socket } from 'socket.io';
|
import { Socket } from 'socket.io';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
AlreadyInSpace,
|
|
||||||
CallMetric,
|
CallMetric,
|
||||||
DocNotFound,
|
DocNotFound,
|
||||||
GatewayErrorWrapper,
|
GatewayErrorWrapper,
|
||||||
@@ -617,13 +616,17 @@ abstract class SyncSocketAdapter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async join(userId: string, spaceId: string, roomType: RoomType = 'sync') {
|
async join(userId: string, spaceId: string, roomType: RoomType = 'sync') {
|
||||||
this.assertNotIn(spaceId, roomType);
|
if (this.in(spaceId, roomType)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
await this.assertAccessible(spaceId, userId, WorkspaceRole.Collaborator);
|
await this.assertAccessible(spaceId, userId, WorkspaceRole.Collaborator);
|
||||||
return this.client.join(this.room(spaceId, roomType));
|
return this.client.join(this.room(spaceId, roomType));
|
||||||
}
|
}
|
||||||
|
|
||||||
async leave(spaceId: string, roomType: RoomType = 'sync') {
|
async leave(spaceId: string, roomType: RoomType = 'sync') {
|
||||||
this.assertIn(spaceId, roomType);
|
if (!this.in(spaceId, roomType)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
return this.client.leave(this.room(spaceId, roomType));
|
return this.client.leave(this.room(spaceId, roomType));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -631,12 +634,6 @@ abstract class SyncSocketAdapter {
|
|||||||
return this.client.rooms.has(this.room(spaceId, roomType));
|
return this.client.rooms.has(this.room(spaceId, roomType));
|
||||||
}
|
}
|
||||||
|
|
||||||
assertNotIn(spaceId: string, roomType: RoomType = 'sync') {
|
|
||||||
if (this.client.rooms.has(this.room(spaceId, roomType))) {
|
|
||||||
throw new AlreadyInSpace({ spaceId });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
assertIn(spaceId: string, roomType: RoomType = 'sync') {
|
assertIn(spaceId: string, roomType: RoomType = 'sync') {
|
||||||
if (!this.client.rooms.has(this.room(spaceId, roomType))) {
|
if (!this.client.rooms.has(this.room(spaceId, roomType))) {
|
||||||
throw new NotInSpace({ spaceId });
|
throw new NotInSpace({ spaceId });
|
||||||
|
|||||||
Reference in New Issue
Block a user