1
0
mirror of https://gitlab.com/comunic/comunicapiv3 synced 2024-11-22 05:19:21 +00:00

Improve code readability

This commit is contained in:
Pierre HUBERT 2022-03-17 18:29:42 +01:00
parent 70d5b50f4c
commit 9271623fd6
7 changed files with 12 additions and 12 deletions

View File

@ -18,7 +18,7 @@ pub struct DataConservationSettingsAPI {
impl DataConservationSettingsAPI {
pub fn new(user: &User) -> Self {
Self {
inactive_account_lifetime: user.delete_account_after.clone(),
inactive_account_lifetime: user.delete_account_after,
notification_lifetime: user.delete_notifications_after,
comments_lifetime: user.delete_comments_after,
posts_lifetime: user.delete_posts_after,

View File

@ -9,7 +9,7 @@ pub trait EntitiesConstructor {
fn new(i: &Self::Item) -> Self;
/// Parse a list of it
fn for_list(l: &Vec<Self::Item>) -> Vec<Self>
fn for_list(l: &[Self::Item]) -> Vec<Self>
where Self: std::marker::Sized {
l.iter().map(Self::new).collect()
}

View File

@ -40,9 +40,9 @@ impl GeneralSettingsAPI {
allow_comunic_mails: user.allow_mails,
public_friends_list: user.public_friends_list,
public_email: user.is_email_public,
virtual_directory: user.virtual_directory.clone().unwrap_or(String::new()),
personnal_website: user.personal_website.clone().unwrap_or(String::new()),
publicNote: user.public_note.clone().unwrap_or(String::new()),
virtual_directory: user.virtual_directory.clone().unwrap_or_default(),
personnal_website: user.personal_website.clone().unwrap_or_default(),
publicNote: user.public_note.clone().unwrap_or_default(),
location: user.location.clone(),
}
}

View File

@ -20,10 +20,10 @@ impl SecuritySettingsAPI {
pub fn new(user: &User) -> SecuritySettingsAPI {
SecuritySettingsAPI {
id: user.id.id(),
security_question_1: user.security_question_1.clone().unwrap_or(String::new()),
security_answer_1: user.security_answer_1.clone().unwrap_or(String::new()),
security_question_2: user.security_question_2.clone().unwrap_or(String::new()),
security_answer_2: user.security_answer_2.clone().unwrap_or(String::new()),
security_question_1: user.security_question_1.clone().unwrap_or_default(),
security_answer_1: user.security_answer_1.clone().unwrap_or_default(),
security_question_2: user.security_question_2.clone().unwrap_or_default(),
security_answer_2: user.security_answer_2.clone().unwrap_or_default(),
}
}
}

View File

@ -27,7 +27,7 @@ impl UserLikeAPI {
}
}
pub fn for_list(l: &Vec<UserLike>) -> Vec<Self> {
pub fn for_list(l: &[UserLike]) -> Vec<Self> {
l.iter().map(Self::new).collect()
}
}

View File

@ -28,7 +28,7 @@ pub fn time() -> u64 {
pub fn time_to_mysql_date(time: u64) -> String {
let utc = Utc.timestamp(time as i64, 0);
let str = utc.to_rfc3339();
(&str[..19]).replace("T", " ")
(&str[..19]).replace('T', " ")
}
/// Get current Mysql formatted date

View File

@ -48,7 +48,7 @@ pub fn prepare_file_creation(user_id: &UserID, folder: &str) -> ResultBoxError<P
/// Generate a new file name to store user data
pub fn generate_new_user_data_file_name(dir: &Path, ext: &str) -> ResultBoxError<PathBuf> {
let sys_dir = user_data_path(&dir);
let sys_dir = user_data_path(dir);
if !sys_dir.exists() {
return Err(ExecError::boxed_string(format!("Directory {:?} does not exists!", dir)));