Better management of text messages ( JSONize ) #24
Closed
arkanoider
started this conversation in
Ideas
Replies: 2 comments
-
|
That's right we need to fix this, current pub enum Content {
Order(NewOrder),
PaymentRequest(String),
PayHoldInvoice(NewOrder, String),
}We can make it better and rehuse variants like this pub enum Content {
Order(NewOrder),
PaymentRequest(Option<NewOrder>, String),
}So when user send a takesell message it should created it like this: let content = Some(Content::PaymentRequest(None, invoice.to_string()));
let message = Message::new(0, Some(order), Action::TakeSell, content)
.as_json()
.unwrap();When send a message to the seller with the hold invoice, it should be: let new_order = order.as_new_order();
let content = Some(Content::PaymentRequest(Some(new_order), hold_invoice.to_string()));
let message = Message::new(0, Some(order_id), Action::PayInvoice, content)
.as_json()
.unwrap();About pub enum Content {
Order(NewOrder),
PaymentRequest(Option<NewOrder>, String),
TextMessage(String),
} |
Beta Was this translation helpful? Give feedback.
0 replies
-
|
Closing this discussion via MostroP2P/mostro-cli#23 and #25 |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Create a new variant in Conten enum to Jsonize also text messages, to get nicer parsing options in CLI, this is what you did exactly for PayHoldInvoice message:
pub enum Content { Order(Order), PaymentRequest(String), PayHoldInvoice(Order, String), TextMessage(String), }this could be managed in a better way on CLI side in util.rs line line 76: I think we can eliminate the Err part, or using it for a real Err, than we can match agains differnent Content
Let me know boss!
Beta Was this translation helpful? Give feedback.
All reactions