mirror of
				https://gitlab.com/comunic/comunicapiv3
				synced 2025-11-04 01:24:04 +00:00 
			
		
		
		
	Get path to user data files
This commit is contained in:
		@@ -15,3 +15,9 @@ 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
 | 
				
			||||||
@@ -31,3 +33,17 @@ pub struct User {
 | 
				
			|||||||
    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)
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -3,3 +3,4 @@
 | 
				
			|||||||
//! 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)
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
		Reference in New Issue
	
	Block a user