Skip to content

Conversation

@dewabisma
Copy link
Contributor

Summary

Created new endpoint for association X. This one will check if the user has the required mention in bio.

Endpoint

POST /addresses/associations/x

@dewabisma dewabisma requested a review from n13 January 5, 2026 10:36
@n13
Copy link
Contributor

n13 commented Jan 6, 2026

Review for PR 49: Update linking X flow

Summary

This PR implements a new flow for linking an X (Twitter) account to a Quantus address. Instead of a direct link or OAuth, it verifies ownership by checking if the user's X bio contains a specific mention (configured as @QuantusNetwork).

Key Changes

1. Configuration (config/*.toml, src/config.rs)

  • Added [x_association] section with a bio_mention setting.
  • Updated Config struct to include XAssociationConfig.

2. Dependency Update (Cargo.toml)

  • Bumped rusx to version 0.6.1.

3. New Handler (src/handlers/address.rs)

  • Implemented associate_x_handle.
  • Flow:
    1. Receives username in the request body.
    2. Fetches the Twitter user details (specifically description aka bio) using rusx.
    3. Verifies that the bio contains the configured bio_mention string.
    4. If verified, creates a new association in the database.
    5. Returns 204 No Content on success.

4. Routes (src/routes/address.rs)

  • Added POST method to /addresses/associations/x endpoint.

5. Tests

  • Added unit tests for the new handler:
    • test_associate_x_handle_success: Verifies correct association when bio matches.
    • test_associate_x_handle_fails_bad_bio: Verifies 401 Unauthorized when bio verification fails.
  • Updated existing tests in other modules to include description in mock User objects.

Feedback

Positive

  • Security: The "verify via bio" mechanism is a clever and simple way to prove ownership of the X account without requiring a complex OAuth integration for this specific use case.
  • Code Structure: The implementation follows the existing pattern of handlers, services, and repositories well.
  • Testing: Good coverage of the happy path and the verification failure case.

Suggestions / Questions

  1. Case Sensitivity: The check !bio.contains(x_bio_mention) is case-sensitive.
    • Question: Should this be case-insensitive to be more user-friendly (e.g. if a user types @quantusnetwork instead of @QuantusNetwork)?
  2. Duplicate Handling:
    • The handler calls state.db.x_associations.create. Ensure that the repository or database schema handles unique constraints (e.g., if one X account tries to link to multiple addresses, or one address to multiple X accounts) and that the error returned to the user is clear if a conflict occurs.
  3. Rate Limiting:
    • Since this endpoint calls the Twitter API directly, ensure that associate_x_handle is protected by appropriate rate limits to prevent draining the API quota or abuse.

Conclusion

The PR looks solid and ready for merge, pending the minor considerations above.

Status: ✅ Approved (with non-blocking suggestions)

Copy link
Contributor

@n13 n13 left a comment

Choose a reason for hiding this comment

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

LGTM, some suggestions above

Case sensitivity is probably a good one - just check they have quantus in lowercase of their bio (case ignored)

@dewabisma dewabisma merged commit 449fa15 into main Jan 6, 2026
1 check passed
@dewabisma dewabisma deleted the feat/update-linking-x-flow branch January 6, 2026 05:49
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