mirror of
https://github.com/danbulant/Portfolio
synced 2026-06-08 17:20:52 +00:00
refactor: method params
This commit is contained in:
parent
a545de458d
commit
64bbd3d946
1 changed files with 3 additions and 9 deletions
|
|
@ -217,20 +217,14 @@ impl PortfolioService {
|
||||||
tokio::fs::metadata(path.join(FileType::Age.as_str())).await.is_ok()
|
tokio::fs::metadata(path.join(FileType::Age.as_str())).await.is_ok()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns decrypted portfolio as bytes
|
/// Returns decrypted portfolio zip as bytes
|
||||||
pub async fn get_portfolio(candidate_id: i32, db: &DbConn) -> Result<Vec<u8>, ServiceError> {
|
pub async fn get_portfolio(candidate_id: i32, private_key: String) -> Result<Vec<u8>, ServiceError> {
|
||||||
let path = Self::get_file_store_path().join(&candidate_id.to_string()).to_path_buf();
|
let path = Self::get_file_store_path().join(&candidate_id.to_string()).to_path_buf();
|
||||||
|
|
||||||
let candidate = Query::find_candidate_by_id(db, candidate_id)
|
|
||||||
.await?
|
|
||||||
.ok_or(ServiceError::CandidateNotFound)?;
|
|
||||||
|
|
||||||
let candidate_public_key = candidate.public_key;
|
|
||||||
|
|
||||||
let path = path.join(FileType::Age.as_str());
|
let path = path.join(FileType::Age.as_str());
|
||||||
|
|
||||||
let buffer =
|
let buffer =
|
||||||
crypto::decrypt_file_with_private_key_as_buffer(path, &candidate_public_key).await?;
|
crypto::decrypt_file_with_private_key_as_buffer(path, &private_key).await?;
|
||||||
|
|
||||||
Ok(buffer)
|
Ok(buffer)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue