1 use crate::PerformCrud;
2 use actix_web::web::Data;
3 use lemmy_api_common::{
5 custom_emoji::{DeleteCustomEmoji, DeleteCustomEmojiResponse},
6 utils::{is_admin, local_user_view_from_jwt},
8 use lemmy_db_schema::source::custom_emoji::CustomEmoji;
9 use lemmy_utils::{error::LemmyError, ConnectionId};
11 #[async_trait::async_trait(?Send)]
12 impl PerformCrud for DeleteCustomEmoji {
13 type Response = DeleteCustomEmojiResponse;
15 #[tracing::instrument(skip(self, context, _websocket_id))]
18 context: &Data<LemmyContext>,
19 _websocket_id: Option<ConnectionId>,
20 ) -> Result<DeleteCustomEmojiResponse, LemmyError> {
21 let data: &DeleteCustomEmoji = self;
22 let local_user_view = local_user_view_from_jwt(&data.auth, context).await?;
24 // Make sure user is an admin
25 is_admin(&local_user_view)?;
26 CustomEmoji::delete(context.pool(), data.id).await?;
27 Ok(DeleteCustomEmojiResponse {