mirror of
https://gitlab.com/comunic/comunicapiv3
synced 2025-06-22 01:15:16 +00:00
Can delete a custom emoji
This commit is contained in:
@ -2,7 +2,10 @@
|
||||
//!
|
||||
//! @author Pierre Hubert
|
||||
|
||||
use std::path::PathBuf;
|
||||
|
||||
use crate::data::user::UserID;
|
||||
use crate::utils::user_data_utils::user_data_path;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct CustomEmoji {
|
||||
@ -10,4 +13,11 @@ pub struct CustomEmoji {
|
||||
pub user_id: UserID,
|
||||
pub shortcut: String,
|
||||
pub path: String,
|
||||
}
|
||||
|
||||
impl CustomEmoji {
|
||||
/// Get the system path pointing on this custom emoji
|
||||
pub fn sys_path(&self) -> PathBuf {
|
||||
user_data_path(self.path.as_ref())
|
||||
}
|
||||
}
|
@ -15,12 +15,13 @@ use crate::controllers::routes::RequestResult;
|
||||
use crate::data::api_client::APIClient;
|
||||
use crate::data::comment::Comment;
|
||||
use crate::data::config::conf;
|
||||
use crate::data::custom_emoji::CustomEmoji;
|
||||
use crate::data::error::{ExecError, ResultBoxError};
|
||||
use crate::data::group::GroupAccessLevel;
|
||||
use crate::data::group_id::GroupID;
|
||||
use crate::data::post::{Post, PostAccessLevel};
|
||||
use crate::data::user::UserID;
|
||||
use crate::helpers::{account_helper, api_helper, comments_helper, conversations_helper, friends_helper, groups_helper, movies_helper, posts_helper, user_helper, virtual_directory_helper};
|
||||
use crate::helpers::{account_helper, api_helper, comments_helper, conversations_helper, custom_emojies_helper, friends_helper, groups_helper, movies_helper, posts_helper, user_helper, virtual_directory_helper};
|
||||
use crate::helpers::virtual_directory_helper::VirtualDirType;
|
||||
use crate::utils::pdf_utils::is_valid_pdf;
|
||||
use crate::utils::string_utils::{check_emoji_code, check_string_before_insert, check_url, remove_html_nodes};
|
||||
@ -682,4 +683,20 @@ impl HttpRequestHandler {
|
||||
|
||||
Ok(emoji_shortcut)
|
||||
}
|
||||
|
||||
/// Get information about an emoji included in a POST request
|
||||
pub fn post_emoji_id(&mut self, field: &str) -> ResultBoxError<CustomEmoji> {
|
||||
let emoji_id = self.post_u64(field)?;
|
||||
|
||||
let info = self.ok_or_not_found(
|
||||
custom_emojies_helper::get_single(emoji_id),
|
||||
"Requested emoji not found!"
|
||||
)?;
|
||||
|
||||
if &info.user_id != self.user_id_ref()? {
|
||||
self.forbidden("You do not own this emoji!".to_string())?;
|
||||
}
|
||||
|
||||
Ok(info)
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user