1
0
mirror of https://gitlab.com/comunic/comunicapiv3 synced 2025-07-10 01:22:48 +00:00

Check out whether a conversations can be used for calls or not

This commit is contained in:
2021-02-08 18:14:15 +01:00
parent a2b2fc89cf
commit 01b83dfa8f
4 changed files with 43 additions and 3 deletions

@ -0,0 +1,29 @@
//! # Calls helper
//!
//! @author Pierre Hubert
use crate::controllers::rtc_relay_controller;
use crate::data::config::conf;
use crate::data::conversation::Conversation;
/// Check out whether a conversation can make a call or not
pub fn can_have_call(conv: &Conversation) -> bool {
if let Some(conf) = &conf().rtc_relay {
return conv.members.len() > 1
&& conf.max_users_per_calls >= conv.members.len() as u64
&& rtc_relay_controller::is_connected();
}
false
}
/// Check out whether a conversation is allowed to make video calls or not
pub fn can_have_video_calls(conv: &Conversation) -> bool {
if let Some(conf) = &conf().rtc_relay {
return can_have_call(conv)
&& conf.allow_video
&& conf.max_users_per_video_calls >= conv.members.len() as u64;
}
false
}

@ -17,4 +17,5 @@ pub mod comments_helper;
pub mod notifications_helper;
pub mod webapp_helper;
pub mod requests_limit_helper;
pub mod events_helper;
pub mod events_helper;
pub mod calls_helper;