mirror of
https://gitlab.com/comunic/comunicapiv3
synced 2024-12-29 06:58:50 +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 user_info;
|
||||||
pub mod custom_emoji;
|
pub mod custom_emoji;
|
||||||
pub mod res_find_user_by_virtual_directory;
|
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::controllers::routes::RequestResult;
|
||||||
use crate::helpers::{user_helper, conversations_helper};
|
use crate::helpers::{user_helper, conversations_helper};
|
||||||
use crate::data::new_conversation::NewConversation;
|
use crate::data::new_conversation::NewConversation;
|
||||||
|
use crate::api_data::res_create_conversation::ResCreateConversation;
|
||||||
|
|
||||||
/// Create a new conversation
|
/// Create a new conversation
|
||||||
pub fn create(r: &mut HttpRequestHandler) -> RequestResult {
|
pub fn create(r: &mut HttpRequestHandler) -> RequestResult {
|
||||||
@ -36,13 +37,10 @@ pub fn create(r: &mut HttpRequestHandler) -> RequestResult {
|
|||||||
name,
|
name,
|
||||||
owner_following: r.post_bool("follow")?,
|
owner_following: r.post_bool("follow")?,
|
||||||
members,
|
members,
|
||||||
can_everyone_add_members: r.post_bool_opt("canEveryoneAddMembers", true)
|
can_everyone_add_members: r.post_bool_opt("canEveryoneAddMembers", true),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Create the conversation
|
||||||
// TODO : adapt for API
|
|
||||||
println!("Conversation to create: {:#?}", conv);
|
|
||||||
let conv_id = conversations_helper::create(&conv)?;
|
let conv_id = conversations_helper::create(&conv)?;
|
||||||
println!("conv: {}", conv_id);
|
r.set_response(ResCreateConversation::new(conv_id))
|
||||||
r.success("create")
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user