-
Notifications
You must be signed in to change notification settings - Fork 12
Aligning message management #144
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
5b090d9
feat: improving parsing functions
arkanoider 5ad663a
chore: going on to uniform message fetching calls
arkanoider fbe1c9a
chore: almost remove wait for dm function with fetch event
arkanoider ebe1bfc
chore: almost remove wait for dm function with fetch event
arkanoider 55c6d3f
chore: testing all patterns with new code
arkanoider 4fcb3bf
fix: some fixes on message management
arkanoider 29baccb
fix: added a check to avoid UNIQUE constraint error - now if an order…
arkanoider ac3f69b
feat: add invalid fiat currency managed
arkanoider 60e7638
chore: rabbit fixes
arkanoider 47ff00e
chore: rabbit fixes
arkanoider d9d356a
feat: added correct since time calculation for get dm command - impro…
arkanoider 807ce79
chore: added trade index number printout in new order and take order …
arkanoider 08ea97e
chore: rabbit improvement
arkanoider 07e4165
chore: rabbit improvement
arkanoider c55069e
chore: fix on rabbit improvements
arkanoider 275facf
fix: moved some logic parts in wait dm function to avoid issues with …
arkanoider 61636b1
feat: first testable mostro cli version with last_trade_index command…
arkanoider 39f4b26
feat: improved reception logic and small fix for last trade index
arkanoider 51f8588
chore: updateded README.md
arkanoider 6301df0
chore: fix by rabbit
arkanoider 6bc8f73
feat: fixed some wrong key in decryption
arkanoider a3be582
chore: fix for clippy gh actions
arkanoider 4edef4d
chore: fix in README.md
arkanoider File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| use anyhow::Result; | ||
| use mostro_core::prelude::*; | ||
| use nostr_sdk::prelude::*; | ||
|
|
||
| use crate::{ | ||
| cli::Context, | ||
| parser::{dms::print_commands_results, parse_dm_events}, | ||
| util::{send_dm, wait_for_dm}, | ||
| }; | ||
|
|
||
| pub async fn execute_last_trade_index( | ||
| identity_keys: &Keys, | ||
| mostro_key: PublicKey, | ||
| ctx: &Context, | ||
| ) -> Result<()> { | ||
| let kind = MessageKind::new(None, None, None, Action::LastTradeIndex, None); | ||
| let last_trade_index_message = Message::Restore(kind); | ||
| let message_json = last_trade_index_message | ||
| .as_json() | ||
| .map_err(|_| anyhow::anyhow!("Failed to serialize message"))?; | ||
|
|
||
| // Send the last trade index message to Mostro server | ||
| let sent_message = send_dm( | ||
| &ctx.client, | ||
| Some(identity_keys), | ||
| identity_keys, | ||
| &mostro_key, | ||
| message_json, | ||
| None, | ||
| false, | ||
| ); | ||
|
|
||
| // Log the sent message | ||
| println!( | ||
| "Sent request to Mostro to get last trade index of user {}", | ||
| identity_keys.public_key() | ||
| ); | ||
|
|
||
| // Wait for incoming DM | ||
| let recv_event = wait_for_dm(ctx, Some(identity_keys), sent_message).await?; | ||
|
|
||
| // Parse the incoming DM | ||
| let messages = parse_dm_events(recv_event, identity_keys, None).await; | ||
| if let Some((message, _, _)) = messages.first() { | ||
| let message = message.get_inner_message_kind(); | ||
| if message.action == Action::LastTradeIndex { | ||
| print_commands_results(message, None, ctx).await? | ||
| } else { | ||
| return Err(anyhow::anyhow!( | ||
| "Received response with mismatched action. Expected: {:?}, Got: {:?}", | ||
| Action::LastTradeIndex, | ||
| message.action | ||
| )); | ||
| } | ||
| } else { | ||
| return Err(anyhow::anyhow!("No response received from Mostro")); | ||
| } | ||
|
|
||
| Ok(()) | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix borrow when calling
execute_get_dmexecute_get_dmnow takes&i64. Passingsinceby value won’t compile (expected &i64, found i64). Borrow it at both call sites.📝 Committable suggestion
🤖 Prompt for AI Agents
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since is passed correctly also the:
cargo clippy --all-targets --all-features -- -D warnings
command is happy!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
Length of output: 482
@arkanoider, thank you for confirming! Just to be clear: the diff shown above passes
sinceby value (without the&), butexecute_get_dmexpects&i64. If you've already added the borrow operator (&since) in your local code and clippy is happy, that's perfect! ✅If you haven't applied the fix yet, you'll need to change both call sites to:
execute_get_dm(&since, false, from_user, ctx).awaitexecute_get_dm(&since, true, from_user, ctx).awaitOnce that's done, the types will align correctly and clippy will pass.
🐰
🧬 Code Graph Analysis Results
[src/cli/adm_send_dm.rs:6-17]
[src/cli/conversation_key.rs:5-17]
[src/cli/list_disputes.rs:7-21]
[src/cli/restore.rs:7-32]
[src/cli/dm_to_user.rs:7-33]
[src/cli/get_dm.rs:10-38]
[src/cli/send_dm.rs:8-47]
[src/cli/rate_user.rs:19-59]
[src/cli/list_orders.rs:9-72]
[src/cli/take_order.rs:54-124]
[src/cli/add_invoice.rs:12-84]
[src/cli/take_dispute.rs:64-85]
[src/cli/take_dispute.rs:7-26]
[src/cli/take_dispute.rs:47-62]
[src/cli/add_invoice.rs:12-84]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes but since is yet a reference coming from cli command no need to reference it again
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
Length of output: 508
🏁 Script executed:
Length of output: 1710
@arkanoider, I understand the confusion, but there's actually a type mismatch here. Let me clarify:
When you pattern match on
Commands::GetDm { since, from_user }, thesincevariable is an ownedi64value (not a reference), because the enum field is defined as:However,
execute_get_dmexpects a reference:So when you call
execute_get_dm(since, ...), you're passing ani64where an&i64is expected. This is a type error in Rust.You need to borrow
sinceat the call sites:If your local code compiles without the
&, then you might have already made this fix locally, or perhaps you've modified the function signature to accepti64instead of&i64. Could you double-check what you have locally?🐰
🧬 Code Graph Analysis Results