1
0
mirror of https://gitlab.com/comunic/comunicapiv3 synced 2025-06-21 08:55:16 +00:00

Can delete a group's logo

This commit is contained in:
2020-06-26 10:35:54 +02:00
parent 8d6dc6365c
commit 539765d01c
6 changed files with 79 additions and 2 deletions

View File

@ -300,6 +300,30 @@ pub fn set_settings(g: &Group) -> ResultBoxError {
.exec()
}
/// Set a new path for a logo
pub fn set_logo_path(g: &GroupID, path: Option<String>) -> ResultBoxError {
database::UpdateInfo::new(GROUPS_LIST_TABLE)
.cond_group_id("id", g)
.set_opt_str("path_logo", path)
.exec()
}
/// Delete the logo of a group
pub fn delete_logo(g: &GroupID) -> ResultBoxError {
let group = get_info(g)?;
if !group.has_logo() {
return Ok(());
}
let logo_path = group.get_logo_sys_path();
if logo_path.exists() {
std::fs::remove_file(logo_path)?;
}
set_logo_path(g, None)
}
/// Turn a database entry into a group struct
fn db_to_group(row: &database::RowResult) -> ResultBoxError<Group> {
let group_id = row.get_group_id("id")?;