diff --git a/src/controllers/CallsController.ts b/src/controllers/CallsController.ts index c92d713..0e90de6 100644 --- a/src/controllers/CallsController.ts +++ b/src/controllers/CallsController.ts @@ -6,6 +6,8 @@ import * as ws from 'ws' import { WsMessage } from "../entities/WsMessage"; import { conf } from "../helpers/ConfigHelper"; import { RTCRelayController } from "./RTCRelayController"; +import { ConversationsHelper } from "../helpers/ConversationsHelper"; +import { CallsHelper } from "../helpers/CallsHelper"; /** * Legacy calls controller @@ -60,6 +62,11 @@ export class CallsController { public static async JoinCall(h: UserWebSocketRequestsHandler) { const convID = await h.postConversationId("convID"); + // Check if the conversation is authorized to have a call + const conv = await ConversationsHelper.GetSingle(convID, h.getUserId()); + if(!CallsHelper.CanHaveCall(conv)) + h.error(401, "This conversation is not allowed to have a call!"); + // If the user was active in any other calls, remove him for(const c of UserWebSocketController.active_clients.filter((f) => f.userID == h.getUserId() && f.activeCalls.has(convID))) await this.MakeUserLeaveCall(convID, c)