1
0
mirror of https://gitlab.com/comunic/comunicapiv3 synced 2025-06-20 16:35:17 +00:00

Can delete group conversation

This commit is contained in:
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,