- Removing /messages/from_id as its no longer usable with the new id generation model

+ Adding new flags to sample .env file
+ Wrapper script run-api-tests.sh which does as its called
- Removing build.sh in favor of run-api-tests.sh
Makefile takes care of building, and apitests are ran with special script anyway
This commit is contained in:
shockrah
2021-04-20 12:09:05 -07:00
parent bb2201c00e
commit 52676cdd1f
6 changed files with 27 additions and 101 deletions

View File

@@ -76,7 +76,6 @@ async fn route_dispatcher(
/* MESSAGING */
(POST, routes::MESSAGE_SEND) => messages::send_message(pool, resp, body, headers, params).await,
(GET, routes::MESSAGE_TIME_RANGE) => messages::get_by_time(pool, resp, params).await,
(GET, routes::MESSAGE_FROM_ID) =>messages::from_id(pool, resp, params).await,
(GET, routes::MESSAGE_LAST_N) => messages::recent_messages(pool, resp, params).await,
/* ADMIN */
(POST, routes::SET_PERMS_BY_ADMIN) => admin::set_permissions(pool, resp, params).await,

View File

@@ -130,49 +130,6 @@ pub async fn send_message(pool: &Pool, response: &mut Response<Body>, body: Body
}
}
pub async fn from_id(pool: &Pool, response: &mut Response<Body>, params: HashMap<String, String>) {
/*
* @start-id: u64
* @limit: optional<u64>
* @channel: u64
* {
* "channel_id": 1,
* "start": 123,
* "limit": 100
* }
*/
let channel = qs_param!(params, "channel_id", u64);
let start_id = qs_param!(params, "start", u64);
let limit = qs_param!(params, "limit", u64);
if let (Some(channel), Some(start_id)) = (channel, start_id) {
match Message::get_from_id(pool, channel, start_id, limit).await {
Ok(db_response) => {
match db_response {
db::Response::Set(messages) => {
// *any* kind of empty response, even those from weird
// parameters get 404's
if messages.len() == 0 {
*response.status_mut() = StatusCode::NOT_FOUND;
} else {
set_json_body(response, json!({"messages": messages}));
}
},
_ => *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR
};
},
Err(err) => {
*response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
eprintln!("{}", err);
}
};
}
else {
*response.status_mut() = StatusCode::BAD_REQUEST;
}
}
pub async fn recent_messages(pool: &Pool, response: &mut Response<Body>, params: HashMap<String, String>) {
let limit = qs_param!(params, "limit", i32);
let channel_id = qs_param!(params, "channel_id", u64);

View File

@@ -12,7 +12,6 @@ pub const CHANNELS_DELETE: Rstr = "/channels/delete"; // requires @name perms:
pub const MESSAGE_SEND: Rstr = "/message/send"; // requires @content perms::MESSAGE_SEND
pub const MESSAGE_TIME_RANGE: Rstr = "/message/get_range"; // requires @channel(id) @start-time @end-time
pub const MESSAGE_FROM_ID: Rstr = "/message/from_id"; // requires @channel_id requires @start(id) @<optional>limit(1..1000)
pub const MESSAGE_LAST_N: Rstr = "/message/recent"; // requires @channel_id requires @limit(1..100)
pub const GET_ONLINE_MEMBERS: Rstr = "/members/get_online"; // requires none