diff options
| author | Owen Jacobson <owen@grimoire.ca> | 2024-09-11 19:14:22 -0400 |
|---|---|---|
| committer | Owen Jacobson <owen@grimoire.ca> | 2024-09-11 19:14:22 -0400 |
| commit | 4563f221bf61123b15f9608bb14e8f46db05e4f6 (patch) | |
| tree | 58a5ee7e0e14b918a332d4536dec06d4ad8367e8 /src/channel/routes.rs | |
| parent | 588a14848d4ac45f31ee8646555e1e21cca5595d (diff) | |
Remove the notion of "channel members."
This came out of a conversation with Kit. Their position, loosely, was that seeing scrollback when you look at a channel is useful, and since message delivery isn't meaningfully tied to membership (or at least doesn't have to be), what the hell is membership even doing? (I may have added that last part.)
My take, on top of that, is that membership increases the amount of concepts we're committed to. We don't need that commitment yet.
Diffstat (limited to 'src/channel/routes.rs')
| -rw-r--r-- | src/channel/routes.rs | 43 |
1 files changed, 5 insertions, 38 deletions
diff --git a/src/channel/routes.rs b/src/channel/routes.rs index 3dc2b1a..014a57b 100644 --- a/src/channel/routes.rs +++ b/src/channel/routes.rs @@ -1,19 +1,16 @@ use axum::{ - extract::{Form, Path, State}, + extract::{Form, State}, response::{IntoResponse, Redirect}, routing::post, Router, }; use sqlx::sqlite::SqlitePool; -use super::repo::{Id as ChannelId, Provider as _}; +use super::repo::Provider as _; use crate::{error::InternalError, login::repo::logins::Login}; pub fn router() -> Router<SqlitePool> { - Router::new() - .route("/create", post(on_create)) - .route("/join", post(on_join)) - .route("/:channel/leave", post(on_leave)) + Router::new().route("/create", post(on_create)) } #[derive(serde::Deserialize)] @@ -23,41 +20,11 @@ struct CreateRequest { async fn on_create( State(db): State<SqlitePool>, - login: Login, + _: Login, // requires auth, but doesn't actually care who you are Form(form): Form<CreateRequest>, ) -> Result<impl IntoResponse, InternalError> { let mut tx = db.begin().await?; - let channel = tx.channels().create(&form.name).await?; - tx.channels().join(&channel.id, &login.id).await?; - tx.commit().await?; - - Ok(Redirect::to("/")) -} - -#[derive(serde::Deserialize)] -struct JoinRequest { - channel: ChannelId, -} - -async fn on_join( - State(db): State<SqlitePool>, - login: Login, - Form(req): Form<JoinRequest>, -) -> Result<impl IntoResponse, InternalError> { - let mut tx = db.begin().await?; - tx.channels().join(&req.channel, &login.id).await?; - tx.commit().await?; - - Ok(Redirect::to("/")) -} - -async fn on_leave( - State(db): State<SqlitePool>, - login: Login, - Path(channel): Path<ChannelId>, -) -> Result<impl IntoResponse, InternalError> { - let mut tx = db.begin().await?; - tx.channels().leave(&channel, &login.id).await?; + tx.channels().create(&form.name).await?; tx.commit().await?; Ok(Redirect::to("/")) |
