From ddb08818b13b80d87f4b57f6501ee0fb464e2b55 Mon Sep 17 00:00:00 2001 From: shockrah Date: Tue, 9 Mar 2021 00:03:12 -0800 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Updating=20schemas=20to=20support?= =?UTF-8?q?=20content=5Ftype?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- json-api/migrations/2020-07-06-022319_messages/up.sql | 3 ++- json-api/src/channels.rs | 6 +++--- json-api/src/messages.rs | 4 +--- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/json-api/migrations/2020-07-06-022319_messages/up.sql b/json-api/migrations/2020-07-06-022319_messages/up.sql index 8da352c..d5fa48f 100644 --- a/json-api/migrations/2020-07-06-022319_messages/up.sql +++ b/json-api/migrations/2020-07-06-022319_messages/up.sql @@ -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`), diff --git a/json-api/src/channels.rs b/json-api/src/channels.rs index 0236e43..122b44e 100644 --- a/json-api/src/channels.rs +++ b/json-api/src/channels.rs @@ -18,14 +18,14 @@ pub async fn list_channels(pool: &Pool, response: &mut Response, 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, 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" diff --git a/json-api/src/messages.rs b/json-api/src/messages.rs index c28d4fc..3452bfd 100644 --- a/json-api/src/messages.rs +++ b/json-api/src/messages.rs @@ -35,9 +35,7 @@ pub async fn get_by_time(pool: &Pool, response: &mut Response, 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; }