Skip to content

There can be more than Notion and Miro. AFFiNE(pronounced [ə‘fain]) is a next-gen knowledge base that brings planning, sorting and creating all together. Privacy first, open-source, customizable and ready to use.

chore(server): ignore erorr when join joint room (#10354)

liuyi7d68aa5b2ff5
diff --git a/packages/backend/server/src/core/sync/gateway.ts b/packages/backend/server/src/core/sync/gateway.ts
index a9a4a1e0e4..ade38a6a8e 100644
--- a/packages/backend/server/src/core/sync/gateway.ts
+++ b/packages/backend/server/src/core/sync/gateway.ts
@@ -11,7 +11,6 @@ import { ClsInterceptor } from 'nestjs-cls';
import { Socket } from 'socket.io';
import {
- AlreadyInSpace,
CallMetric,
DocNotFound,
GatewayErrorWrapper,
@@ -617,13 +616,17 @@ abstract class SyncSocketAdapter {
}
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);
return this.client.join(this.room(spaceId, roomType));
}
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));
}
@@ -631,12 +634,6 @@ abstract class SyncSocketAdapter {
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') {
if (!this.client.rooms.has(this.room(spaceId, roomType))) {
throw new NotInSpace({ spaceId });