mirror of
https://gitlab.com/comunic/comunicapiv3
synced 2024-11-22 21:39:21 +00:00
A user can remove its group's membership
This commit is contained in:
parent
5906c53484
commit
f219b0f4fa
@ -338,3 +338,18 @@ pub fn get_membership(r: &mut HttpRequestHandler) -> RequestResult {
|
||||
|
||||
r.set_response(GroupMemberAPI::new(&membership))
|
||||
}
|
||||
|
||||
/// Delete the membership of a user over a group
|
||||
pub fn remove_membership(r: &mut HttpRequestHandler) -> RequestResult {
|
||||
let group_id = r.post_group_id_with_access("groupID", GroupAccessLevel::LIMITED_ACCESS)?;
|
||||
|
||||
if groups_helper::is_last_admin(&group_id, &r.user_id()?)? {
|
||||
r.forbidden("You are the last administrator of this group!".to_string())?;
|
||||
}
|
||||
|
||||
groups_helper::delete_member(&group_id, &r.user_id()?)?;
|
||||
|
||||
// TODO : delete group membership notifications
|
||||
|
||||
r.success("Your membership has been successfully deleted!")
|
||||
}
|
@ -168,6 +168,8 @@ pub fn get_routes() -> Vec<Route> {
|
||||
|
||||
Route::post("/groups/get_membership", Box::new(groups_controller::get_membership)),
|
||||
|
||||
Route::post("/groups/remove_membership", Box::new(groups_controller::remove_membership)),
|
||||
|
||||
|
||||
// Virtual directory controller
|
||||
Route::post("/user/findbyfolder", Box::new(virtual_directory_controller::find_user)),
|
||||
|
Loading…
Reference in New Issue
Block a user