1
0
mirror of https://gitlab.com/comunic/comunicapiv3 synced 2024-11-27 15:59:21 +00:00
comunicapiv3/src/controllers/groups_controller.rs

21 lines
614 B
Rust
Raw Normal View History

2020-06-23 17:04:32 +00:00
//! # Groups controller
//!
//! @author Pierre Hubert
2020-06-24 07:08:31 +00:00
use crate::api_data::res_create_group::GroupCreationResult;
2020-06-23 17:04:32 +00:00
use crate::controllers::routes::RequestResult;
use crate::data::http_request_handler::HttpRequestHandler;
2020-06-24 07:08:31 +00:00
use crate::data::new_group::NewGroup;
use crate::helpers::groups_helper;
2020-06-23 17:04:32 +00:00
/// Create a new group
pub fn create(r: &mut HttpRequestHandler) -> RequestResult {
2020-06-24 07:08:31 +00:00
let new_group = NewGroup {
name: r.post_string_opt("name", 3, true)?,
owner_id: r.user_id()?,
};
let group_id = groups_helper::create(&new_group)?;
r.set_response(GroupCreationResult::new(&group_id))
2020-06-23 17:04:32 +00:00
}