diff --git a/server/src/channels.rs b/server/src/channels.rs new file mode 100644 index 0000000..f3e53b5 --- /dev/null +++ b/server/src/channels.rs @@ -0,0 +1,32 @@ +/* + With this module we take care of getting all kinds of channel information out to the users + Base prefix is "/channels" +*/ +use diesel::{self, prelude::*}; +use rocket_contrib::json::Json; +use std::vec::Vec; +use crate::models::{Channel, VOICE_CHANNEL}; +use crate::DBConn; +use crate::schema; + + + +#[get("/voice")] +pub fn get_voice_channels(conn: DBConn) -> Json> { + use schema::channels::dsl::*; + + let result = channels.filter(type_.eq(VOICE_CHANNEL)).load(&conn.0); + if let Ok(data) = result { + Json(data) + } + else { + let bust = Channel { + id: -1, + name: "".to_string(), + permissions: 0, + limit: 0, + type_: 0, // the other fields are bs this is the only one that really mattesr + }; + Json(vec![bust]) + } +} \ No newline at end of file