mirror of
				https://gitlab.com/comunic/comunicapiv3
				synced 2025-11-04 01:24:04 +00:00 
			
		
		
		
	Check out whether a conversations can be used for calls or not
This commit is contained in:
		
							
								
								
									
										29
									
								
								src/helpers/calls_helper.rs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										29
									
								
								src/helpers/calls_helper.rs
									
									
									
									
									
										Normal file
									
								
							@@ -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;
 | 
			
		||||
		Reference in New Issue
	
	Block a user