mirror of
https://gitlab.com/comunic/comunicapiv3
synced 2024-11-22 13:29:21 +00:00
Can cancel a group membership request
This commit is contained in:
parent
205541f6d8
commit
8b0095942c
@ -226,4 +226,19 @@ pub fn send_request(r: &mut HttpRequestHandler) -> RequestResult {
|
||||
// TODO : Send a notification, if required
|
||||
|
||||
r.success("The membership has been successfully saved!")
|
||||
}
|
||||
|
||||
/// Cancel a group membership request
|
||||
pub fn cancel_request(r: &mut HttpRequestHandler) -> RequestResult {
|
||||
let group_id = r.post_group_id_with_access("id", GroupAccessLevel::LIMITED_ACCESS)?;
|
||||
|
||||
if groups_helper::get_membership_level(&group_id, r.user_id_opt())? != GroupMembershipLevel::PENDING {
|
||||
r.forbidden("You did not send a membership request to this group!".to_string())?;
|
||||
}
|
||||
|
||||
groups_helper::delete_member(&group_id, &r.user_id()?)?;
|
||||
|
||||
// TODO : delete any related notification
|
||||
|
||||
r.success("The request has been successfully cancelled!")
|
||||
}
|
@ -156,6 +156,8 @@ pub fn get_routes() -> Vec<Route> {
|
||||
|
||||
Route::post("/groups/send_request", Box::new(groups_controller::send_request)),
|
||||
|
||||
Route::post("/groups/cancel_request", Box::new(groups_controller::cancel_request)),
|
||||
|
||||
|
||||
// Virtual directory controller
|
||||
Route::post("/user/findbyfolder", Box::new(virtual_directory_controller::find_user)),
|
||||
|
Loading…
Reference in New Issue
Block a user