mirror of
https://gitlab.com/comunic/comunicapiv3
synced 2024-11-25 23:09:22 +00:00
Get path to user data files
This commit is contained in:
parent
175266f397
commit
305e836d78
@ -14,4 +14,10 @@ pub mod database_tables_names {
|
|||||||
|
|
||||||
/// User table
|
/// User table
|
||||||
pub const USERS_TABLE: &str = "utilisateurs";
|
pub const USERS_TABLE: &str = "utilisateurs";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// The account image to show for user who do not have any
|
||||||
|
pub const DEFAULT_ACCOUNT_IMAGE: &str = "avatars/0Reverse.png";
|
||||||
|
|
||||||
|
/// The account image to show for users who are not allowed to access other users account images
|
||||||
|
pub const ERROR_ACCOUNT_IMAGE: &str = "avatars/0Red.png";
|
@ -1,3 +1,5 @@
|
|||||||
|
use crate::utils::user_data_utils::user_data_url;
|
||||||
|
|
||||||
///! User information
|
///! User information
|
||||||
///!
|
///!
|
||||||
///! @author Pierre Hubert
|
///! @author Pierre Hubert
|
||||||
@ -30,4 +32,18 @@ pub struct User {
|
|||||||
pub virtual_directory: Option<String>,
|
pub virtual_directory: Option<String>,
|
||||||
pub account_image_path: Option<String>,
|
pub account_image_path: Option<String>,
|
||||||
pub account_image_visibility: AccountImageVisibility,
|
pub account_image_visibility: AccountImageVisibility,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl User {
|
||||||
|
|
||||||
|
/// Get the URL pointing to the default account image
|
||||||
|
pub fn default_account_image_url() -> String {
|
||||||
|
user_data_url(crate::constants::DEFAULT_ACCOUNT_IMAGE)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Get the URL pointing to the error account image, when the user is not allowed to see user
|
||||||
|
/// account image
|
||||||
|
pub fn error_account_image_url() -> String {
|
||||||
|
user_data_url(crate::constants::ERROR_ACCOUNT_IMAGE)
|
||||||
|
}
|
||||||
}
|
}
|
@ -2,4 +2,5 @@
|
|||||||
//!
|
//!
|
||||||
//! This module contains utilities that can be used anywhere in the code
|
//! This module contains utilities that can be used anywhere in the code
|
||||||
|
|
||||||
pub mod crypt_utils;
|
pub mod crypt_utils;
|
||||||
|
pub mod user_data_utils;
|
12
src/utils/user_data_utils.rs
Normal file
12
src/utils/user_data_utils.rs
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
//! # User data utilities
|
||||||
|
//!
|
||||||
|
//! @author Pierre Hubert
|
||||||
|
|
||||||
|
use crate::data::config::conf;
|
||||||
|
|
||||||
|
/// Get the full URL to a user data file
|
||||||
|
///
|
||||||
|
/// `uri` should contain the path to the target resource
|
||||||
|
pub fn user_data_url(uri: &str) -> String {
|
||||||
|
format!("{}{}", conf().storage_url, uri)
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user