From 4563f221bf61123b15f9608bb14e8f46db05e4f6 Mon Sep 17 00:00:00 2001 From: Owen Jacobson Date: Wed, 11 Sep 2024 19:14:22 -0400 Subject: 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. --- src/channel/routes.rs | 43 +++++-------------------------------------- 1 file changed, 5 insertions(+), 38 deletions(-) (limited to 'src/channel/routes.rs') 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 { - 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, - login: Login, + _: Login, // requires auth, but doesn't actually care who you are Form(form): Form, ) -> Result { 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, - login: Login, - Form(req): Form, -) -> Result { - 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, - login: Login, - Path(channel): Path, -) -> Result { - 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("/")) -- cgit v1.2.3