∅:D[
2.682] → [
5.928:2045]
∅:D[
5.928] → [
5.928:2045]
∅:D[
5.2045] → [
2.683:825]
∅:D[
2.825] → [
5.2147:2182]
∅:D[
5.2147] → [
5.2147:2182]
.and_then(move |_msg: String| {
cmd_send
.clone()
.send(XmppCommand { xmpp_to })
.then(|r| match r {
Ok(_) => tokio::prelude::future::ok(Response::new(Body::from(
"Accepted",
))),
Err(e) => {
error!("Command sent error: {}", e);
tokio::prelude::future::result(
Response::builder()
.status(hyper::StatusCode::BAD_REQUEST)
.body(Body::from(format!(
"Command sent error: {}",
e
))),
)
}
})
.map_err(|e| {
Box::new(e)
as Box<dyn std::error::Error + Sync + Send + 'static>
})
.and_then(move |msg: String| {
if !msg.is_empty() {
Box::new(
cmd_send
.clone()
.send(XmppCommand { xmpp_to })
.then(|r| match r {
Ok(_) => tokio::prelude::future::ok(Response::new(
Body::from("Accepted"),
)),
Err(e) => {
error!("Command sent error: {}", e);
tokio::prelude::future::result(
Response::builder()
.status(hyper::StatusCode::BAD_REQUEST)
.body(Body::from(format!(
"Command sent error: {}",
e
))),
)
}
})
.map_err(|e| {
Box::new(e)
as Box<
dyn std::error::Error + Sync + Send + 'static,
>
}),
)
} else {
warn!("Empty message");
Box::new(tokio::prelude::future::result(
Response::builder()
.status(hyper::StatusCode::BAD_REQUEST)
.body(Body::from("Empty message"))
.map_err(|e| {
Box::new(e)
as Box<
dyn std::error::Error + Sync + Send + 'static,
>
}),
))
as Box<Future<Item = _, Error = _> + Send + 'static>
}