mirror of
https://gitlab.com/comunic/comunicapiv3
synced 2024-12-28 14:38:52 +00:00
Finish to implement conversation creation
This commit is contained in:
parent
435ba32653
commit
55566a85dc
@ -13,4 +13,5 @@ pub mod current_user_id;
|
||||
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_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))
|
||||
}
|
Loading…
Reference in New Issue
Block a user