-
Notifications
You must be signed in to change notification settings - Fork 0
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
Develop #618
Merged
+441
−54
Merged
Develop #618
Changes from all commits
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
82bbc25
added cloudflare images field
alimaktabi 2d46d0c
update requirements.txt
alimaktabi 6ce04cf
removed extra prints
alimaktabi c23e742
refactored string injection method
alimaktabi 7b953cf
removed extra implementation of cloudflare image field to use a custo…
alimaktabi e26ca71
fixed arguments passing for is_valid
alimaktabi faacb84
fixed field typos
alimaktabi db05838
updated requirements
alimaktabi 4a6303c
added migrations for image fields
alimaktabi 5bbbeb6
Merge branch 'develop' into feature/add-cloudflare-image-field
alimaktabi 4137c92
fixed migrations
alimaktabi 30bd275
fixed testing image column name
alimaktabi 3a8cf16
fixed migration issue
alimaktabi 787b147
Add zora constraint
PooyaFekri ce00e5e
Merge pull request #611 from UnitapApp/feature/add-zora-constraint
PooyaFekri 8335a1e
Add twitter_id filed to TwitterConnection
PooyaFekri 14f3971
Merge pull request #612 from UnitapApp/feature/add-twitter-id-to-twit…
PooyaFekri 41b8f20
Fix test in twitter constraint
PooyaFekri 51a6fb0
Merge pull request #613 from UnitapApp/feature/add-twitter-id-to-twit…
PooyaFekri 9fca870
Fix get_twitter_id
PooyaFekri 56532fb
Merge pull request #614 from UnitapApp/feature/add-twitter-id-to-twit…
PooyaFekri 0da60d8
added hcaptcha setup
alimaktabi 62a4be9
Merge pull request #606 from UnitapApp/feature/add-cloudflare-image-f…
PooyaFekri 49a3bd5
Merge pull request #615 from UnitapApp/feature/hcaptcha-implementation
PooyaFekri acde1fd
requirements
ShayanShiravani ed68b4a
bugfix
ShayanShiravani 63505ed
Merge pull request #616 from UnitapApp/feature/unt-771-gitcoin-integr…
ShayanShiravani b89e323
fixed migrations
alimaktabi 3ef8154
Merge pull request #617 from UnitapApp/fix/migrations-error
PooyaFekri 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
There are no files selected for viewing
18 changes: 18 additions & 0 deletions
18
authentication/migrations/0042_twitterconnection_twitter_id.py
This file contains 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,18 @@ | ||
# Generated by Django 4.0.4 on 2024-08-30 15:47 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('authentication', '0041_alter_brightidconnection_user_profile_and_more'), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name='twitterconnection', | ||
name='twitter_id', | ||
field=models.CharField(max_length=255, null=True, unique=True), | ||
), | ||
] |
This file contains 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 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 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 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 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 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 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 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 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,33 @@ | ||
from datetime import datetime | ||
|
||
from core.constraints.abstract import ( | ||
ConstraintApp, | ||
ConstraintParam, | ||
ConstraintVerification, | ||
) | ||
from core.thirdpartyapp import ZoraUtil | ||
|
||
|
||
class DidMintZoraNFT(ConstraintVerification): | ||
app_name = ConstraintApp.ZORA.value | ||
_param_keys = [ConstraintParam.ADDRESS] | ||
|
||
def __init__(self, user_profile) -> None: | ||
super().__init__(user_profile) | ||
|
||
def is_observed(self, *args, **kwargs) -> bool: | ||
zora_util = ZoraUtil() | ||
user_addresses = self.user_addresses | ||
nft_address = self.param_values[ConstraintParam.ADDRESS.name] | ||
for address in user_addresses: | ||
res = zora_util.get_tx(nft_address=nft_address, address=address) | ||
if res is None: | ||
continue | ||
for tx in res.values: | ||
if ( | ||
tx.get("method") == "mint" | ||
and datetime.strptime(tx.get("timestamp"), "%Y-%m-%dT%H:%M:%S.%fZ") | ||
> self.obj.start_at | ||
): | ||
return True | ||
return False |
This file contains 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,30 @@ | ||||||||||||
""" | ||||||||||||
Contains all the fields related classes to support custom features | ||||||||||||
such as variants in Cloudflare Images | ||||||||||||
""" | ||||||||||||
|
||||||||||||
from django.db import models | ||||||||||||
|
||||||||||||
|
||||||||||||
class BigNumField(models.Field): | ||||||||||||
empty_strings_allowed = False | ||||||||||||
|
||||||||||||
def __init__(self, *args, **kwargs): | ||||||||||||
kwargs["max_length"] = 200 # or some other number | ||||||||||||
super().__init__(*args, **kwargs) | ||||||||||||
|
||||||||||||
def db_type(self, connection): | ||||||||||||
return "numeric" | ||||||||||||
|
||||||||||||
def get_internal_type(self): | ||||||||||||
return "BigNumField" | ||||||||||||
|
||||||||||||
def to_python(self, value): | ||||||||||||
if isinstance(value, str): | ||||||||||||
return int(value) | ||||||||||||
|
||||||||||||
return value | ||||||||||||
Comment on lines
+23
to
+26
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. suggestion (code-quality): We've found these issues:
Suggested change
|
||||||||||||
|
||||||||||||
def get_prep_value(self, value): | ||||||||||||
return str(value) | ||||||||||||
|
This file contains 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 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 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 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 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,24 @@ | ||
import logging | ||
from django.conf import settings | ||
import requests | ||
|
||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
class HCaptchaUtil: | ||
secret_key = settings.H_CAPTCHA_SECRET | ||
api_url = "https://api.hcaptcha.com" | ||
|
||
def is_verified(self, token: str, ip: str) -> bool: | ||
try: | ||
res = requests.post( | ||
f"{self.api_url}/siteverify", | ||
data={"secret": self.secret_key, "response": token, "remoteip": ip}, | ||
) | ||
|
||
return res.ok and res.json()["success"] | ||
except Exception as e: | ||
logger.info(f"Error occurred during hcaptcha verification {str(e)}") | ||
|
||
return False |
This file contains 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
Oops, something went wrong.
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.
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.
suggestion: Consider extracting common captcha verification logic
The
is_observed
method inHasVerifiedHCaptcha
is very similar to the one inHasVerifiedCloudflareCaptcha
. Consider extracting common functionality to a base class or utility function to reduce code duplication.