mirror of
https://gitlab.com/comunic/comunicapiv3
synced 2025-06-20 16:35:17 +00:00
Add new user information
This commit is contained in:
@ -13,7 +13,7 @@ use crate::api_data::friend_api::FriendAPI;
|
||||
use crate::api_data::group_api::GroupApi;
|
||||
use crate::api_data::post_api::PostAPI;
|
||||
use crate::api_data::survey_response_api::SurveyResponseAPI;
|
||||
use crate::api_data::user_info::APIUserInfo;
|
||||
use crate::api_data::user_info::{APIUserInfo, APIAdvancedInfo};
|
||||
use crate::api_data::user_like_api::UserLikeAPI;
|
||||
use crate::data::account_export::AccountExport;
|
||||
use crate::data::error::ResultBoxError;
|
||||
@ -26,7 +26,7 @@ use crate::helpers::user_helper;
|
||||
#[allow(non_snake_case)]
|
||||
pub struct AccountExportAPI {
|
||||
userID: u64,
|
||||
advanced_info: APIUserInfo,
|
||||
advanced_info: APIAdvancedInfo,
|
||||
posts: Vec<PostAPI>,
|
||||
comments: Vec<CommentAPI>,
|
||||
likes: Vec<UserLikeAPI>,
|
||||
|
@ -22,17 +22,17 @@ pub struct APIUserInfo {
|
||||
virtualDirectory: String,
|
||||
accountImage: String,
|
||||
customEmojis: Vec<CustomEmojiAPI>,
|
||||
|
||||
#[serde(flatten)]
|
||||
advanced_info: Option<APIAdvancedInfo>,
|
||||
}
|
||||
|
||||
#[derive(Serialize)]
|
||||
#[allow(non_snake_case)]
|
||||
struct APIAdvancedInfo {
|
||||
pub struct APIAdvancedInfo {
|
||||
friend_list_public: bool,
|
||||
personnalWebsite: String,
|
||||
publicNote: String,
|
||||
location: Option<String>,
|
||||
is_email_public: bool,
|
||||
email_address: Option<String>,
|
||||
noCommentOnHisPage: bool,
|
||||
allowPostFromFriendOnHisPage: bool,
|
||||
account_creation_time: u64,
|
||||
@ -41,6 +41,9 @@ struct APIAdvancedInfo {
|
||||
pageLikes: usize,
|
||||
user_like_page: bool,
|
||||
can_post_texts: bool,
|
||||
|
||||
#[serde(flatten)]
|
||||
base_info: APIUserInfo,
|
||||
}
|
||||
|
||||
impl APIUserInfo {
|
||||
@ -59,13 +62,12 @@ impl APIUserInfo {
|
||||
.iter()
|
||||
.map(|f| CustomEmojiAPI::new(f))
|
||||
.collect(),
|
||||
advanced_info: None,
|
||||
})
|
||||
}
|
||||
|
||||
/// Get advanced user information
|
||||
pub fn new_advanced_info(user_id: &Option<UserID>, info: &User) -> ResultBoxError<APIUserInfo> {
|
||||
let mut user = APIUserInfo::new(&user_id, info)?;
|
||||
pub fn new_advanced_info(user_id: &Option<UserID>, info: &User) -> ResultBoxError<APIAdvancedInfo> {
|
||||
let user = APIUserInfo::new(&user_id, info)?;
|
||||
let curr_user_id = user_id.clone().unwrap_or(UserID::new(0));
|
||||
let signed_in = user_id.is_some();
|
||||
|
||||
@ -79,10 +81,17 @@ impl APIUserInfo {
|
||||
} else { false };
|
||||
|
||||
// Set advanced user information
|
||||
user.advanced_info = Some(APIAdvancedInfo {
|
||||
Ok(APIAdvancedInfo {
|
||||
base_info: user,
|
||||
friend_list_public: info.public_friends_list,
|
||||
personnalWebsite: info.personal_website.clone().unwrap_or(String::new()),
|
||||
publicNote: info.public_note.clone().unwrap_or(String::new()),
|
||||
location: info.location.clone(),
|
||||
is_email_public: info.is_email_public,
|
||||
email_address: match info.is_email_public {
|
||||
true => Some(info.email.clone()),
|
||||
false => None,
|
||||
},
|
||||
noCommentOnHisPage: info.block_comments_on_his_page,
|
||||
allowPostFromFriendOnHisPage: info.allow_posts_from_friends,
|
||||
account_creation_time: info.account_creation_time,
|
||||
@ -91,9 +100,7 @@ impl APIUserInfo {
|
||||
pageLikes: likes_helper::count(info.id.id(), LikeType::USER)?,
|
||||
user_like_page: likes_page,
|
||||
can_post_texts: user_helper::can_create_posts(&curr_user_id, &info.id)?,
|
||||
});
|
||||
|
||||
Ok(user)
|
||||
})
|
||||
}
|
||||
|
||||
/// Get the URL of a specific user account image
|
||||
|
Reference in New Issue
Block a user