diff --git a/json-api/src/messages.rs b/json-api/src/messages.rs index 2eef93c..2fd53cd 100644 --- a/json-api/src/messages.rs +++ b/json-api/src/messages.rs @@ -1,6 +1,7 @@ use mysql_async::Pool; use hyper::{Response, Body, HeaderMap, StatusCode}; use hyper::body::to_bytes; +use hyper::body::Bytes; use serde_json::json; use std::collections::HashMap; @@ -94,7 +95,7 @@ pub async fn send_message(pool: &Pool, response: &mut Response, body: Body let channel_id = qs_param!(params, "channel_id", u64); // Black magic - let body_bytes: &[u8] = &to_bytes(body).await.unwrap(); // yolo + let body_bytes: &[u8] = &to_bytes(body).await.unwrap_or(Bytes::new()); let content = String::from_utf8_lossy(body_bytes); // 400 on empty bodies or missing channel id's @@ -164,3 +165,4 @@ pub async fn recent_messages(pool: &Pool, response: &mut Response, params: } else { } } +