mirror of
https://gitlab.com/comunic/comunicapiv3
synced 2024-11-22 21:39:21 +00:00
Can check whether a conversation is having a call or not
This commit is contained in:
parent
74b74fe76b
commit
5194a389af
@ -4,6 +4,7 @@
|
||||
use serde::{Serialize, Serializer};
|
||||
|
||||
use crate::api_data::legacy_api_bool::LegacyBool;
|
||||
use crate::controllers::calls_controller;
|
||||
use crate::data::conversation::Conversation;
|
||||
use crate::helpers::calls_helper;
|
||||
|
||||
@ -51,8 +52,7 @@ impl ConversationAPI {
|
||||
|
||||
can_have_call: calls_helper::can_have_call(conv),
|
||||
can_have_video_call: calls_helper::can_have_video_calls(conv),
|
||||
// TODO : update when call system is implemented
|
||||
has_call_now: false,
|
||||
has_call_now: calls_controller::is_conversation_having_call(&conv.id),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -43,6 +43,25 @@ pub fn get_config(r: &mut UserWsRequestHandler) -> RequestResult {
|
||||
r.internal_error(ExecError::boxed_new("Missing calls configuration!"))
|
||||
}
|
||||
|
||||
/// Check out whether a conversation is having a call or not
|
||||
pub fn is_conversation_having_call(conv_id: &ConvID) -> bool {
|
||||
let mut found = false;
|
||||
|
||||
let res = user_ws_controller::foreach_connection(|f| {
|
||||
if found || f.is_having_call_with_conversation(conv_id) {
|
||||
found = true;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
});
|
||||
|
||||
if let Err(e) = res {
|
||||
eprintln!("Failed to check if a conversation is having call! Conversation: {} / Error: {:#?}", conv_id, e);
|
||||
}
|
||||
|
||||
found
|
||||
}
|
||||
|
||||
/// Join a call
|
||||
pub fn join_call(r: &mut UserWsRequestHandler) -> RequestResult {
|
||||
let conv_id = r.post_conv_id("convID")?;
|
||||
|
Loading…
Reference in New Issue
Block a user