mirror of
https://gitlab.com/comunic/comunicapiv3
synced 2025-06-20 08:25:16 +00:00
Can remove a member from a conversation
This commit is contained in:
@ -5,6 +5,7 @@
|
||||
|
||||
use std::collections::HashSet;
|
||||
use std::error::Error;
|
||||
use std::str::from_utf8;
|
||||
|
||||
use exif::In;
|
||||
use image::{GenericImageView, ImageFormat};
|
||||
@ -31,7 +32,6 @@ use crate::utils::string_utils::{check_emoji_code, check_html_color, check_strin
|
||||
use crate::utils::user_data_utils::{generate_new_user_data_file_name, prepare_file_creation, user_data_path};
|
||||
use crate::utils::virtual_directories_utils;
|
||||
use crate::utils::zip_utils::is_valid_zip;
|
||||
use std::str::from_utf8;
|
||||
|
||||
#[derive(Serialize)]
|
||||
struct SuccessMessage {
|
||||
@ -80,6 +80,13 @@ pub trait BaseRequestHandler {
|
||||
})
|
||||
}
|
||||
|
||||
/// Success without message
|
||||
fn ok(&mut self) -> RequestResult {
|
||||
self.set_response(SuccessMessage {
|
||||
success: "OK.".to_string()
|
||||
})
|
||||
}
|
||||
|
||||
/// Internal error response (500)
|
||||
fn internal_error(&mut self, error: Box<dyn Error>) -> RequestResult {
|
||||
self.set_error(HttpError::internal_error("Internal server error."));
|
||||
|
@ -75,6 +75,11 @@ impl Conversation {
|
||||
!self.is_managed() && (self.is_admin(user_id) || self.can_everyone_add_members)
|
||||
}
|
||||
|
||||
/// Check out whether a user can remove members from a conversation or not
|
||||
pub fn can_user_remove_members(&self, user_id: &UserID) -> bool {
|
||||
!self.is_managed() && self.is_admin(user_id)
|
||||
}
|
||||
|
||||
/// Check out whether a user is the last administrator of a conversation or not
|
||||
pub fn is_last_admin(&self, user_id: &UserID) -> bool {
|
||||
let admins: Vec<&ConversationMember> = self.members
|
||||
|
Reference in New Issue
Block a user