Skip to content

Commit

Permalink
improved format of rating tag in new order event
Browse files Browse the repository at this point in the history
  • Loading branch information
arkanoider committed Jun 8, 2024
1 parent 62b3261 commit 4501273
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
11 changes: 7 additions & 4 deletions src/nip33.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use crate::Settings;
use chrono::Duration;
use mostro_core::order::{Order, Status};
use mostro_core::NOSTR_REPLACEABLE_EVENT_KIND;
use mostro_core::rating::Rating;
use mostro_core::NOSTR_REPLACEABLE_EVENT_KIND;
use nostr::event::builder::Error;
use nostr_sdk::prelude::*;

Expand Down Expand Up @@ -38,10 +38,13 @@ pub fn new_event(
EventBuilder::new(Kind::Custom(NOSTR_REPLACEABLE_EVENT_KIND), content, tags).to_event(keys)
}


fn create_rating_string(rating: Option<Rating>) -> String {
if rating.is_some() {
format!("{:?}", rating.unwrap(),)
if let Some(rating) = rating {
if let Ok(rating_json) = rating.as_json() {
rating_json
} else {
"bad format value".to_string()
}
} else {
"none".to_string()
}
Expand Down
2 changes: 1 addition & 1 deletion src/util.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::cli::settings::Settings;
use crate::app::rate_user::get_user_reputation;
use crate::cli::settings::Settings;
use crate::db;
use crate::error::MostroError;
use crate::flow;
Expand Down

0 comments on commit 4501273

Please sign in to comment.