mirror of
				https://gitlab.com/comunic/comunicapiv3
				synced 2025-11-03 17:14:03 +00:00 
			
		
		
		
	Finish to implement conversation creation
This commit is contained in:
		@@ -14,3 +14,4 @@ pub mod user_info;
 | 
			
		||||
pub mod custom_emoji;
 | 
			
		||||
pub mod res_find_user_by_virtual_directory;
 | 
			
		||||
pub mod res_find_virtual_directory;
 | 
			
		||||
pub mod res_create_conversation;
 | 
			
		||||
							
								
								
									
										22
									
								
								src/api_data/res_create_conversation.rs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										22
									
								
								src/api_data/res_create_conversation.rs
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,22 @@
 | 
			
		||||
//! # Create conversation result
 | 
			
		||||
//!
 | 
			
		||||
//! @author Pierre Hubert
 | 
			
		||||
 | 
			
		||||
use serde::{Serialize};
 | 
			
		||||
 | 
			
		||||
#[derive(Serialize)]
 | 
			
		||||
#[allow(non_snake_case)]
 | 
			
		||||
pub struct ResCreateConversation {
 | 
			
		||||
    conversationID: u64,
 | 
			
		||||
    success: String,
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
impl ResCreateConversation {
 | 
			
		||||
    /// Construct a new Result instance
 | 
			
		||||
    pub fn new(conv_id: u64) -> ResCreateConversation {
 | 
			
		||||
        ResCreateConversation {
 | 
			
		||||
            conversationID: conv_id,
 | 
			
		||||
            success: "The conversation was successfully created!".to_string(),
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -6,6 +6,7 @@ use crate::data::http_request_handler::HttpRequestHandler;
 | 
			
		||||
use crate::controllers::routes::RequestResult;
 | 
			
		||||
use crate::helpers::{user_helper, conversations_helper};
 | 
			
		||||
use crate::data::new_conversation::NewConversation;
 | 
			
		||||
use crate::api_data::res_create_conversation::ResCreateConversation;
 | 
			
		||||
 | 
			
		||||
/// Create a new conversation
 | 
			
		||||
pub fn create(r: &mut HttpRequestHandler) -> RequestResult {
 | 
			
		||||
@@ -36,13 +37,10 @@ pub fn create(r: &mut HttpRequestHandler) -> RequestResult {
 | 
			
		||||
        name,
 | 
			
		||||
        owner_following: r.post_bool("follow")?,
 | 
			
		||||
        members,
 | 
			
		||||
        can_everyone_add_members: r.post_bool_opt("canEveryoneAddMembers", true)
 | 
			
		||||
        can_everyone_add_members: r.post_bool_opt("canEveryoneAddMembers", true),
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    // TODO : adapt for API
 | 
			
		||||
    println!("Conversation to create: {:#?}", conv);
 | 
			
		||||
    // Create the conversation
 | 
			
		||||
    let conv_id = conversations_helper::create(&conv)?;
 | 
			
		||||
    println!("conv: {}", conv_id);
 | 
			
		||||
    r.success("create")
 | 
			
		||||
    r.set_response(ResCreateConversation::new(conv_id))
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user