mirror of
https://gitlab.com/comunic/comunicapiv2
synced 2024-12-26 13:38:52 +00:00
Can check if conversation is allowed to have a call or not
This commit is contained in:
parent
fcebb9efb6
commit
0944a99a71
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user