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; }