diff options
Diffstat (limited to 'src/channel')
| -rw-r--r-- | src/channel/repo/channels.rs | 16 | ||||
| -rw-r--r-- | src/channel/routes.rs | 3 |
2 files changed, 17 insertions, 2 deletions
diff --git a/src/channel/repo/channels.rs b/src/channel/repo/channels.rs index 6fb0c23..fc52aa3 100644 --- a/src/channel/repo/channels.rs +++ b/src/channel/repo/channels.rs @@ -44,6 +44,22 @@ impl<'c> Channels<'c> { Ok(channel) } + pub async fn by_id(&mut self, channel: Id) -> Result<Channel, BoxedError> { + let channel = sqlx::query_as!( + Channel, + r#" + select id as "id: Id", name + from channel + where id = $1 + "#, + channel, + ) + .fetch_one(&mut *self.0) + .await?; + + Ok(channel) + } + pub async fn all(&mut self) -> Result<Vec<Channel>, BoxedError> { let channels = sqlx::query_as!( Channel, diff --git a/src/channel/routes.rs b/src/channel/routes.rs index 4f83a8b..eae68a2 100644 --- a/src/channel/routes.rs +++ b/src/channel/routes.rs @@ -1,6 +1,5 @@ use axum::{ extract::{Form, Path, State}, - http::StatusCode, response::{ sse::{self, Sse}, IntoResponse, Redirect, @@ -59,7 +58,7 @@ async fn on_send( .send(&login, &channel, &form.message, &sent_at) .await?; - Ok(StatusCode::ACCEPTED) + Ok(Redirect::to(&format!("/{}", channel))) } async fn on_events( |
