1
0
mirror of https://gitlab.com/comunic/comunicapiv3 synced 2025-06-20 08:25: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

@ -2,9 +2,11 @@
//!
//! Group visibility level
use std::path::PathBuf;
use crate::constants::DEFAULT_GROUP_LOGO;
use crate::data::group_id::GroupID;
use crate::utils::user_data_utils::user_data_url;
use crate::utils::user_data_utils::{user_data_path, user_data_url};
#[allow(non_camel_case_types)]
#[derive(Eq, PartialEq, Hash, Debug)]
@ -125,6 +127,11 @@ pub struct Group {
}
impl Group {
/// Check out whether current group has a logo or not
pub fn has_logo(&self) -> bool {
self.logo.is_some()
}
/// Determine the path of the logo to use for this group
pub fn get_logo_path(&self) -> &str {
match &self.logo {
@ -137,6 +144,15 @@ impl Group {
pub fn get_logo_url(&self) -> String {
user_data_url(self.get_logo_path())
}
/// Get file access to the logo
pub fn get_logo_sys_path(&self) -> PathBuf {
if !self.has_logo() {
panic!("This group has no logo!")
}
user_data_path(self.logo.as_ref().unwrap().as_ref())
}
}
#[cfg(test)]