B:BD[
2.159] → [
2.159:1148]
info!("Got message request. Reading body...");
let mut cmd_send = self.cmd_send.clone();
Box::pin(async move {
match body_to_string(req).await {
Ok(message) => {
match cmd_send.send(XmppCommand::Chat { xmpp_to, message }).await {
Ok(_) => Response::builder()
.body(Body::from(format!("Accepted")))
.map_err(std::convert::Into::into),
Err(e) => {
error!("Cann't send message command: {}", e);
Response::builder()
.status(hyper::StatusCode::BAD_REQUEST)
.body(Body::from(format!("Cann't get message text")))
.map_err(std::convert::Into::into)
if req.uri().path() == "/ping" {
info!("Got ping request");
let mut cmd_send = self.cmd_send.clone();
Box::pin(async move {
match cmd_send
.send(XmppCommand::Ping {
opt_xmpp_to: Some(xmpp_to),
})
.await
{
Ok(_) => Response::builder()
.body(Body::from(format!("Accepted")))
.map_err(std::convert::Into::into),
Err(e) => {
error!("Cann't send ping command: {}", e);
Response::builder()
.status(hyper::StatusCode::BAD_REQUEST)
.body(Body::from(format!("Cann't send ping")))
.map_err(std::convert::Into::into)
}
}
})
} else {
info!("Got message request. Reading body...");
let mut cmd_send = self.cmd_send.clone();
Box::pin(async move {
match body_to_string(req).await {
Ok(message) => {
match cmd_send.send(XmppCommand::Chat { xmpp_to, message }).await {
Ok(_) => Response::builder()
.body(Body::from(format!("Accepted")))
.map_err(std::convert::Into::into),
Err(e) => {
error!("Cann't send message command: {}", e);
Response::builder()
.status(hyper::StatusCode::BAD_REQUEST)
.body(Body::from(format!("Cann't get message text")))
.map_err(std::convert::Into::into)
}