summaryrefslogtreecommitdiff
path: root/src/channel/routes.rs
diff options
context:
space:
mode:
authorKit La Touche <kit@transneptune.net>2024-10-10 13:26:15 -0400
committerKit La Touche <kit@transneptune.net>2024-10-10 13:26:15 -0400
commit03f8d9ad603a4e523a0e2a0e60ad62c8725f0875 (patch)
treeb01543c0c2dadbd4be17320d47fc2e3d2fdb280d /src/channel/routes.rs
parentefae871b1bdb1e01081a44218281950cf0177f3b (diff)
parentd173bc08f2b699f58c8cca752ff688ad46f33ced (diff)
Merge branch 'main' into wip/path-routing-for-channels
Diffstat (limited to 'src/channel/routes.rs')
-rw-r--r--src/channel/routes.rs16
1 files changed, 10 insertions, 6 deletions
diff --git a/src/channel/routes.rs b/src/channel/routes.rs
index 5d67af8..e97c447 100644
--- a/src/channel/routes.rs
+++ b/src/channel/routes.rs
@@ -7,7 +7,13 @@ use axum::{
};
use super::{app, Channel, Id};
-use crate::{app::App, clock::RequestedAt, error::Internal, login::Login, message::app::SendError};
+use crate::{
+ app::App,
+ clock::RequestedAt,
+ error::{Internal, NotFound},
+ login::Login,
+ message::app::SendError,
+};
#[cfg(test)]
mod test;
@@ -56,7 +62,7 @@ impl IntoResponse for CreateError {
#[derive(Clone, serde::Deserialize)]
struct SendRequest {
- message: String,
+ body: String,
}
async fn on_send(
@@ -67,7 +73,7 @@ async fn on_send(
Json(request): Json<SendRequest>,
) -> Result<StatusCode, SendErrorResponse> {
app.messages()
- .send(&channel, &login, &sent_at, &request.message)
+ .send(&channel, &login, &sent_at, &request.body)
.await?;
Ok(StatusCode::ACCEPTED)
@@ -81,9 +87,7 @@ impl IntoResponse for SendErrorResponse {
fn into_response(self) -> Response {
let Self(error) = self;
match error {
- not_found @ SendError::ChannelNotFound(_) => {
- (StatusCode::NOT_FOUND, not_found.to_string()).into_response()
- }
+ not_found @ SendError::ChannelNotFound(_) => NotFound(not_found).into_response(),
other => Internal::from(other).into_response(),
}
}