1
0
mirror of https://gitlab.com/comunic/comunicapiv3 synced 2024-12-27 22:18:51 +00:00

Can delete group conversation

This commit is contained in:
Pierre HUBERT 2021-04-03 19:14:32 +02:00
parent 63c284c322
commit 42d43ef9d8
3 changed files with 21 additions and 0 deletions

View File

@ -179,6 +179,20 @@ pub fn create_conversation(r: &mut HttpRequestHandler) -> RequestResult {
r.set_response(ResCreateConversationForGroup::new(conv_id))
}
/// Delete a group's conversation
pub fn delete_conversation(r: &mut HttpRequestHandler) -> RequestResult {
let conv_membership = r.post_conv_admin("conv_id")?;
let conv = conversations_helper::get_single(conv_membership.conv_id)?;
if !conv.is_linked_to_group() {
r.bad_request("This conversation is not linked to a group, it can not deleted this way!".to_string())?;
}
conversations_helper::delete_conversation(&conv)?;
r.ok()
}
/// Get the list of members of a group
pub fn get_members(r: &mut HttpRequestHandler) -> RequestResult {
let group_id = r.post_group_id("id")?;
@ -282,6 +296,8 @@ pub fn send_request(r: &mut HttpRequestHandler) -> RequestResult {
following: true,
})?;
// TODO : if the user has already the "member" level, gives him access to conversations
// Send a notification, if required
if matches!(group.registration_level, GroupRegistrationLevel::MODERATED_REGISTRATION) {
notifications_helper::create_group_membership_notification(r.user_id_ref()?, None,

View File

@ -132,6 +132,8 @@ pub fn delete_member(group_id: &GroupID, user_id: &UserID) -> ResultBoxError {
.cond_group_id("groups_id", group_id)
.cond_user_id("user_id", user_id)
.exec()
// TODO : Update access to group's conversations
}
/// Update a user's membership level
@ -141,6 +143,8 @@ pub fn update_membership_level(group_id: &GroupID, user_id: &UserID, new_level:
.cond_group_id("groups_id", group_id)
.set_u32("level", new_level.to_db())
.exec()
// TODO : Update access to group's conversations
}
/// Update following status of a user

View File

@ -228,6 +228,7 @@ pub fn get_routes() -> Vec<Route> {
Route::post("/groups/upload_logo", Box::new(groups_controller::upload_logo)),
Route::post("/groups/delete_logo", Box::new(groups_controller::delete_logo)),
Route::post("/groups/create_conversation", Box::new(groups_controller::create_conversation)),
Route::post("/groups/delete_conversation", Box::new(groups_controller::delete_conversation)),
Route::post("/groups/get_members", Box::new(groups_controller::get_members)),
Route::post("/groups/invite", Box::new(groups_controller::invite_user)),
Route::post("/groups/cancel_invitation", Box::new(groups_controller::cancel_invitation)),