pub mod delete { use axum::{ extract::{Path, State}, http::StatusCode, response::{IntoResponse, Response}, }; use crate::{ app::App, clock::RequestedAt, error::{Internal, NotFound}, login::Login, message::{self, app::DeleteError}, }; pub async fn handler( State(app): State, Path(message): Path, RequestedAt(deleted_at): RequestedAt, _: Login, ) -> Result { app.messages().delete(&message, &deleted_at).await?; Ok(StatusCode::ACCEPTED) } #[derive(Debug, thiserror::Error)] #[error(transparent)] pub struct Error(#[from] pub DeleteError); impl IntoResponse for Error { fn into_response(self) -> Response { let Self(error) = self; #[allow(clippy::match_wildcard_for_single_variants)] match error { DeleteError::ChannelNotFound(_) | DeleteError::NotFound(_) | DeleteError::Deleted(_) => NotFound(error).into_response(), other => Internal::from(other).into_response(), } } } }