diff --git a/src/api_data/server_config.rs b/src/api_data/server_config.rs index 9210432..a2116c0 100644 --- a/src/api_data/server_config.rs +++ b/src/api_data/server_config.rs @@ -4,7 +4,7 @@ use serde::Serialize; use crate::constants::{conservation_policy, MIN_SUPPORTED_MOBILE_VERSION, password_policy}; -use crate::constants::accounts_info_policy::{MAX_FIRST_NAME_LENGTH, MAX_LAST_NAME_LENGTH, MIN_FIRST_NAME_LENGTH, MIN_LAST_NAME_LENGTH}; +use crate::constants::accounts_info_policy::{MAX_FIRST_NAME_LENGTH, MAX_LAST_NAME_LENGTH, MAX_LOCATION_LENGTH, MIN_FIRST_NAME_LENGTH, MIN_LAST_NAME_LENGTH}; use crate::constants::conversations::{ALLOWED_CONVERSATION_FILES_TYPES, CONVERSATION_FILES_MAX_SIZE, CONVERSATION_WRITING_EVENT_INTERVAL, CONVERSATION_WRITING_EVENT_LIFETIME, MAX_CONV_IMAGE_MESSAGE_WIDTH, MAX_CONV_LOGO_HEIGHT, MAX_CONV_LOGO_WIDTH, MAX_CONV_MESSAGE_THUMBNAIL_HEIGHT, MAX_CONV_MESSAGE_THUMBNAIL_WIDTH, MAX_CONVERSATION_MESSAGE_LENGTH, MAX_CONVERSATION_NAME_LENGTH, MIN_CONVERSATION_MESSAGE_LENGTH}; use crate::data::api_client::APIClient; use crate::data::config::conf; @@ -60,6 +60,7 @@ struct AccountInformationPolicy { max_first_name_length: u8, min_last_name_length: u8, max_last_name_length: u8, + max_location_length: usize, } #[derive(Serialize)] @@ -132,6 +133,7 @@ impl ServerConfig { max_first_name_length: MAX_FIRST_NAME_LENGTH, min_last_name_length: MIN_LAST_NAME_LENGTH, max_last_name_length: MAX_LAST_NAME_LENGTH, + max_location_length: MAX_LOCATION_LENGTH, }, } } diff --git a/src/constants.rs b/src/constants.rs index 3e44f12..195eafc 100644 --- a/src/constants.rs +++ b/src/constants.rs @@ -233,6 +233,9 @@ pub mod accounts_info_policy { /// Minimum & maximum last name length pub const MIN_LAST_NAME_LENGTH: u8 = 2; pub const MAX_LAST_NAME_LENGTH: u8 = 50; + + /// Max location value size + pub const MAX_LOCATION_LENGTH: usize = 45; } /// Url where Firebase push notifications can be sent diff --git a/src/controllers/settings_controller.rs b/src/controllers/settings_controller.rs index ce9f09b..ff612de 100644 --- a/src/controllers/settings_controller.rs +++ b/src/controllers/settings_controller.rs @@ -23,6 +23,7 @@ use crate::data::user::{AccountImageVisibility, UserPageStatus}; use crate::helpers::{account_helper, custom_emojies_helper, user_helper}; use crate::helpers::virtual_directory_helper::VirtualDirType; use crate::routes::RequestResult; +use crate::utils::string_utils::remove_html_nodes; /// Get the general settings of the user pub fn get_general(r: &mut HttpRequestHandler) -> RequestResult { @@ -52,10 +53,12 @@ pub fn set_general(r: &mut HttpRequestHandler) -> RequestResult { block_comments: !r.post_bool("allowComments")?, allow_posts_from_friends: r.post_bool("allowPostsFromFriends")?, friends_list_public: r.post_bool("publicFriendsList")?, + email_public: r.post_bool("email_public")?, personal_website, virtual_directory, allow_mails: r.post_bool("allow_comunic_mails")?, public_note: Some(r.post_content("publicNote", 0, false)?), + location: r.post_string_optional("location").map(|s| remove_html_nodes(&s)), }; account_helper::set_general(&new_settings)?; diff --git a/src/data/general_settings.rs b/src/data/general_settings.rs index 58ae2a9..8c203c9 100644 --- a/src/data/general_settings.rs +++ b/src/data/general_settings.rs @@ -12,8 +12,10 @@ pub struct GeneralSettings { pub block_comments: bool, pub allow_posts_from_friends: bool, pub friends_list_public: bool, + pub email_public: bool, pub personal_website: Option, pub virtual_directory: Option, pub allow_mails: bool, pub public_note: Option, + pub location: Option, } \ No newline at end of file diff --git a/src/helpers/account_helper.rs b/src/helpers/account_helper.rs index 1cc08f4..fbc1b69 100644 --- a/src/helpers/account_helper.rs +++ b/src/helpers/account_helper.rs @@ -231,9 +231,11 @@ pub fn set_general(settings: &GeneralSettings) -> ResultBoxError { .set_legacy_bool("autoriser_post_amis", settings.allow_posts_from_friends) .set_legacy_bool("autorise_mail", settings.allow_mails) .set_legacy_bool("liste_amis_publique", settings.friends_list_public) + .set_legacy_bool("is_email_public", settings.email_public) .set_opt_str("sous_repertoire", settings.virtual_directory.clone()) .set_opt_str("site_web", settings.personal_website.clone()) .set_opt_str("public_note", settings.public_note.clone()) + .set_opt_str("location", settings.location.clone()) .exec() }