WIP: servers and channels #9

Draft
radical wants to merge 28 commits from wip/messaging into main
2 changed files with 6 additions and 5 deletions
Showing only changes of commit 358a7f8336 - Show all commits

View file

@ -25,7 +25,7 @@ struct Channel {
impl Channel { impl Channel {
async fn fetch_all(pool: &Pool<Postgres>, guild_uuid: Uuid) -> Result<Vec<Self>, HttpResponse> { async fn fetch_all(pool: &Pool<Postgres>, guild_uuid: Uuid) -> Result<Vec<Self>, HttpResponse> {
let row = sqlx::query_as(&format!("SELECT uuid, name, description FROM channels WHERE guild_uuid = '{}'", guild_uuid)) let row = sqlx::query_as(&format!("SELECT CAST(uuid AS VARCHAR), name, description FROM channels WHERE guild_uuid = '{}'", guild_uuid))
.fetch_all(pool) .fetch_all(pool)
.await; .await;
@ -40,7 +40,7 @@ impl Channel {
let futures = channels.iter().map(async |t| { let futures = channels.iter().map(async |t| {
let (uuid, name, description) = t.to_owned(); let (uuid, name, description) = t.to_owned();
let row = sqlx::query_as(&format!("SELECT role_uuid, permissions FROM channel_permissions WHERE channel_uuid = '{}'", uuid)) let row = sqlx::query_as(&format!("SELECT CAST(role_uuid AS VARCHAR), permissions FROM channel_permissions WHERE channel_uuid = '{}'", uuid))
.fetch_all(pool) .fetch_all(pool)
.await; .await;

View file

@ -30,12 +30,13 @@ struct Role {
} }
pub fn web() -> Scope { pub fn web() -> Scope {
web::scope("/") web::scope("")
.service(res)
.service(channels::response) .service(channels::response)
.service(res)
} }
#[get("{uuid}")] #[get("/{uuid}")]
pub async fn res(req: HttpRequest, path: web::Path<(Uuid,)>, data: web::Data<Data>) -> Result<HttpResponse, Error> { pub async fn res(req: HttpRequest, path: web::Path<(Uuid,)>, data: web::Data<Data>) -> Result<HttpResponse, Error> {
let headers = req.headers(); let headers = req.headers();