-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added telegram connection constraint
- Loading branch information
1 parent
d62fad8
commit 1cc33ba
Showing
7 changed files
with
215 additions
and
8 deletions.
There are no files selected for viewing
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,23 @@ | ||
import logging | ||
|
||
from core.constraints.abstract import ( | ||
ConstraintApp, | ||
ConstraintVerification, | ||
) | ||
|
||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
class HasTelegramConnection(ConstraintVerification): | ||
_param_keys = [] | ||
app_name = ConstraintApp.GENERAL.value | ||
|
||
def is_observed(self, *args, **kwargs) -> bool: | ||
from telegram.models import TelegramConnection | ||
|
||
try: | ||
twitter = TelegramConnection.get_connection(self.user_profile) | ||
except TelegramConnection.DoesNotExist: | ||
return False | ||
return twitter.is_connected() |
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
Empty file.
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,93 @@ | ||
# Generated by Django 5.1.2 on 2024-10-17 11:39 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
def create_prizetap_constraint(apps, schema_editor): | ||
Constraint = apps.get_model("prizetap", "Constraint") | ||
|
||
Constraint.objects.create( | ||
name="core.HasTelegramConnection", | ||
description="HasTelegramConnection", | ||
title="Connect Telegram", | ||
type="VER", | ||
) | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
("prizetap", "0080_alter_constraint_name"), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterField( | ||
model_name="constraint", | ||
name="name", | ||
field=models.CharField( | ||
choices=[ | ||
("core.BrightIDMeetVerification", "BrightIDMeetVerification"), | ||
("core.BrightIDAuraVerification", "BrightIDAuraVerification"), | ||
("core.HasNFTVerification", "HasNFTVerification"), | ||
("core.HasTokenVerification", "HasTokenVerification"), | ||
( | ||
"core.HasTokenTransferVerification", | ||
"HasTokenTransferVerification", | ||
), | ||
("core.AllowListVerification", "AllowListVerification"), | ||
("core.HasENSVerification", "HasENSVerification"), | ||
("core.HasLensProfile", "HasLensProfile"), | ||
("core.IsFollowingLensUser", "IsFollowingLensUser"), | ||
("core.BeFollowedByLensUser", "BeFollowedByLensUser"), | ||
("core.DidMirrorOnLensPublication", "DidMirrorOnLensPublication"), | ||
("core.DidCollectLensPublication", "DidCollectLensPublication"), | ||
("core.HasMinimumLensPost", "HasMinimumLensPost"), | ||
("core.HasMinimumLensFollower", "HasMinimumLensFollower"), | ||
("core.BeFollowedByFarcasterUser", "BeFollowedByFarcasterUser"), | ||
("core.HasMinimumFarcasterFollower", "HasMinimumFarcasterFollower"), | ||
("core.DidLikedFarcasterCast", "DidLikedFarcasterCast"), | ||
("core.DidRecastFarcasterCast", "DidRecastFarcasterCast"), | ||
("core.IsFollowingFarcasterUser", "IsFollowingFarcasterUser"), | ||
("core.HasFarcasterProfile", "HasFarcasterProfile"), | ||
("core.BeAttestedBy", "BeAttestedBy"), | ||
("core.Attest", "Attest"), | ||
("core.HasDonatedOnGitcoin", "HasDonatedOnGitcoin"), | ||
("core.HasMinimumHumanityScore", "HasMinimumHumanityScore"), | ||
("core.HasGitcoinPassportProfile", "HasGitcoinPassportProfile"), | ||
("core.IsFollowingFarcasterChannel", "IsFollowingFarcasterChannel"), | ||
("core.BridgeEthToArb", "BridgeEthToArb"), | ||
("core.IsFollowingTwitterUser", "IsFollowingTwitterUser"), | ||
("core.BeFollowedByTwitterUser", "BeFollowedByTwitterUser"), | ||
("core.DidRetweetTweet", "DidRetweetTweet"), | ||
("core.DidQuoteTweet", "DidQuoteTweet"), | ||
("core.HasMuonNode", "HasMuonNode"), | ||
("core.DelegateArb", "DelegateArb"), | ||
("core.DelegateOP", "DelegateOP"), | ||
("core.DidDelegateArbToAddress", "DidDelegateArbToAddress"), | ||
("core.DidDelegateOPToAddress", "DidDelegateOPToAddress"), | ||
("core.GLMStakingVerification", "GLMStakingVerification"), | ||
("core.IsFollowingTwitterBatch", "IsFollowingTwitterBatch"), | ||
("core.IsFollowingFarcasterBatch", "IsFollowingFarcasterBatch"), | ||
( | ||
"core.HasVerifiedCloudflareCaptcha", | ||
"HasVerifiedCloudflareCaptcha", | ||
), | ||
("core.DidMintZoraNFT", "DidMintZoraNFT"), | ||
("core.HasVerifiedHCaptcha", "HasVerifiedHCaptcha"), | ||
("core.HasTelegramConnection", "HasTelegramConnection"), | ||
("prizetap.HaveUnitapPass", "HaveUnitapPass"), | ||
("prizetap.NotHaveUnitapPass", "NotHaveUnitapPass"), | ||
("faucet.OptimismDonationConstraint", "OptimismDonationConstraint"), | ||
( | ||
"faucet.OptimismClaimingGasConstraint", | ||
"OptimismClaimingGasConstraint", | ||
), | ||
], | ||
max_length=255, | ||
unique=True, | ||
), | ||
), | ||
migrations.RunPython( | ||
create_prizetap_constraint, reverse_code=migrations.RunPython.noop | ||
), | ||
] |
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,95 @@ | ||
# Generated by Django 5.1.2 on 2024-10-17 11:39 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
def create_tokentap_constraint(apps, schema_editor): | ||
Constraint = apps.get_model("tokenTap", "Constraint") | ||
|
||
Constraint.objects.create( | ||
name="core.HasTelegramConnection", | ||
description="HasTelegramConnection", | ||
title="Connect Telegram", | ||
type="VER", | ||
) | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
("tokenTap", "0066_alter_constraint_name"), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterField( | ||
model_name="constraint", | ||
name="name", | ||
field=models.CharField( | ||
choices=[ | ||
("core.BrightIDMeetVerification", "BrightIDMeetVerification"), | ||
("core.BrightIDAuraVerification", "BrightIDAuraVerification"), | ||
("core.HasNFTVerification", "HasNFTVerification"), | ||
("core.HasTokenVerification", "HasTokenVerification"), | ||
( | ||
"core.HasTokenTransferVerification", | ||
"HasTokenTransferVerification", | ||
), | ||
("core.AllowListVerification", "AllowListVerification"), | ||
("core.HasENSVerification", "HasENSVerification"), | ||
("core.HasLensProfile", "HasLensProfile"), | ||
("core.IsFollowingLensUser", "IsFollowingLensUser"), | ||
("core.BeFollowedByLensUser", "BeFollowedByLensUser"), | ||
("core.DidMirrorOnLensPublication", "DidMirrorOnLensPublication"), | ||
("core.DidCollectLensPublication", "DidCollectLensPublication"), | ||
("core.HasMinimumLensPost", "HasMinimumLensPost"), | ||
("core.HasMinimumLensFollower", "HasMinimumLensFollower"), | ||
("core.BeFollowedByFarcasterUser", "BeFollowedByFarcasterUser"), | ||
("core.HasMinimumFarcasterFollower", "HasMinimumFarcasterFollower"), | ||
("core.DidLikedFarcasterCast", "DidLikedFarcasterCast"), | ||
("core.DidRecastFarcasterCast", "DidRecastFarcasterCast"), | ||
("core.IsFollowingFarcasterUser", "IsFollowingFarcasterUser"), | ||
("core.HasFarcasterProfile", "HasFarcasterProfile"), | ||
("core.BeAttestedBy", "BeAttestedBy"), | ||
("core.Attest", "Attest"), | ||
("core.HasDonatedOnGitcoin", "HasDonatedOnGitcoin"), | ||
("core.HasMinimumHumanityScore", "HasMinimumHumanityScore"), | ||
("core.HasGitcoinPassportProfile", "HasGitcoinPassportProfile"), | ||
("core.IsFollowingFarcasterChannel", "IsFollowingFarcasterChannel"), | ||
("core.BridgeEthToArb", "BridgeEthToArb"), | ||
("core.IsFollowingTwitterUser", "IsFollowingTwitterUser"), | ||
("core.BeFollowedByTwitterUser", "BeFollowedByTwitterUser"), | ||
("core.DidRetweetTweet", "DidRetweetTweet"), | ||
("core.DidQuoteTweet", "DidQuoteTweet"), | ||
("core.HasMuonNode", "HasMuonNode"), | ||
("core.DelegateArb", "DelegateArb"), | ||
("core.DelegateOP", "DelegateOP"), | ||
("core.DidDelegateArbToAddress", "DidDelegateArbToAddress"), | ||
("core.DidDelegateOPToAddress", "DidDelegateOPToAddress"), | ||
("core.GLMStakingVerification", "GLMStakingVerification"), | ||
("core.IsFollowingTwitterBatch", "IsFollowingTwitterBatch"), | ||
("core.IsFollowingFarcasterBatch", "IsFollowingFarcasterBatch"), | ||
( | ||
"core.HasVerifiedCloudflareCaptcha", | ||
"HasVerifiedCloudflareCaptcha", | ||
), | ||
("core.DidMintZoraNFT", "DidMintZoraNFT"), | ||
("core.HasVerifiedHCaptcha", "HasVerifiedHCaptcha"), | ||
("core.HasTelegramConnection", "HasTelegramConnection"), | ||
("tokenTap.OncePerMonthVerification", "OncePerMonthVerification"), | ||
( | ||
"tokenTap.OnceInALifeTimeVerification", | ||
"OnceInALifeTimeVerification", | ||
), | ||
( | ||
"faucet.OptimismHasClaimedGasConstraint", | ||
"OptimismHasClaimedGasConstraint", | ||
), | ||
], | ||
max_length=255, | ||
unique=True, | ||
), | ||
), | ||
migrations.RunPython( | ||
create_tokentap_constraint, reverse_code=migrations.RunPython.noop | ||
), | ||
] |