-
Notifications
You must be signed in to change notification settings - Fork 26
Let validators link Telegram support groups through the Deckard bot #960
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| # Generated by Django 5.2.10 on 2026-07-30 10:18 | ||
|
|
||
| import django.db.models.deletion | ||
| from django.conf import settings | ||
| from django.db import migrations, models | ||
|
|
||
|
|
||
| class Migration(migrations.Migration): | ||
|
|
||
| dependencies = [ | ||
| ('social_connections', '0007_alter_discordearnedroleassignment_options'), | ||
| migrations.swappable_dependency(settings.AUTH_USER_MODEL), | ||
| ] | ||
|
|
||
| operations = [ | ||
| migrations.CreateModel( | ||
| name='TelegramConnection', | ||
| fields=[ | ||
| ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | ||
| ('platform_user_id', models.CharField(help_text="Platform's unique user ID", max_length=100)), | ||
| ('platform_username', models.CharField(help_text='Username on the platform', max_length=100)), | ||
| ('access_token', models.TextField(blank=True, help_text='Encrypted OAuth access token')), | ||
| ('refresh_token', models.TextField(blank=True, help_text='Encrypted OAuth refresh token')), | ||
| ('linked_at', models.DateTimeField(help_text='When the account was linked')), | ||
| ('created_at', models.DateTimeField(auto_now_add=True)), | ||
| ('updated_at', models.DateTimeField(auto_now=True)), | ||
| ('user', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, related_name='%(class)s', to=settings.AUTH_USER_MODEL)), | ||
| ], | ||
| options={ | ||
| 'verbose_name': 'Telegram Connection', | ||
| 'verbose_name_plural': 'Telegram Connections', | ||
| 'db_table': 'social_connections_telegram', | ||
| }, | ||
| ), | ||
| ] |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -48,6 +48,23 @@ class Meta: | |
| verbose_name_plural = 'Twitter Connections' | ||
|
|
||
|
|
||
| class TelegramConnection(SocialConnection): | ||
| """Telegram identity for a portal account. | ||
|
|
||
| Telegram has no OAuth flow here: the connection is created/confirmed when | ||
| the Deckard support bot redeems a Telegram group bind code issued by this | ||
| user (see validators.TelegramGroupBindCode). `platform_user_id` holds the | ||
| numeric Telegram user id (the stable identity); `platform_username` is the | ||
| display-only @username, which Telegram users can change at any time. The | ||
| inherited OAuth token fields stay empty. | ||
| """ | ||
|
|
||
| class Meta: | ||
| db_table = 'social_connections_telegram' | ||
| verbose_name = 'Telegram Connection' | ||
| verbose_name_plural = 'Telegram Connections' | ||
|
|
||
|
|
||
|
Comment on lines
+51
to
+67
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. 📐 Maintainability & Code Quality | 🔵 Trivial | ⚖️ Poor tradeoff
It subclasses the abstract 🤖 Prompt for AI AgentsSource: Coding guidelines |
||
| class DiscordConnection(SocialConnection): | ||
| discriminator = models.CharField(max_length=10, blank=True, help_text="Discord discriminator (legacy)") | ||
| avatar_hash = models.CharField(max_length=100, blank=True, help_text="Discord avatar hash for CDN URL") | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| # Generated by Django 5.2.10 on 2026-07-30 10:18 | ||
|
|
||
| import django.db.models.deletion | ||
| from django.conf import settings | ||
| from django.db import migrations, models | ||
|
|
||
|
|
||
| class Migration(migrations.Migration): | ||
|
|
||
| dependencies = [ | ||
| ('validators', '0017_validatoroperatorwallet'), | ||
| migrations.swappable_dependency(settings.AUTH_USER_MODEL), | ||
| ] | ||
|
|
||
| operations = [ | ||
| migrations.CreateModel( | ||
| name='TelegramGroupBindCode', | ||
| fields=[ | ||
| ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | ||
| ('created_at', models.DateTimeField(auto_now_add=True)), | ||
| ('updated_at', models.DateTimeField(auto_now=True)), | ||
| ('identifier', models.CharField(help_text='Non-secret lookup id embedded in the code', max_length=16, unique=True)), | ||
| ('digest', models.CharField(help_text='SHA-256 digest of the plaintext code (plaintext is never stored)', max_length=64, unique=True)), | ||
| ('status', models.CharField(choices=[('issued', 'Issued'), ('redeemed', 'Redeemed'), ('expired', 'Expired'), ('revoked', 'Revoked')], db_index=True, default='issued', max_length=10)), | ||
| ('expires_at', models.DateTimeField()), | ||
| ('redeemed_at', models.DateTimeField(blank=True, null=True)), | ||
| ('redeemed_group_chat_id', models.CharField(blank=True, help_text='Telegram chat id of the bound group (set on redemption)', max_length=32)), | ||
| ('redeemed_by_telegram_uid', models.CharField(blank=True, help_text='Numeric Telegram user id that redeemed the code (set on redemption)', max_length=32)), | ||
| ('created_by', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='telegram_bind_codes', to=settings.AUTH_USER_MODEL)), | ||
| ('validator', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='telegram_bind_codes', to='validators.validator')), | ||
| ], | ||
| options={ | ||
| 'ordering': ['-created_at'], | ||
| }, | ||
| ), | ||
| ] |
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.
📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value
Minor: prefer unpacking over concatenation.
Ruff flags the tuple concatenation; unpacking is idiomatic and avoids the implicit tuple-type check.
♻️ Suggested fix
📝 Committable suggestion
🧰 Tools
🪛 Ruff (0.16.0)
[warning] 14-14: Consider
(*AI_REVIEW_SCOPES, TELEGRAM_BIND_REDEEM_SCOPE)instead of concatenationReplace with
(*AI_REVIEW_SCOPES, TELEGRAM_BIND_REDEEM_SCOPE)(RUF005)
🤖 Prompt for AI Agents
Source: Linters/SAST tools