Skip to content

New user or privacy order send same user info with zeros#471

Merged
grunch merged 3 commits into
developfrom
feature-privacy-order-event
Apr 3, 2025
Merged

New user or privacy order send same user info with zeros#471
grunch merged 3 commits into
developfrom
feature-privacy-order-event

Conversation

@arkanoider

@arkanoider arkanoider commented Apr 2, 2025

Copy link
Copy Markdown
Collaborator

@Catrya ,

this should be quite easy, when you are available please test.

Now new order event from a new user or a privacy order should have the same ratings values filled with zeros.

Summary by CodeRabbit

  • Bug Fixes

    • Enhanced order processing to better handle cases where user details are missing by applying consistent default parameters. This update improves the stability and reliability of order tagging, ensuring smoother operations when associated user data is not available.
  • New Features

    • Improved error logging throughout the application for better monitoring and debugging.
    • Enhanced clarity in logging messages related to order assignments and expirations.
    • Added contextual information to dispute handling by including order status in dispute creation.
  • Refactor

    • Updated the handling of reputation data to ensure accurate JSON output and improved maintainability by using constants for indexing.
    • Improved logging mechanisms across various functions for structured and clear log messages.

@coderabbitai

coderabbitai Bot commented Apr 2, 2025

Copy link
Copy Markdown
Contributor

Walkthrough

This change updates the get_tags_for_new_order function in src/util.rs. When a user is not found in the database, instead of passing None to the order_to_tags function, the function now passes Some((0.0, 0, 0)). The error handling for mismatches between identity and trade public keys remains unchanged. Additionally, error logging in src/app.rs, src/db.rs, and src/scheduler.rs has been improved by replacing println! statements with structured logging using the tracing crate. The create_rating_tag function in src/nip33.rs has been modified to handle reputation data more robustly.

Changes

File Change Summary
src/util.rs Modified get_tags_for_new_order to pass Some((0.0, 0, 0)) to order_to_tags instead of None when the user is not found in the database.
src/app.rs Replaced println! with tracing::warn! for error logging in the run function, improving error reporting.
src/db.rs Changed logging in is_assigned_solver from println! to tracing::info!, enhancing log clarity.
src/nip33.rs Updated create_rating_tag to include conditional checks for reputation_data and modified JSON structure handling. Added constant RATING_TAG_INDEX.
src/scheduler.rs Changed logging in job_expire_pending_older_orders from println! to tracing::info! for improved log formatting.
src/app/dispute.rs Modified instantiation of Dispute in dispute_action to include order.status.clone() for enhanced context.

Possibly related PRs

  • Privacy range order fix #468: The changes in the main PR, specifically the modification of the get_tags_for_new_order function, are related to the order_to_tags function, which is also referenced in the retrieved PR's changes to the create_order_event function, indicating a direct connection in their functionality.
  • Cosmetics #384: The changes in the main PR, specifically the modifications to the order_to_tags function in src/nip33.rs, are related to those in the retrieved PR, which also involves updates to the order_to_tags function, focusing on tag construction and syntax improvements.
  • Feat: issue #437 implementation #445: The changes in the main PR modify how the order_to_tags function is called in the get_tags_for_new_order function, while the retrieved PR alters the signature of the order_to_tags function itself, indicating a direct relationship between the two.

Suggested reviewers

  • Catrya
  • grunch

Poem

I'm a rabbit on the run, hopping through the code,
Finding missing users now with a neat new mode.
Instead of saying "none", I cheer with a default tuple in tow,
(0.0, 0, 0) – a safety net for our tag flow.
Hop along, dear coder, in this joyous binary land!
🐰💻 Hop, skip, and let the changes expand!


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9f1a1cf and 578d59c.

