Skip to content
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/requirements/captcha and zora #619

Merged
merged 2 commits into from
Sep 7, 2024

Conversation

alimaktabi
Copy link
Collaborator

@alimaktabi alimaktabi commented Sep 7, 2024

Summary by Sourcery

Fix initialization issues in the DidMintZoraNFT class by adding an optional 'obj' parameter and correct the token retrieval logic in the captcha constraint to handle 'hc-turnstile-response' and 'cf-turnstile-response'.

Bug Fixes:

  • Fix the initialization of DidMintZoraNFT by adding an optional 'obj' parameter to the constructor.
  • Correct the retrieval of the turnstile token in the captcha constraint by checking for 'hc-turnstile-response' before 'cf-turnstile-response'.

Copy link
Contributor

sourcery-ai bot commented Sep 7, 2024

Reviewer's Guide by Sourcery

This pull request makes minor adjustments to the Zora NFT minting constraint and the CAPTCHA verification process. The changes improve the flexibility of the DidMintZoraNFT class initialization and expand the CAPTCHA token retrieval to support multiple sources.

File-Level Changes

Change Details Files
Modified the DidMintZoraNFT class constructor to accept an optional 'obj' parameter
  • Added 'obj=None' as a keyword-only argument to the constructor
  • Updated the super().init() call to pass the 'obj' parameter
core/constraints/zora.py
Enhanced CAPTCHA token retrieval to support multiple sources
  • Added support for 'hc-turnstile-response' as an alternative CAPTCHA token source
  • Modified the token retrieval logic to check for both 'hc-turnstile-response' and 'cf-turnstile-response'
core/constraints/captcha.py

Tips
  • Trigger a new Sourcery review by commenting @sourcery-ai review on the pull request.
  • Continue your discussion with Sourcery by replying directly to review comments.
  • You can change your review settings at any time by accessing your dashboard:
    • Enable or disable the Sourcery-generated pull request summary or reviewer's guide;
    • Change the review language;
  • You can always contact us if you have any questions or feedback.

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey @alimaktabi - I've reviewed your changes and they look great!

Here's what I looked at during the review
  • 🟡 General issues: 1 issue found
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment to tell me if it was helpful.

@@ -60,7 +60,7 @@ def is_observed(self, *args, **kwargs) -> bool:
context["request"]
)

turnstile_token = request_context.data.get("cf-turnstile-response")
turnstile_token = request_context.data.get("hc-turnstile-response") or request_context.data.get("cf-turnstile-response")
Copy link
Contributor

Choose a reason for hiding this comment

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

suggestion: Consider adding a comment explaining the reason for supporting multiple CAPTCHA providers

It would be helpful to add a brief comment explaining why both 'hc-turnstile-response' and 'cf-turnstile-response' are being checked. Additionally, consider defining these as constants to avoid string duplication and improve maintainability.

Suggested change
turnstile_token = request_context.data.get("hc-turnstile-response") or request_context.data.get("cf-turnstile-response")
HC_TURNSTILE_KEY = "hc-turnstile-response"
CF_TURNSTILE_KEY = "cf-turnstile-response"
turnstile_token = request_context.data.get(HC_TURNSTILE_KEY) or request_context.data.get(CF_TURNSTILE_KEY)

@ShayanShiravani ShayanShiravani merged commit e24904b into develop Sep 7, 2024
1 check passed
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.

2 participants