✨ Updating schemas to support content_type
This commit is contained in:
parent
ae675d000b
commit
ddb08818b1
@ -2,7 +2,8 @@
|
||||
CREATE TABLE IF NOT EXISTS `messages`(
|
||||
`id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
`time` BIGINT NOT NULL,
|
||||
`content` VARCHAR(2048) NOT NULL,
|
||||
`content` VARCHAR(4096) NOT NULL,
|
||||
`content_type` VARCHAR NOT NULL,
|
||||
`author_id` BIGINT UNSIGNED NOT NULL,
|
||||
`channel_id` BIGINT UNSIGNED NOT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
|
@ -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"
|
||||
|
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user