📒 Files selected for processing (2)
  • Cargo.toml (1 hunks)
  • src/app/dispute.rs (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • Cargo.toml
🔇 Additional comments (1)
src/app/dispute.rs (1)

197-197: Appropriate enhancement to the dispute creation process.

The change properly adds the order status as a parameter to the Dispute::new function, providing important context about the order's state at the time of dispute initiation. This enhancement allows the dispute system to retain more information about the circumstances under which the dispute was created, which can be valuable for dispute resolution and analytics.

✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai plan to trigger planning for file edits and PR creation.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@arkanoider arkanoider requested review from Catrya and grunch April 2, 2025 06:55

@Catrya Catrya left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @arkanoider the days are wrong, it show 20180 days

[
        "rating",
        "[\"rating\",{\"days\":20180,\"total_rating\":0.0,\"total_reviews\":0}]"
      ],

@arkanoider

Copy link
Copy Markdown
Collaborator Author

Hi @arkanoider the days are wrong, it show 20180 days

[
        "rating",
        "[\"rating\",{\"days\":20180,\"total_rating\":0.0,\"total_reviews\":0}]"
      ],

Ok! will fix asap..

@Catrya Catrya left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tACK

@arkanoider

Copy link
Copy Markdown
Collaborator Author

Bumped mostro-core version to 6.36.

Ready for merge @grunch

@grunch grunch left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks gooooooooooooood!

utACK

@grunch grunch merged commit fa5cbdf into develop Apr 3, 2025
@grunch grunch deleted the feature-privacy-order-event branch April 3, 2025 14:25
arkanoider added a commit that referenced this pull request Apr 30, 2025
* 📝 Add docstrings to `feature-full-privacy-mode-checks` (#455)

* add feature to check correctly if order is full privacy or normal

* 📝 Add docstrings to `feature-full-privacy-mode-checks`

Docstrings generation was requested by @arkanoider.

* #454 (comment)

The following files were modified:

* `src/app/order.rs`
* `src/util.rs`

---------

Co-authored-by: arkanoider <github.913zc@simplelogin.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: arkanoider <113362043+arkanoider@users.noreply.github.com>

* Fix network in order event (#452)

Now in orers event 38383 the network that comes out is the correct one

* Feature anyhow removal (#459)

* remove of anyhow dependency start

* removed anyhow dependecy

* remove patch from cargo.toml

* Update mostro-core version

---------

Co-authored-by: Francisco Calderón <fjcalderon@gmail.com>

* Feature disputes (#463)

* Feature: dispute fix for new logic

* fix for coop cancel case

* Add logic for info message about dispute for solver

* first working dispute info message for admin after taking disputes

* added fields to dispute info message for solver

* removed some probably useless and refactored a bit admin-take-dispute function

* clippy suggestion

* other cosmetics to admin take file

* some other cosmetics on admin-take-dispute file

* fix on admin-take

* Update admin_take_dispute.rs

* fixed a wrong search of order id in admin take file@

* Fix: added correct check to add solver from admin cli

* fix: wrong check on admin cancel

* Fix initiator pubkey: now is the trade key of initiator not identity

* quick fix for full privacy orders

* new logic with mixed full privacy - regular reputation mode

* Update cargo toml to compile with version 0.6.32 of mostro-core - this is in preparation for migrating to nostr-sdk 0.40

* rollback sdk to 0.38 version to merge disputes - we will come back to 0.40 when we will fix signature issue

* Update mostro-core dependency

---------

Co-authored-by: Francisco Calderón <fjcalderon@gmail.com>

* added correction for the case of buyer adding back a new invoice after payment failure (#462)

* Fix for nostr sdk 40 issue on incoming message (#465)

* testing sdk 40

* fix for sdk 40

* cleaned cargo.toml

* Bump mostro core version

---------

Co-authored-by: Francisco Calderón <fjcalderon@gmail.com>

* fix: sends order with an updated 'status' field as the reply to add-invoice when there is a preimage (#464)

* Feature-nip69-order-status (#467)

* feature: align to nip69 order status in nostr event

* Improved in progress nip69 logic

* refined event states of the order with nip69 request

* add another check to avoid multiple events with in-progress state

* Privacy range order fix (#468)

* add optional field for users in full privacy inside solver message

* To be tested - privacy range child order fix

* fix cargo.toml

* bumped mostro-core version to 6.35

* New user or privacy order send same user info with zeros (#471)

* new user or privacy order send same user info with zeros

* fix days field and removed some println! macro with nicer tracing messages

* bumped mostro-core version to 6.36 and added requested fix to compile

* Add previous order state in database for solver message (#472)

* add previous state in database for solver message

* bumped mostro-core version to 6.36

* Taker info message to maker.

I think that could be modifies in a more generic UserInfo.
 (#473)

* added logic to send infos to maker when an order is taken

* Add takers info message for maker

* fix cargo.toml

* set peer pubkey to empty string when notifying taker reputation to maker

* moved user info message to the right point of the order flow

* fix cargo.toml

* changed message struct from UserDisputeInfo to UserInfo

* fix: get master keys for user infos

* Bumped mostro-core to version 6.38

* fix for buy order flow with message to maker (#479)

* Rabbit fixes

---------

Co-authored-by: Francisco Calderón <fjcalderon@gmail.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: Catrya <140891948+Catrya@users.noreply.github.com>
Co-authored-by: Bilthon <bilthon@gmail.com>
@coderabbitai coderabbitai Bot mentioned this pull request May 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants