summaryrefslogtreecommitdiff
path: root/src/message
diff options
context:
space:
mode:
authorKit La Touche <kit@transneptune.net>2024-10-25 22:16:03 -0400
committerKit La Touche <kit@transneptune.net>2024-10-25 22:16:03 -0400
commita50911a03c8955e08c77b0f3764dbda963013971 (patch)
tree9f5319191438b85b860ba06c9a203d3f129072a1 /src/message
parent4c49283553f4b18bb2a74de280b340a073e3253e (diff)
parentc87b5c53077c02bf21234e24bf976aa7a5f2bac8 (diff)
Merge branch 'main' into wip/mobile
Diffstat (limited to 'src/message')
-rw-r--r--src/message/routes/message/mod.rs21
-rw-r--r--src/message/routes/message/test.rs7
2 files changed, 18 insertions, 10 deletions
diff --git a/src/message/routes/message/mod.rs b/src/message/routes/message/mod.rs
index 545ad26..45a7e9d 100644
--- a/src/message/routes/message/mod.rs
+++ b/src/message/routes/message/mod.rs
@@ -3,9 +3,9 @@ mod test;
pub mod delete {
use axum::{
- extract::{Path, State},
+ extract::{Json, Path, State},
http::StatusCode,
- response::{IntoResponse, Response},
+ response::{self, IntoResponse},
};
use crate::{
@@ -21,10 +21,21 @@ pub mod delete {
Path(message): Path<message::Id>,
RequestedAt(deleted_at): RequestedAt,
_: Identity,
- ) -> Result<StatusCode, Error> {
+ ) -> Result<Response, Error> {
app.messages().delete(&message, &deleted_at).await?;
- Ok(StatusCode::ACCEPTED)
+ Ok(Response { id: message })
+ }
+
+ #[derive(Debug, serde::Serialize)]
+ pub struct Response {
+ pub id: message::Id,
+ }
+
+ impl IntoResponse for Response {
+ fn into_response(self) -> response::Response {
+ (StatusCode::ACCEPTED, Json(self)).into_response()
+ }
}
#[derive(Debug, thiserror::Error)]
@@ -32,7 +43,7 @@ pub mod delete {
pub struct Error(#[from] pub DeleteError);
impl IntoResponse for Error {
- fn into_response(self) -> Response {
+ fn into_response(self) -> response::Response {
let Self(error) = self;
#[allow(clippy::match_wildcard_for_single_variants)]
match error {
diff --git a/src/message/routes/message/test.rs b/src/message/routes/message/test.rs
index 2016fb8..ae89506 100644
--- a/src/message/routes/message/test.rs
+++ b/src/message/routes/message/test.rs
@@ -1,7 +1,4 @@
-use axum::{
- extract::{Path, State},
- http::StatusCode,
-};
+use axum::extract::{Path, State};
use super::delete;
use crate::{message::app, test::fixtures};
@@ -29,7 +26,7 @@ pub async fn delete_message() {
// Verify the response
- assert_eq!(response, StatusCode::ACCEPTED);
+ assert_eq!(message.id, response.id);
// Verify the semantics