1
0
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:
2020-07-14 11:36:15 +02:00
parent dcd8b07b60
commit 1850ca0626
6 changed files with 82 additions and 6 deletions

View 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>,
}

View File

@ -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)? {

View File

@ -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;