diff --git a/src/controllers/groups_controller.rs b/src/controllers/groups_controller.rs index 41953d4..590aaae 100644 --- a/src/controllers/groups_controller.rs +++ b/src/controllers/groups_controller.rs @@ -12,7 +12,7 @@ use crate::data::group::{Group, GroupAccessLevel, GroupPostsCreationLevel, Group use crate::data::group_id::GroupID; use crate::data::http_request_handler::HttpRequestHandler; use crate::data::new_group::NewGroup; -use crate::helpers::groups_helper; +use crate::helpers::{groups_helper, virtual_directory_helper}; use crate::helpers::virtual_directory_helper::VirtualDirType; /// Create a new group @@ -105,4 +105,16 @@ pub fn set_settings(r: &mut HttpRequestHandler) -> RequestResult { groups_helper::set_settings(&new_settings)?; r.success("Group settings have been successfully updated!") +} + +/// Check out whether a virtual directory is available for a group or not +pub fn check_virtual_dir(r: &mut HttpRequestHandler) -> RequestResult { + let group_id = r.post_group_id_with_access("groupID", GroupAccessLevel::ADMIN_ACCESS)?; + let dir = r.post_virtual_directory("directory")?; + + if !virtual_directory_helper::check_availability(&dir, group_id.id(), VirtualDirType::GROUP)? { + r.forbidden("The requested virtual directory seems not to be available!".to_string())?; + } + + r.success("Requested virtual directory seems to be available!") } \ No newline at end of file diff --git a/src/controllers/routes.rs b/src/controllers/routes.rs index 3b7bedc..92fa78f 100644 --- a/src/controllers/routes.rs +++ b/src/controllers/routes.rs @@ -142,6 +142,8 @@ pub fn get_routes() -> Vec { Route::post("/groups/set_settings", Box::new(groups_controller::set_settings)), + Route::post("/groups/checkVirtualDirectory", Box::new(groups_controller::check_virtual_dir)), + // Virtual directory controller Route::post("/user/findbyfolder", Box::new(virtual_directory_controller::find_user)),