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:
@ -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)]
|
||||
|
Reference in New Issue
Block a user