-
Notifications
You must be signed in to change notification settings - Fork 13
Fix/get user #555
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
Fix/get user #555
Conversation
WalkthroughUpdates changelog text, bumps the whitenoise Git dependency revision in Cargo.toml, and modifies get_user to call find_or_create_user_by_pubkey instead of find_user_by_pubkey, enabling user creation on lookup. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
actor Client
participant API as API:get_user
participant Repo as UsersRepo
Client->>API: GET /users/{pubkey}
API->>Repo: find_or_create_user_by_pubkey(pubkey)
alt User does not exist
rect rgba(200,230,255,0.35)
note over Repo: Create user record with metadata
Repo-->>API: Newly created User
end
else User exists
Repo-->>API: Existing User
end
API-->>Client: 200 OK + User (with metadata)
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
✨ Finishing Touches
🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
CodeRabbit Configuration File (
|
48e332d to
d956986
Compare
d956986 to
eeacd90
Compare
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.
Actionable comments posted: 0
🧹 Nitpick comments (3)
CHANGELOG.md (1)
24-24: Polish the entry for clarity and code-style.Use the function name and be explicit about the behavior.
-- Fixed get user logic, to show metadata when searching a new npub +- Fix `get_user` logic: create user on first lookup (new npub) so metadata is shown.rust/src/api/users.rs (1)
33-35: Correct fix; consider documenting side effects and aligning other API calls.
- This switches to create-on-read, which can write to storage. Add a brief doc comment so callers know it persists state.
- Consider using the same create-on-read behavior in
user_metadata,user_relays, anduser_has_key_packageto avoid 404/NotFound if they’re called first. If that’s not desired, leave as-is but document the difference.Add docs above
get_user:/// Returns the user, creating a local record if it doesn't exist. /// Side effect: may write to storage and trigger metadata/relay updates. pub async fn get_user(pubkey: String) -> Result<User, ApiError> { ... }Optional consistency change:
- let user = whitenoise.find_user_by_pubkey(&pubkey).await?; + let user = whitenoise.find_or_create_user_by_pubkey(&pubkey).await?;Please confirm whether create-on-read is intended across these endpoints or only for
get_user.rust/Cargo.toml (1)
26-26: Pin revision correct; verify lockfile and add traceability comment
- Ensure
rust/Cargo.lockis committed and updated to reference thisrevso CI installs deterministically.- Add an inline comment linking to the upstream PR (e.g. parres-hq/whitenoise#336) for future traceability.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
⛔ Files ignored due to path filters (3)
ios/Podfile.lockis excluded by!**/*.lockpubspec.lockis excluded by!**/*.lockrust/Cargo.lockis excluded by!**/*.lock
📒 Files selected for processing (3)
CHANGELOG.md(1 hunks)rust/Cargo.toml(1 hunks)rust/src/api/users.rs(1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.md
📄 CodeRabbit inference engine (.cursor/rules/whitenoise.mdc)
**/*.md: NIPs (Nostr Implementation Possibilities) are numbered likeNIP-XXwhereXXare two capitalized hexadecimal digits, e.g.,NIP-01andNIP-C7.
To read a specific NIP, construct the NIP URL following this template:https://raw.githubusercontent.com/nostr-protocol/nips/refs/heads/master/{nip}.md(replace{nip}in the URL template with the relevant NIP name, e.g.,07for NIP-07, orC7for NIP-C7).
To read the definition of a specific kind, construct a URL following this template:https://nostrbook.dev/kinds/{kind}.md(replace{kind}in the template with the kind number, e.g.,https://nostrbook.dev/kinds/0.mdfor kind 0).
Files:
CHANGELOG.md
Description
The get user method was searching in the existing users in database but not creating a new one if the npub wasn't saved in db yet. In parres-hq/whitenoise#336 we made publlic the method to find or create a user, and updated the metadata and relays
Changes:
This PR fixes the get user method in the bridge by using the find or create method from whitenoise crate
Example of results of same pub before and after:
Type of Change
Checklist
just precommitto ensure that formatting and linting are correctjust check-flutter-coverageto ensure that flutter coverage rules are passingCHANGELOG.mdfile with your changes (if they affect the user experience)Summary by CodeRabbit
Bug Fixes
Chores
Documentation
Notes