diff --git a/src/api_data/account_export_api.rs b/src/api_data/account_export_api.rs index 6deb8fb..5ec2e26 100644 --- a/src/api_data/account_export_api.rs +++ b/src/api_data/account_export_api.rs @@ -8,6 +8,8 @@ use serde::Serialize; use crate::api_data::comment_api::CommentAPI; use crate::api_data::conversation_api::ConversationAPI; use crate::api_data::conversation_message_api::ConversationMessageAPI; +use crate::api_data::friend_api::FriendAPI; +use crate::api_data::group_api::GroupApi; use crate::api_data::movie_api::MovieAPI; use crate::api_data::post_api::PostAPI; use crate::api_data::survey_response_api::SurveyResponseAPI; @@ -15,6 +17,8 @@ use crate::api_data::user_info::APIUserInfo; use crate::api_data::user_like_api::UserLikeAPI; use crate::data::account_export::AccountExport; use crate::data::error::ResultBoxError; +use crate::data::group::Group; +use crate::helpers::groups_helper; #[derive(Serialize)] #[allow(non_snake_case)] @@ -29,6 +33,8 @@ pub struct AccountExportAPI { all_conversation_messages: Vec, conversations_list: Vec, conversations_messages: HashMap>, + friends_list: Vec, + groups: Vec, } impl AccountExportAPI { @@ -48,6 +54,14 @@ impl AccountExportAPI { .iter() .map(|r| (r.0.clone(), ConversationMessageAPI::for_list(r.1))) .collect(), + friends_list: FriendAPI::from_list(&export.friends_list), + groups: export.groups + .iter() + .map(|g| groups_helper::get_info(g)) + .collect::, _>>()? + .iter() + .map(|g| GroupApi::new(&g, curr_user_id.as_option())) + .collect::, _>>()?, }; Ok(export) diff --git a/src/data/account_export.rs b/src/data/account_export.rs index dda4fe0..0748783 100644 --- a/src/data/account_export.rs +++ b/src/data/account_export.rs @@ -7,6 +7,8 @@ use std::collections::HashMap; use crate::data::comment::Comment; use crate::data::conversation::Conversation; use crate::data::conversation_message::ConversationMessage; +use crate::data::friend::Friend; +use crate::data::group_id::GroupID; use crate::data::movie::Movie; use crate::data::post::Post; use crate::data::survey_response::SurveyResponse; @@ -23,4 +25,6 @@ pub struct AccountExport { pub all_conversation_messages: Vec, pub conversations: Vec, pub conversation_messages: HashMap>, + pub friends_list: Vec, + pub groups: Vec, } \ No newline at end of file diff --git a/src/helpers/account_helper.rs b/src/helpers/account_helper.rs index 9636e50..e668631 100644 --- a/src/helpers/account_helper.rs +++ b/src/helpers/account_helper.rs @@ -6,7 +6,7 @@ use crate::data::error::{ExecError, ResultBoxError}; use crate::data::new_account::NewAccount; use crate::data::user::UserID; use crate::data::user_token::UserAccessToken; -use crate::helpers::{comments_helper, conversations_helper, database, likes_helper, movies_helper, posts_helper, survey_helper, user_helper}; +use crate::helpers::{comments_helper, conversations_helper, database, friends_helper, groups_helper, likes_helper, movies_helper, posts_helper, survey_helper, user_helper}; use crate::helpers::database::{DeleteQuery, InsertQuery, QueryInfo}; use crate::utils::crypt_utils::{crypt_pass, rand_str}; use crate::utils::date_utils::{mysql_date, time}; @@ -203,8 +203,8 @@ pub fn export(user_id: &UserID) -> ResultBoxError { all_conversation_messages: conversations_helper::export_all_user_messages(user_id)?, conversations: conversations_helper::get_list_user(user_id)?, conversation_messages: Default::default(), - - //TODO : add other fields + friends_list: friends_helper::GetFriendsQuery::new(user_id).exec()?, + groups: groups_helper::get_list_user(user_id, false)?, }; // Process conversation messages