B:BD[
2.47989] → [
2.47989:49108]
(None, Ok(xmpp_to), _) => Box::pin(async {
Response::builder()
.status(hyper::StatusCode::BAD_REQUEST)
.body(Body::from(format!("SOON")))
.map_err(std::convert::Into::into)
}),
(Some(Ok(muc_id)), _, Ok(show)) => Box::pin(async {
Response::builder()
.status(hyper::StatusCode::BAD_REQUEST)
.body(Body::from(format!("SOON")))
.map_err(std::convert::Into::into)
}),
(Some(Ok(muc_id)), _, _) => Box::pin(async {
Response::builder()
.status(hyper::StatusCode::BAD_REQUEST)
.body(Body::from(format!("SOON")))
.map_err(std::convert::Into::into)
}),
(Some(Err(err)), _, _) => Box::pin(async {
Response::builder()
.status(hyper::StatusCode::BAD_REQUEST)
.body(Body::from(format!("SOON")))
.map_err(std::convert::Into::into)
}),
(Some(Ok(muc_id)), _, Ok(show)) => {
info!("Got chat presence 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::ChatroomPresence {
muc_id,
show,
message,
})
.await
{
Ok(_) => Response::builder()
.body(Body::from(format!("Accepted")))
.map_err(std::convert::Into::into),
Err(e) => {
error!("Cann't send chat presence command: {}", e);
Response::builder()
.status(hyper::StatusCode::BAD_REQUEST)
.body(Body::from(format!("Cann't get chat presence text")))
.map_err(std::convert::Into::into)
}
}
}
Err(e) => Response::builder()
.status(hyper::StatusCode::BAD_REQUEST)
.body(Body::from(format!("Cann't get chat presence text")))
.map_err(std::convert::Into::into),
}
})
}
(Some(Ok(muc_id)), _, _) => {
info!("Got chat 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::Chatroom { muc_id, message })
.await
{
Ok(_) => Response::builder()
.body(Body::from(format!("Accepted")))
.map_err(std::convert::Into::into),
Err(e) => {
error!("Cann't send chat message command: {}", e);
Response::builder()
.status(hyper::StatusCode::BAD_REQUEST)
.body(Body::from(format!("Cann't get chat message text")))
.map_err(std::convert::Into::into)
}
}
}
Err(e) => Response::builder()
.status(hyper::StatusCode::BAD_REQUEST)
.body(Body::from(format!("Cann't get chat message text")))
.map_err(std::convert::Into::into),
}
})
}
(Some(Err(err)), _, _) => {
warn!("Unknown destination: {}", err);
Box::pin(async move {
Response::builder()
.status(hyper::StatusCode::BAD_REQUEST)
.body(Body::from(format!("Unknown destination: {}", err,)))
.map_err(std::convert::Into::into)
})
}