sample function to grab all the voice channels
This commit is contained in:
parent
7c2e1abbc3
commit
ce4ef515bd
32
server/src/channels.rs
Normal file
32
server/src/channels.rs
Normal file
@ -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<Vec<Channel>> {
|
||||||
|
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])
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user