1
0
mirror of https://gitlab.com/comunic/comunicapiv2 synced 2024-11-25 23:09:22 +00:00

Can check if conversation is allowed to have a call or not

This commit is contained in:
Pierre HUBERT 2020-04-15 07:55:59 +02:00
parent fcebb9efb6
commit 0944a99a71

View File

@ -6,6 +6,8 @@ import * as ws from 'ws'
import { WsMessage } from "../entities/WsMessage"; import { WsMessage } from "../entities/WsMessage";
import { conf } from "../helpers/ConfigHelper"; import { conf } from "../helpers/ConfigHelper";
import { RTCRelayController } from "./RTCRelayController"; import { RTCRelayController } from "./RTCRelayController";
import { ConversationsHelper } from "../helpers/ConversationsHelper";
import { CallsHelper } from "../helpers/CallsHelper";
/** /**
* Legacy calls controller * Legacy calls controller
@ -60,6 +62,11 @@ export class CallsController {
public static async JoinCall(h: UserWebSocketRequestsHandler) { public static async JoinCall(h: UserWebSocketRequestsHandler) {
const convID = await h.postConversationId("convID"); 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 // 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))) for(const c of UserWebSocketController.active_clients.filter((f) => f.userID == h.getUserId() && f.activeCalls.has(convID)))
await this.MakeUserLeaveCall(convID, c) await this.MakeUserLeaveCall(convID, c)