mirror of
https://gitlab.com/comunic/comunicapiv2
synced 2024-11-22 05:19:22 +00:00
Check if a conversation can be the source for a call
This commit is contained in:
parent
d1235f4f8c
commit
0a778811af
@ -17,6 +17,8 @@
|
||||
"token": "SecretToken",
|
||||
"iceServers": [
|
||||
"stun:stun.l.google.com:19302"
|
||||
]
|
||||
],
|
||||
"maxUsersPerCalls": 3,
|
||||
"allowVideo": true
|
||||
}
|
||||
}
|
@ -5,6 +5,7 @@ import { UserHelper } from "../helpers/UserHelper";
|
||||
import { removeHTMLNodes } from "../utils/StringUtils";
|
||||
import { ConversationMessage } from "../entities/ConversationMessage";
|
||||
import { UnreadConversation } from "../entities/UnreadConversation";
|
||||
import { CallsHelper } from "../helpers/CallsHelper";
|
||||
|
||||
/**
|
||||
* Conversations controller
|
||||
@ -369,7 +370,8 @@ export class ConversationsController {
|
||||
name: c.name.length > 0 ? c.name : false,
|
||||
following: c.following ? 1 : 0,
|
||||
saw_last_message: c.sawLastMessage ? 1 : 0,
|
||||
members: [...c.members]
|
||||
members: [...c.members],
|
||||
can_have_call: CallsHelper.CanHaveCall(c)
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -73,6 +73,13 @@ export class RTCRelayController {
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* Check out wheter a relay is currently connected to the API
|
||||
*/
|
||||
public static get IsConnected() : boolean {
|
||||
return this.currWs && this.currWs.readyState == ws.OPEN;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method called when a websocket connection is closed
|
||||
*/
|
||||
|
24
src/helpers/CallsHelper.ts
Normal file
24
src/helpers/CallsHelper.ts
Normal file
@ -0,0 +1,24 @@
|
||||
/**
|
||||
* Calls helper
|
||||
*
|
||||
* @author Pierre Hubert
|
||||
*/
|
||||
|
||||
import { Conversation } from "../entities/Conversation";
|
||||
import { conf } from "./ConfigHelper";
|
||||
import { RTCRelayController } from "../controllers/RTCRelayController";
|
||||
|
||||
export class CallsHelper {
|
||||
|
||||
/**
|
||||
* Check out whether a given conversation can have a call or not
|
||||
*
|
||||
* @param conv Target conversation
|
||||
*/
|
||||
public static CanHaveCall(conv: Conversation) : boolean {
|
||||
return (conf().rtc_relay && RTCRelayController.IsConnected
|
||||
&& conv.members.size > 1
|
||||
&& conf().rtc_relay.maxUsersPerCalls >= conv.members.size) === true
|
||||
}
|
||||
|
||||
}
|
@ -18,7 +18,10 @@ export interface DatabaseConfiguration {
|
||||
export interface RTCRelayConfiguration {
|
||||
ip ?: string,
|
||||
token: string,
|
||||
iceServers: string[]
|
||||
iceServers: string[],
|
||||
|
||||
maxUsersPerCalls: number,
|
||||
allowVideo: boolean,
|
||||
}
|
||||
|
||||
export interface Configuration {
|
||||
|
Loading…
Reference in New Issue
Block a user