Updating schemas to support content_type

This commit is contained in:
shockrah
2021-03-09 00:03:12 -08:00
parent ae675d000b
commit ddb08818b1
3 changed files with 6 additions and 7 deletions

View File

@@ -18,14 +18,14 @@ pub async fn list_channels(pool: &Pool, response: &mut Response<Body>, params: H
*/
// Default to filtering for text channels only
let chan_type = match qs_param!(params, "type", i32) {
let chan_type = match qs_param!(params, "kind", i32) {
Some(ctype) => ctype,
None => db::channels::TEXT_CHANNEL
};
match db::Channel::filter(pool, chan_type).await {
Ok(resp) => match resp {
db::Response::Set(channels) => set_json_body(response, json!(channels)),
db::Response::Set(channels) => set_json_body(response, json!({"channels": json!(channels)}) ),
_ => *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR
},
Err(e) => {
@@ -45,7 +45,7 @@ pub async fn create_channel(pool: &Pool, response: &mut Response<Body>, params:
use db::Response::*;
let name = params.get("name");
let kind = qs_param!(params, "type", i32);
let kind = qs_param!(params, "kind", i32);
let description = match params.get("description") {
Some(d) => d,
None => "No description"

View File

@@ -35,9 +35,7 @@ pub async fn get_by_time(pool: &Pool, response: &mut Response<Body>, params: Has
match db_response {
// this absolute lack of data streaming is prolly gonna suck like
// a whore in hell week for performance but lets pretend servers don't get massive
db::Response::Set(messages) => {
set_json_body(response, json!({"messages": messages}));
},
db::Response::Set(messages) => set_json_body(response, json!({"messages": messages})),
db::Response::RestrictedInput(_/*error message to log*/) => {
*response.status_mut() = StatusCode::BAD_REQUEST;
}