mirror of
https://gitlab.com/comunic/comunicapiv3
synced 2025-06-20 16:35:17 +00:00
Start to return advanced user info
This commit is contained in:
@ -21,6 +21,20 @@ pub struct APIUserInfo {
|
||||
virtualDirectory: String,
|
||||
accountImage: String,
|
||||
customEmojis: Vec<CustomEmojiAPI>,
|
||||
|
||||
#[serde(flatten)]
|
||||
advanced_info: Option<APIAdvancedInfo>,
|
||||
}
|
||||
|
||||
#[derive(Serialize)]
|
||||
#[allow(non_snake_case)]
|
||||
struct APIAdvancedInfo {
|
||||
friend_list_public: bool,
|
||||
personnalWebsite: String,
|
||||
publicNote: String,
|
||||
noCommentOnHisPage: bool,
|
||||
allowPostFromFriendOnHisPage: bool,
|
||||
account_creation_time: u64
|
||||
}
|
||||
|
||||
impl APIUserInfo {
|
||||
@ -39,9 +53,27 @@ 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)?;
|
||||
|
||||
// Set advanced user information
|
||||
user.advanced_info = Some(APIAdvancedInfo {
|
||||
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()),
|
||||
noCommentOnHisPage: info.block_comments_on_his_page,
|
||||
allowPostFromFriendOnHisPage: info.allow_posts_from_friends,
|
||||
account_creation_time: info.account_creation_time
|
||||
});
|
||||
|
||||
Ok(user)
|
||||
}
|
||||
|
||||
/// Get the URL of a specific user account image
|
||||
pub fn get_account_image_url(user_id: Option<UserID>, user: &User) -> ResultBoxError<String> {
|
||||
if !user.has_account_image() {
|
||||
|
Reference in New Issue
Block a user