mirror of
https://gitlab.com/comunic/comunicapiv3
synced 2024-12-27 22:18:51 +00:00
Can delete account image
This commit is contained in:
parent
e02c0ba2b9
commit
33eab5919b
@ -104,6 +104,7 @@ pub fn get_routes() -> Vec<Route> {
|
||||
Route::post("/settings/update_password", Box::new(settings_controller::update_password)),
|
||||
Route::post("/settings/get_account_image", Box::new(settings_controller::get_account_image_settings)),
|
||||
Route::post("/settings/upload_account_image", Box::new(settings_controller::upload_account_image)),
|
||||
Route::post("/settings/delete_account_image", Box::new(settings_controller::delete_account_image)),
|
||||
|
||||
|
||||
// Friends controller
|
||||
|
@ -2,6 +2,7 @@
|
||||
//!
|
||||
//! @author Pierre Hubert
|
||||
|
||||
use crate::api_data::account_image_settings_api::AccountImageSettingsAPI;
|
||||
use crate::api_data::general_settings_api::GeneralSettingsAPI;
|
||||
use crate::api_data::language_settings_api::LanguageSettingsAPI;
|
||||
use crate::api_data::security_settings_api::SecuritySettingsAPI;
|
||||
@ -14,7 +15,6 @@ use crate::data::security_settings::{SecurityQuestion, SecuritySettings};
|
||||
use crate::data::user::UserPageStatus;
|
||||
use crate::helpers::{account_helper, user_helper};
|
||||
use crate::helpers::virtual_directory_helper::VirtualDirType;
|
||||
use crate::api_data::account_image_settings_api::AccountImageSettingsAPI;
|
||||
|
||||
/// Get the general settings of the user
|
||||
pub fn get_general(r: &mut HttpRequestHandler) -> RequestResult {
|
||||
@ -147,7 +147,7 @@ pub fn get_account_image_settings(r: &mut HttpRequestHandler) -> RequestResult {
|
||||
/// Upload a new account image
|
||||
pub fn upload_account_image(r: &mut HttpRequestHandler) -> RequestResult {
|
||||
if !r.has_file("picture") {
|
||||
return r.bad_request("An error occurred while receiving the image !".to_string())
|
||||
return r.bad_request("An error occurred while receiving the image !".to_string());
|
||||
}
|
||||
|
||||
let uri = r.save_post_image("picture", "avatars", 800, 800)?;
|
||||
@ -155,4 +155,11 @@ pub fn upload_account_image(r: &mut HttpRequestHandler) -> RequestResult {
|
||||
account_helper::set_account_image(r.user_id_ref()?, &uri)?;
|
||||
|
||||
r.success("Account image updated!")
|
||||
}
|
||||
|
||||
/// Delete user account image
|
||||
pub fn delete_account_image(r: &mut HttpRequestHandler) -> RequestResult {
|
||||
account_helper::delete_account_image(r.user_id_ref()?)?;
|
||||
|
||||
r.success("Account image deleted!")
|
||||
}
|
Loading…
Reference in New Issue
Block a user