summaryrefslogtreecommitdiff
path: root/src/channel
diff options
context:
space:
mode:
authorOwen Jacobson <owen@grimoire.ca>2024-09-14 00:16:51 -0400
committerOwen Jacobson <owen@grimoire.ca>2024-09-14 00:18:08 -0400
commit5249aad35741f6f029c442a04d679937fb91d2bb (patch)
treec75085a93538367ae3f5da8f64f90b33a3c8feef /src/channel
parent407ca8df6284ce1a4c649b018c7326fd195bbd26 (diff)
Placeholder UX, probably
Diffstat (limited to 'src/channel')
-rw-r--r--src/channel/repo/channels.rs16
-rw-r--r--src/channel/routes.rs3
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(