mirror of
https://gitlab.com/comunic/comunicapiv3
synced 2025-06-20 16:35:17 +00:00
Start account export
This commit is contained in:
33
src/api_data/account_export_api.rs
Normal file
33
src/api_data/account_export_api.rs
Normal file
@ -0,0 +1,33 @@
|
||||
//! # Export account API entry
|
||||
//!
|
||||
//! @author Pierre Hubert
|
||||
use serde::Serialize;
|
||||
|
||||
use crate::api_data::comment_api::CommentAPI;
|
||||
use crate::api_data::post_api::PostAPI;
|
||||
use crate::api_data::user_info::APIUserInfo;
|
||||
use crate::data::account_export::AccountExport;
|
||||
use crate::data::error::ResultBoxError;
|
||||
|
||||
#[derive(Serialize)]
|
||||
#[allow(non_snake_case)]
|
||||
pub struct AccountExportAPI {
|
||||
userID: u64,
|
||||
advanced_info: APIUserInfo,
|
||||
posts: Vec<PostAPI>,
|
||||
comments: Vec<CommentAPI>,
|
||||
}
|
||||
|
||||
impl AccountExportAPI {
|
||||
pub fn new(export: &AccountExport) -> ResultBoxError<AccountExportAPI> {
|
||||
let curr_user_id = &export.user.id;
|
||||
let export = AccountExportAPI {
|
||||
userID: curr_user_id.id(),
|
||||
advanced_info: APIUserInfo::new_advanced_info(&curr_user_id.as_option(), &export.user)?,
|
||||
posts: PostAPI::for_list(&export.posts, curr_user_id.as_option())?,
|
||||
comments: CommentAPI::for_list(&export.comments, &curr_user_id.as_option())?,
|
||||
};
|
||||
|
||||
Ok(export)
|
||||
}
|
||||
}
|
@ -46,4 +46,5 @@ mod type_container_api;
|
||||
pub mod res_check_email_exists;
|
||||
pub mod res_check_security_questions_exists;
|
||||
pub mod res_get_security_questions;
|
||||
pub mod res_check_security_answers;
|
||||
pub mod res_check_security_answers;
|
||||
pub mod account_export_api;
|
Reference in New Issue
Block a user