mirror of
https://gitlab.com/comunic/comunicapiv3
synced 2025-06-20 16:35:17 +00:00
Ready to implement account image visibility
This commit is contained in:
@ -3,7 +3,7 @@
|
||||
//! @author Pierre Hubert
|
||||
use serde::Serialize;
|
||||
|
||||
use crate::data::user::{User, UserPageStatus};
|
||||
use crate::data::user::{User, UserPageStatus, UserID};
|
||||
|
||||
#[derive(Serialize)]
|
||||
#[allow(non_snake_case)]
|
||||
@ -14,17 +14,26 @@ pub struct APIUserInfo {
|
||||
publicPage: bool,
|
||||
openPage: bool,
|
||||
virtualDirectory: String,
|
||||
accountImage: String,
|
||||
}
|
||||
|
||||
impl APIUserInfo {
|
||||
pub fn new(info: User) -> APIUserInfo {
|
||||
/// Construct a new API user instance. Note: `user_id` is the ID of the user who makes the
|
||||
/// requests, not the user whose we return information about!
|
||||
pub fn new(user_id: Option<UserID>, info: &User) -> APIUserInfo {
|
||||
APIUserInfo {
|
||||
userID: info.id,
|
||||
firstName: info.first_name,
|
||||
lastName: info.last_name,
|
||||
firstName: info.first_name.to_string(),
|
||||
lastName: info.last_name.to_string(),
|
||||
publicPage: info.status != UserPageStatus::PRIVATE,
|
||||
openPage: info.status == UserPageStatus::OPEN,
|
||||
virtualDirectory: info.virtual_directory.unwrap_or("".to_string())
|
||||
virtualDirectory: info.virtual_directory.clone().unwrap_or(String::new()),
|
||||
accountImage: APIUserInfo::get_account_image_url(user_id, info),
|
||||
}
|
||||
}
|
||||
|
||||
/// Get the URL of a specific user account image
|
||||
pub fn get_account_image_url(user_id: Option<UserID>, user: &User) -> String {
|
||||
"do it".to_string()
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user