1
0
mirror of https://gitlab.com/comunic/comunicapiv3 synced 2024-12-27 05:58:51 +00:00

Can update new user information fields

This commit is contained in:
Pierre HUBERT 2021-04-16 15:06:07 +02:00
parent b5d2410413
commit 2f931ff026
5 changed files with 13 additions and 1 deletions

View File

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

View File

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

View File

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

View File

@ -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<String>,
pub virtual_directory: Option<String>,
pub allow_mails: bool,
pub public_note: Option<String>,
pub location: Option<String>,
}

View File

@ -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()
}