Adding optional limit field to /message/time_range handler

This commit is contained in:
shockrah 2021-01-23 15:14:57 -08:00
parent feef6104c6
commit 5a27ef07f1

View File

@ -31,9 +31,14 @@ pub async fn get_by_time(pool: &Pool, response: &mut Response<Body>, params: Val
Some(val) => val.as_i64(),
None => None
};
let limit = match params.get("limit") {
Some(val) => val.as_u64(),
None => None
};
// TODO: flatten me mommy
if let (Some(channel), Some(start), Some(end)) = (channel, start_time, end_time) {
match Message::get_time_range(pool, channel, start, end).await {
match Message::get_time_range(pool, channel, start, end, limit).await {
Ok(db_response) => {
match db_response {
db::Response::Set(messages) => {
@ -132,7 +137,6 @@ pub async fn from_id(pool: &Pool, response: &mut Response<Body>, params: Value)
None => None
};
// TODO: untested lmao
if let (Some(channel), Some(start_id)) = (channel, start_id) {
match Message::get_from_id(pool, channel, start_id, limit).await {
Ok(db_response) => {