diff --git a/src/app/rate_user.rs b/src/app/rate_user.rs index 8aaacfa..c615d2b 100644 --- a/src/app/rate_user.rs +++ b/src/app/rate_user.rs @@ -3,7 +3,7 @@ use crate::util::{send_dm, update_user_rating_event}; use anyhow::Result; use log::{error, info}; use mostro_core::order::Order; -use mostro_core::{Action, Content, Message, Rating}; +use mostro_core::{Action, Content, Message, Rating,NOSTR_REPLACEABLE_EVENT_KIND}; use nostr_sdk::prelude::*; use sqlx::{Pool, Sqlite}; use sqlx_crud::Crud; @@ -90,7 +90,6 @@ pub async fn get_nip_33_event( let mut notifications = client.notifications(); let mut ev = None; - while let Ok(notification) = notifications.recv().await { if let RelayPoolNotification::Message(_, msg) = notification { match msg { @@ -130,7 +129,7 @@ pub async fn get_counterpart_reputation( let filter = Filter::new() .author(my_keys.public_key().to_string()) - .kind(Kind::Custom(30000)) + .kind(Kind::Custom(NOSTR_REPLACEABLE_EVENT_KIND)) .identifier(user.to_string()); println!("Filter : {:?}", filter); let event_nip33 = send_relays_requests(client, filter).await; diff --git a/src/util.rs b/src/util.rs index 2f7bbe5..75d2f3f 100644 --- a/src/util.rs +++ b/src/util.rs @@ -9,7 +9,7 @@ use crate::{db, flow}; use anyhow::{Context, Result}; use log::{error, info}; use mostro_core::order::{NewOrder, Order, SmallOrder}; -use mostro_core::{Action, Content, Kind as OrderKind, Message, Status}; +use mostro_core::{Action, Content, Kind as OrderKind, Message, Status, NOSTR_REPLACEABLE_EVENT_KIND}; use nostr_sdk::prelude::*; use sqlx::SqlitePool; use sqlx::{Pool, Sqlite}; @@ -108,7 +108,6 @@ pub async fn publish_order( let order_string = order.as_json().unwrap(); info!("serialized order: {order_string}"); // This tag (nip33) allows us to change this event in particular in the future - let event_kind = 30000; let d_tag = Tag::Generic(TagKind::Custom("d".to_string()), vec![order_id.to_string()]); // This tag helps client to subscribe to sell/buy order type notifications let k_tag = Tag::Generic( @@ -121,7 +120,7 @@ pub async fn publish_order( vec![order.fiat_code.clone()], ); let event = EventBuilder::new( - Kind::Custom(event_kind as u64), + Kind::Custom(NOSTR_REPLACEABLE_EVENT_KIND), &order_string, &[d_tag, k_tag, f_tag], ) @@ -195,9 +194,8 @@ pub async fn update_user_rating_event( ) -> Result<()> { // let reputation = reput // nip33 kind and d tag - let event_kind = 30000; let d_tag = Tag::Generic(TagKind::Custom("d".to_string()), vec![user.to_string()]); - let event = EventBuilder::new(Kind::Custom(event_kind), reputation, &[d_tag]).to_event(keys)?; + let event = EventBuilder::new(Kind::Custom(NOSTR_REPLACEABLE_EVENT_KIND), reputation, &[d_tag]).to_event(keys)?; info!("Sending replaceable event: {event:#?}"); // We update the order vote status if buyer_sent_rate { @@ -239,10 +237,9 @@ pub async fn update_order_event( ); let order_string = publish_order.as_json()?; // nip33 kind and d tag - let event_kind = 30000; let d_tag = Tag::Generic(TagKind::Custom("d".to_string()), vec![order.id.to_string()]); let event = - EventBuilder::new(Kind::Custom(event_kind), &order_string, &[d_tag]).to_event(keys)?; + EventBuilder::new(Kind::Custom(NOSTR_REPLACEABLE_EVENT_KIND), &order_string, &[d_tag]).to_event(keys)?; let event_id = event.id.to_string(); let status_str = status.to_string(); info!("Sending replaceable event: {event:#?}");