1
0
mirror of https://gitlab.com/comunic/comunicapiv3 synced 2025-06-21 00:45:18 +00:00

Can change user account image

This commit is contained in:
2021-01-19 18:27:56 +01:00
parent 364a98634f
commit e02c0ba2b9
3 changed files with 48 additions and 0 deletions

View File

@ -103,6 +103,7 @@ pub fn get_routes() -> Vec<Route> {
Route::post("/settings/check_password", Box::new(settings_controller::check_password)),
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)),
// Friends controller

View File

@ -142,4 +142,17 @@ pub fn get_account_image_settings(r: &mut HttpRequestHandler) -> RequestResult {
let user = user_helper::find_user_by_id(r.user_id_ref()?)?;
r.set_response(AccountImageSettingsAPI::new(&user))
}
/// 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())
}
let uri = r.save_post_image("picture", "avatars", 800, 800)?;
account_helper::set_account_image(r.user_id_ref()?, &uri)?;
r.success("Account image updated!")
}