mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-11-24 05:11:18 +00:00
Nutomic
3565ad984a
* Remove chatserver * fix clippy * Remove captchas (fixes #2922) * fix prettier * fix api_common build * cargo fmt
31 lines
928 B
Rust
31 lines
928 B
Rust
use crate::PerformCrud;
|
|
use actix_web::web::Data;
|
|
use lemmy_api_common::{
|
|
context::LemmyContext,
|
|
custom_emoji::{DeleteCustomEmoji, DeleteCustomEmojiResponse},
|
|
utils::{is_admin, local_user_view_from_jwt},
|
|
};
|
|
use lemmy_db_schema::source::custom_emoji::CustomEmoji;
|
|
use lemmy_utils::error::LemmyError;
|
|
|
|
#[async_trait::async_trait(?Send)]
|
|
impl PerformCrud for DeleteCustomEmoji {
|
|
type Response = DeleteCustomEmojiResponse;
|
|
|
|
#[tracing::instrument(skip(self, context))]
|
|
async fn perform(
|
|
&self,
|
|
context: &Data<LemmyContext>,
|
|
) -> Result<DeleteCustomEmojiResponse, LemmyError> {
|
|
let data: &DeleteCustomEmoji = self;
|
|
let local_user_view = local_user_view_from_jwt(&data.auth, context).await?;
|
|
|
|
// Make sure user is an admin
|
|
is_admin(&local_user_view)?;
|
|
CustomEmoji::delete(context.pool(), data.id).await?;
|
|
Ok(DeleteCustomEmojiResponse {
|
|
id: data.id,
|
|
success: true,
|
|
})
|
|
}
|
|
}
|