Skip to content

Commit 5dc45a6

Browse files
committed
fix: fixed from field in getdm command
1 parent 3b5747c commit 5dc45a6

File tree

3 files changed

+27
-27
lines changed

3 files changed

+27
-27
lines changed

β€Žsrc/cli/new_order.rsβ€Ž

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -164,18 +164,15 @@ pub async fn execute_new_order(
164164
));
165165
table.add_row(create_emoji_field_row(
166166
"πŸ”‘ ",
167-
"Trade Keys",
168-
&ctx.trade_keys.public_key().to_hex(),
167+
"Trade Key",
168+
&ctx.trade_keys.public_key.to_hex(),
169169
));
170170
table.add_row(create_emoji_field_row(
171171
"🎯 ",
172172
"Target",
173173
&ctx.mostro_pubkey.to_string(),
174174
));
175175

176-
println!("{table}");
177-
println!("πŸ’‘ Sending new order to Mostro...\n");
178-
179176
// Serialize the message
180177
let message_json = message
181178
.as_json()

β€Žsrc/cli/rate_user.rsβ€Ž

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -13,31 +13,26 @@ use crate::{
1313
};
1414

1515
// Get the user rate
16-
fn get_user_rate(rating: &u8) -> Result<Payload> {
16+
fn get_user_rate(rating: &u8, order_id: &Uuid) -> Result<Payload> {
1717
if let Some(rating) = RATING_BOUNDARIES.iter().find(|r| r == &rating) {
18+
print_section_header("⭐ Rate User");
19+
print_key_value("πŸ“‹", "Order ID", &order_id.to_string());
20+
print_key_value("⭐", "Rating", &format!("{}/5", rating));
21+
print_info_line("πŸ’‘", "Sending user rating...");
22+
println!();
1823
Ok(Payload::RatingUser(*rating))
1924
} else {
20-
Err(anyhow::anyhow!("Rating must be in the range 1 - 5"))
21-
}
22-
}
23-
24-
pub async fn execute_rate_user(order_id: &Uuid, rating: &u8, ctx: &Context) -> Result<()> {
25-
// Validate rating before proceeding
26-
if !RATING_BOUNDARIES.contains(rating) {
2725
print_section_header("❌ Invalid Rating");
2826
print_key_value("⭐", "Rating", &rating.to_string());
2927
print_info_line("πŸ’‘", "Rating must be between 1 and 5");
3028
print_info_line("πŸ“Š", "Valid ratings: 1, 2, 3, 4, 5");
31-
return Err(anyhow::anyhow!("Rating must be in the range 1 - 5"));
29+
Err(anyhow::anyhow!("Rating must be in the range 1 - 5"))
3230
}
33-
print_section_header("⭐ Rate User");
34-
print_key_value("πŸ“‹", "Order ID", &order_id.to_string());
35-
print_key_value("⭐", "Rating", &format!("{}/5", rating));
36-
print_info_line("πŸ’‘", "Sending user rating...");
37-
println!();
31+
}
3832

33+
pub async fn execute_rate_user(order_id: &Uuid, rating: &u8, ctx: &Context) -> Result<()> {
3934
// Check boundaries
40-
let rating_content = get_user_rate(rating)?;
35+
let rating_content = get_user_rate(rating, &order_id)?;
4136

4237
// Get the trade keys
4338
let trade_keys =

β€Žsrc/parser/dms.rsβ€Ž

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -757,7 +757,7 @@ pub async fn parse_dm_events(
757757
continue;
758758
}
759759

760-
let (created_at, message) = match dm.kind {
760+
let (created_at, message, sender) = match dm.kind {
761761
nostr_sdk::Kind::GiftWrap => {
762762
let unwrapped_gift = match nip59::extract_rumor(pubkey, dm).await {
763763
Ok(u) => u,
@@ -780,7 +780,12 @@ pub async fn parse_dm_events(
780780
continue;
781781
}
782782
};
783-
(unwrapped_gift.rumor.created_at, message)
783+
784+
(
785+
unwrapped_gift.rumor.created_at,
786+
message,
787+
unwrapped_gift.sender,
788+
)
784789
}
785790
nostr_sdk::Kind::PrivateDirectMessage => {
786791
let ck = if let Ok(ck) = ConversationKey::derive(pubkey.secret_key(), &dm.pubkey) {
@@ -813,7 +818,7 @@ pub async fn parse_dm_events(
813818
continue;
814819
}
815820
};
816-
(dm.created_at, message)
821+
(dm.created_at, message, dm.pubkey)
817822
}
818823
_ => continue,
819824
};
@@ -829,7 +834,7 @@ pub async fn parse_dm_events(
829834
continue;
830835
}
831836
}
832-
direct_messages.push((message, created_at.as_u64(), dm.pubkey));
837+
direct_messages.push((message, created_at.as_u64(), sender));
833838
}
834839
direct_messages.sort_by(|a, b| a.1.cmp(&b.1));
835840
direct_messages
@@ -876,14 +881,17 @@ pub async fn print_direct_messages(
876881
// From label: show 🧌 Mostro if matches provided pubkey
877882
let from_label = if let Some(pk) = mostro_pubkey {
878883
if *sender_pubkey == pk {
879-
format!("🧌 {}", sender_pubkey.to_hex())
884+
format!("🧌 {}", sender_pubkey.to_string())
880885
} else {
881-
sender_pubkey.to_hex()
886+
sender_pubkey.to_string()
882887
}
883888
} else {
884-
sender_pubkey.to_hex()
889+
sender_pubkey.to_string()
885890
};
886891

892+
println!("mostro pubkey : {}", mostro_pubkey.unwrap());
893+
println!("sender pubkey : {}", sender_pubkey);
894+
887895
// Print message header
888896
println!("πŸ“„ Message {}:", i + 1);
889897
println!("─────────────────────────────────────");

0 commit comments

Comments
Β (0)