Refactor decryption logic to handle empty fields consistently across services
This commit is contained in:
@@ -252,9 +252,9 @@ pub fn get_spell_detail(conn: &Connection, user_id: &str, spell_id: &str, lang:
|
||||
.ok_or_else(|| AppError::Internal(if lang == Lang::Fr { "Sort non trouvé.".to_string() } else { "Spell not found.".to_string() }))?;
|
||||
|
||||
let decrypted_name: String = decrypt_data_with_user_key(&spell.name, &user_key)?;
|
||||
let decrypted_description: String = if let Some(ref description) = spell.description { decrypt_data_with_user_key(description, &user_key)? } else { String::new() };
|
||||
let decrypted_appearance: String = if let Some(ref appearance) = spell.appearance { decrypt_data_with_user_key(appearance, &user_key)? } else { String::new() };
|
||||
let decrypted_tags: Option<String> = if let Some(ref tags) = spell.tags { Some(decrypt_data_with_user_key(tags, &user_key)?) } else { None };
|
||||
let decrypted_description: String = if let Some(ref description) = spell.description { if description.is_empty() { String::new() } else { decrypt_data_with_user_key(description, &user_key)? } } else { String::new() };
|
||||
let decrypted_appearance: String = if let Some(ref appearance) = spell.appearance { if appearance.is_empty() { String::new() } else { decrypt_data_with_user_key(appearance, &user_key)? } } else { String::new() };
|
||||
let decrypted_tags: Option<String> = if let Some(ref tags) = spell.tags { if tags.is_empty() { None } else { Some(decrypt_data_with_user_key(tags, &user_key)?) } } else { None };
|
||||
|
||||
let tag_ids: Vec<String> = match decrypted_tags {
|
||||
Some(ref tags_str) => serde_json::from_str(tags_str).unwrap_or_default(),
|
||||
|
||||
Reference in New Issue
Block a user