mirror of
https://gitlab.com/comunic/comunicapiv3
synced 2025-06-21 17:05:16 +00:00
Can set general settings
This commit is contained in:
19
src/data/general_settings.rs
Normal file
19
src/data/general_settings.rs
Normal file
@ -0,0 +1,19 @@
|
||||
//! # General settings
|
||||
//!
|
||||
//! @author Pierre Hubert
|
||||
|
||||
use crate::data::user::{UserID, UserPageStatus};
|
||||
|
||||
pub struct GeneralSettings {
|
||||
pub id: UserID,
|
||||
pub first_name: String,
|
||||
pub last_name: String,
|
||||
pub page_status: UserPageStatus,
|
||||
pub block_comments: bool,
|
||||
pub allow_posts_from_friends: bool,
|
||||
pub friends_list_public: bool,
|
||||
pub personal_website: Option<String>,
|
||||
pub virtual_directory: Option<String>,
|
||||
pub allow_mails: bool,
|
||||
pub public_note: Option<String>,
|
||||
}
|
@ -10,6 +10,7 @@ use image::{GenericImageView, ImageFormat};
|
||||
use serde::Serialize;
|
||||
|
||||
use crate::api_data::http_error::HttpError;
|
||||
use crate::constants::PASSWORD_MIN_LENGTH;
|
||||
use crate::controllers::routes::RequestResult;
|
||||
use crate::data::api_client::APIClient;
|
||||
use crate::data::comment::Comment;
|
||||
@ -25,7 +26,6 @@ use crate::utils::pdf_utils::is_valid_pdf;
|
||||
use crate::utils::string_utils::{check_string_before_insert, check_url, remove_html_nodes};
|
||||
use crate::utils::user_data_utils::{generate_new_user_data_file_name, prepare_file_creation, user_data_path};
|
||||
use crate::utils::virtual_directories_utils::check_virtual_directory;
|
||||
use crate::constants::PASSWORD_MIN_LENGTH;
|
||||
|
||||
/// Http request handler
|
||||
///
|
||||
@ -654,7 +654,7 @@ impl HttpRequestHandler {
|
||||
self.forbidden("Please do not include inline images!".to_string())?;
|
||||
}
|
||||
|
||||
if !check_string_before_insert(&content) {
|
||||
if min_len > 0 && required && !check_string_before_insert(&content) {
|
||||
self.forbidden(format!("The content inside {} was rejected!", name))?;
|
||||
}
|
||||
|
||||
@ -662,7 +662,7 @@ impl HttpRequestHandler {
|
||||
}
|
||||
|
||||
/// Check the password of the current user
|
||||
pub fn need_user_password(&mut self, field: &str) ->ResultBoxError {
|
||||
pub fn need_user_password(&mut self, field: &str) -> ResultBoxError {
|
||||
let password = self.post_string_opt(field, PASSWORD_MIN_LENGTH, true)?;
|
||||
|
||||
if !account_helper::check_user_password(self.user_id_ref()?, &password)? {
|
||||
|
@ -29,4 +29,5 @@ pub mod user_membership;
|
||||
pub mod new_account;
|
||||
pub mod account_export;
|
||||
pub mod user_like;
|
||||
pub mod survey_response;
|
||||
pub mod survey_response;
|
||||
pub mod general_settings;
|
Reference in New Issue
Block a user