Send ping to custom jid
[?]
Dec 9, 2020, 6:53 PM
GVI6M6SCKQ6AMWMEILSCWBSNHAFFBOUMOT5IQSFY6OSTHQCJGO5QCDependencies
Change contents
- replacement in src/main.rs at line 117
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)} - edit in src/main.rs at line 158
Err(e) => Response::builder().status(hyper::StatusCode::BAD_REQUEST).body(Body::from(format!("Cann't get message text"))).map_err(std::convert::Into::into), - replacement in src/main.rs at line 163
Err(e) => Response::builder().status(hyper::StatusCode::BAD_REQUEST).body(Body::from(format!("Cann't get message text"))).map_err(std::convert::Into::into),}})})}