Checking for valid channel.kind
on /channels/create
This commit is contained in:
parent
8e2b52d1c9
commit
201297f4c1
@ -49,6 +49,11 @@ pub async fn create_channel(pool: &Pool, response: &mut Response<Body>, params:
|
||||
|
||||
match req_params {
|
||||
(Some(name), Some(desc), Some(kind)) => {
|
||||
use db::channels::{TEXT_CHANNEL, VOICE_CHANNEL};
|
||||
if kind < VOICE_CHANNEL as i64 || kind > TEXT_CHANNEL as i64 {
|
||||
*response.status_mut() = StatusCode::BAD_REQUEST; // restriciting to 1|2 for valid channel kinds
|
||||
}
|
||||
else {
|
||||
// Send the data up to the db, then return the new channel back to the user(?)
|
||||
match db::channels::Channel::add(pool, name, desc, kind.try_into().unwrap()).await {
|
||||
db::Response::Row(row) => {
|
||||
@ -65,6 +70,7 @@ pub async fn create_channel(pool: &Pool, response: &mut Response<Body>, params:
|
||||
}
|
||||
_ => *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR
|
||||
}
|
||||
}
|
||||
},
|
||||
// basically one of the parameter gets failed so we bail on all of this
|
||||
_ => *response.status_mut() = StatusCode::BAD_REQUEST
|
||||
|
Loading…
Reference in New Issue
Block a user