mirror of
https://gitlab.com/comunic/comunicapiv3
synced 2025-06-21 17:05:16 +00:00
Can respond to an invitation
This commit is contained in:
@ -172,4 +172,24 @@ pub fn invite_user(r: &mut HttpRequestHandler) -> RequestResult {
|
||||
// TODO : send a notification
|
||||
|
||||
r.success("The user has been successfully invited to join the group!")
|
||||
}
|
||||
|
||||
/// Respond to a user invitation
|
||||
pub fn respond_invitation(r: &mut HttpRequestHandler) -> RequestResult {
|
||||
let group_id = r.post_group_id_with_access("id", GroupAccessLevel::LIMITED_ACCESS)?;
|
||||
let accept = r.post_bool("accept")?;
|
||||
|
||||
if !groups_helper::received_invitation(&group_id, &r.user_id()?)? {
|
||||
r.not_found("Invitation not found!".to_string())?
|
||||
}
|
||||
|
||||
groups_helper::respond_invitation(&group_id, &r.user_id()?, accept)?;
|
||||
|
||||
if accept {
|
||||
groups_helper::set_following(&group_id, &r.user_id()?, true)?;
|
||||
}
|
||||
|
||||
// TODO : Create a notification
|
||||
|
||||
r.success("Response to the invitation was successfully saved!")
|
||||
}
|
@ -152,6 +152,8 @@ pub fn get_routes() -> Vec<Route> {
|
||||
|
||||
Route::post("/groups/invite", Box::new(groups_controller::invite_user)),
|
||||
|
||||
Route::post("/groups/respond_invitation", Box::new(groups_controller::respond_invitation)),
|
||||
|
||||
|
||||
// Virtual directory controller
|
||||
Route::post("/user/findbyfolder", Box::new(virtual_directory_controller::find_user)),
|
||||
|
Reference in New Issue
Block a user