diff --git a/src/clients/mycelium_client.rs b/src/clients/mycelium_client.rs index 68b6f01..5417c8d 100644 --- a/src/clients/mycelium_client.rs +++ b/src/clients/mycelium_client.rs @@ -86,13 +86,13 @@ impl MyceliumClient { &self, id_hex: &str, ) -> Result { - let params = json!({ "id": id_hex }); - let body = self.jsonrpc("messageStatus", params).await?; + let params = json!(id_hex); + let body = self.jsonrpc("getMessageInfo", params).await?; let result = body.get("result").ok_or_else(|| { MyceliumClientError::InvalidResponse(format!("missing result in response: {body}")) })?; - // Accept both { status: "..."} and bare "..." - let status_str = if let Some(s) = result.get("status").and_then(|v| v.as_str()) { + // Accept both { state: "..."} and bare "..." + let status_str = if let Some(s) = result.get("state").and_then(|v| v.as_str()) { s.to_string() } else if let Some(s) = result.as_str() { s.to_string() @@ -101,18 +101,19 @@ impl MyceliumClient { "unexpected result shape: {result}" ))); }; - Self::map_status(&status_str).ok_or_else(|| { + let status = Self::map_status(&status_str).ok_or_else(|| { MyceliumClientError::InvalidResponse(format!("unknown status: {status_str}")) - }) + }); + tracing::info!(%id_hex, status = %status.as_ref().unwrap(), "queried messages status"); + status } fn map_status(s: &str) -> Option { match s { - "queued" => Some(TransportStatus::Queued), - "sent" => Some(TransportStatus::Sent), - "delivered" => Some(TransportStatus::Delivered), + "pending" => Some(TransportStatus::Queued), + "received" => Some(TransportStatus::Delivered), "read" => Some(TransportStatus::Read), - "failed" => Some(TransportStatus::Failed), + "aborted" => Some(TransportStatus::Failed), _ => None, } }