diff --git a/json-api/.gitignore b/json-api/.gitignore index ab93e56..40cb63d 100644 --- a/json-api/.gitignore +++ b/json-api/.gitignore @@ -10,3 +10,6 @@ diesel.toml # Client pycache client-tests/__pycache__/ client-tests/web/__pycache__/ + +# Admin things +msg diff --git a/json-api/src/messages.rs b/json-api/src/messages.rs index dd599cb..5b233a5 100644 --- a/json-api/src/messages.rs +++ b/json-api/src/messages.rs @@ -125,9 +125,10 @@ pub async fn recent_messages(pool: &Pool, response: &mut Response, params: let limit = qs_param!(params, "limit", i32); let channel_id = qs_param!(params, "channel_id", u64); - if channel_id.is_some() && limit.is_some() { + if let (Some(channel_id), Some(limit)) = (channel_id, limit) { + println!("channel_id: {}", channel_id); // NOTE: using match here to capture+log the error from the database - match Message::last_n(pool, limit.unwrap(), channel_id.unwrap()).await { + match Message::last_n(pool, limit, channel_id).await { Ok(dbresp) => { match dbresp { // 200 @@ -150,6 +151,7 @@ pub async fn recent_messages(pool: &Pool, response: &mut Response, params: } } } else { + *response.status_mut() = StatusCode::BAD_REQUEST; } }