use crate::error::ApiResult; use crate::model::space::{Space, SpaceDto}; use crate::model::space::Channel; use crate::repo::{SpaceRepo, ChannelRepo}; use rocket::serde::json::Json; use rocket::State; use std::sync::Arc; use crate::api::auth::Session; use crate::svc::chat_svc::ChatService; #[get("/spaces")] pub async fn list_spaces( space_repo: &State> ) -> ApiResult>> { let spaces = space_repo.get_all().await?; Ok(Json(spaces)) } #[get("/spaces//channels")] pub async fn list_channels( space_id: i64, channel_repo: &State> ) -> ApiResult>> { let channels = channel_repo.get_by_space_id(space_id).await?; Ok(Json(channels)) } #[get("/accessible_channels")] pub async fn get_accessible_channels( session: Session, svc: &State ) -> ApiResult>> { let space = svc.get_accessible_channels(session.uid).await?; println!("{:?}", space); Ok(Json(space)) }