Send ping to custom jid

[?]
Dec 9, 2020, 6:53 PM
GVI6M6SCKQ6AMWMEILSCWBSNHAFFBOUMOT5IQSFY6OSTHQCJGO5QC

Dependencies

Change contents

  • replacement in src/main.rs at line 117
    [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)
    [2.159]
    [2.1148]
    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
    [2.1212]
    [2.1212]
    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
    [2.1238][2.1238:1442](),[2.1442][3.47870:47975](),[3.47870][3.47870:47975]()
    Err(e) => Response::builder()
    .status(hyper::StatusCode::BAD_REQUEST)
    .body(Body::from(format!("Cann't get message text")))
    .map_err(std::convert::Into::into),
    }
    })
    [2.1238]
    [3.47975]
    })
    }