1
0
mirror of https://gitlab.com/comunic/comunicapiv3 synced 2024-11-29 16:56:28 +00:00

Can change group's logo

This commit is contained in:
Pierre HUBERT 2020-06-26 10:53:05 +02:00
parent 7e53ced64d
commit 7cc4b94b55
2 changed files with 17 additions and 3 deletions

View File

@ -42,6 +42,9 @@ 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 /// 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"; pub const ERROR_ACCOUNT_IMAGE: &str = "avatars/0Red.png";
/// The path where groups logos should be stored
pub const PATH_GROUPS_LOGOS: &str = "groups_logo";
/// The group logo to use when no custom logo have been uploaded /// The group logo to use when no custom logo have been uploaded
pub const DEFAULT_GROUP_LOGO: &str = "groups_logo/default.png"; pub const DEFAULT_GROUP_LOGO: &str = "groups_logo/default.png";

View File

@ -8,7 +8,7 @@ use crate::api_data::advanced_group_api::AdvancedGroupApi;
use crate::api_data::group_api::GroupApi; use crate::api_data::group_api::GroupApi;
use crate::api_data::res_change_group_logo::ResChangeGroupLogo; use crate::api_data::res_change_group_logo::ResChangeGroupLogo;
use crate::api_data::res_create_group::GroupCreationResult; use crate::api_data::res_create_group::GroupCreationResult;
use crate::constants::DEFAULT_GROUP_LOGO; use crate::constants::{DEFAULT_GROUP_LOGO, PATH_GROUPS_LOGOS};
use crate::controllers::routes::RequestResult; use crate::controllers::routes::RequestResult;
use crate::data::group::{Group, GroupAccessLevel, GroupPostsCreationLevel, GroupRegistrationLevel, GroupVisibilityLevel}; use crate::data::group::{Group, GroupAccessLevel, GroupPostsCreationLevel, GroupRegistrationLevel, GroupVisibilityLevel};
use crate::data::group_id::GroupID; use crate::data::group_id::GroupID;
@ -123,8 +123,19 @@ pub fn check_virtual_dir(r: &mut HttpRequestHandler) -> RequestResult {
/// Change a group's logo /// Change a group's logo
pub fn upload_logo(r: &mut HttpRequestHandler) -> RequestResult { pub fn upload_logo(r: &mut HttpRequestHandler) -> RequestResult {
// TODO : implement this method let group_id = r.post_group_id_with_access("id", GroupAccessLevel::ADMIN_ACCESS)?;
r.success("implement me")
if !r.has_file("logo") {
r.bad_request("Did not receive logo!".to_string())?;
}
groups_helper::delete_logo(&group_id)?;
let logo_path = r.save_post_image("logo", PATH_GROUPS_LOGOS, 500, 500)?;
groups_helper::set_logo_path(&group_id, Some(logo_path.clone()))?;
r.set_response(ResChangeGroupLogo::new(&logo_path))
} }
/// Delete a group's logo /// Delete a group's logo