Properly encode topic in mycelium rpc
Signed-off-by: Lee Smet <lee.smet@hotmail.com>
This commit is contained in:
@@ -104,6 +104,10 @@ impl SupervisorClient {
|
|||||||
Ok(BASE64_STANDARD.encode(s.as_bytes()))
|
Ok(BASE64_STANDARD.encode(s.as_bytes()))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn encode_topic(topic: &[u8]) -> String {
|
||||||
|
BASE64_STANDARD.encode(topic)
|
||||||
|
}
|
||||||
|
|
||||||
fn extract_message_id_from_result(result: &Value) -> Option<String> {
|
fn extract_message_id_from_result(result: &Value) -> Option<String> {
|
||||||
// Two possibilities per Mycelium spec oneOf:
|
// Two possibilities per Mycelium spec oneOf:
|
||||||
// - PushMessageResponseId: { "id": "0123456789abcdef" }
|
// - PushMessageResponseId: { "id": "0123456789abcdef" }
|
||||||
@@ -120,7 +124,12 @@ impl SupervisorClient {
|
|||||||
let payload_b64 = Self::encode_payload(&inner)?;
|
let payload_b64 = Self::encode_payload(&inner)?;
|
||||||
let result = self
|
let result = self
|
||||||
.mycelium
|
.mycelium
|
||||||
.push_message(&self.destination, &self.topic, &payload_b64, None)
|
.push_message(
|
||||||
|
&self.destination,
|
||||||
|
&Self::encode_topic(self.topic.as_bytes()),
|
||||||
|
&payload_b64,
|
||||||
|
None,
|
||||||
|
)
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
if let Some(id) = MyceliumClient::extract_message_id_from_result(&result) {
|
if let Some(id) = MyceliumClient::extract_message_id_from_result(&result) {
|
||||||
|
Reference in New Issue
Block a user