From 5306a033b23b2407478a22517e21186b87ee3726 Mon Sep 17 00:00:00 2001 From: bakatrouble Date: Mon, 28 Jan 2019 00:49:17 +0300 Subject: [PATCH] fix chat_id fields --- aggregator/client.py | 6 ++--- .../migrations/0003_auto_20190128_0048.py | 23 +++++++++++++++++++ aggregator/models.py | 4 ++-- 3 files changed, 28 insertions(+), 5 deletions(-) create mode 100644 aggregator/migrations/0003_auto_20190128_0048.py diff --git a/aggregator/client.py b/aggregator/client.py index b02dec8..7f17779 100644 --- a/aggregator/client.py +++ b/aggregator/client.py @@ -15,10 +15,10 @@ Session.notice_displayed = True def get_client(): config._reload_maybe() - pyrogram_session = config.pyrogram_session.replace('.session', '') - if not pyrogram_session or not config.pyrogram_app_id or not config.pyrogram_app_hash: + if not config.pyrogram_session or not config.pyrogram_app_id or not config.pyrogram_app_hash: raise RuntimeError('Pyrogram is not configured') - session_path = os.path.relpath(default_storage.path(pyrogram_session)) + + session_path = os.path.relpath(default_storage.path(config.pyrogram_session.replace('.session', ''))) return Client(session_path, config.pyrogram_app_id, config.pyrogram_app_hash) diff --git a/aggregator/migrations/0003_auto_20190128_0048.py b/aggregator/migrations/0003_auto_20190128_0048.py new file mode 100644 index 0000000..9fa6525 --- /dev/null +++ b/aggregator/migrations/0003_auto_20190128_0048.py @@ -0,0 +1,23 @@ +# Generated by Django 2.1.5 on 2019-01-27 21:48 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('aggregator', '0002_remove_aggregationsource_last_id'), + ] + + operations = [ + migrations.AlterField( + model_name='aggregationsource', + name='chat_id', + field=models.CharField(db_index=True, max_length=64), + ), + migrations.AlterField( + model_name='chat', + name='chat_id', + field=models.CharField(db_index=True, max_length=64), + ), + ] diff --git a/aggregator/models.py b/aggregator/models.py index 39fd543..8f8be8e 100644 --- a/aggregator/models.py +++ b/aggregator/models.py @@ -11,14 +11,14 @@ from pyrogram import Chat as PyrogramChat, Message as PyrogramMessage class AggregationSource(models.Model): owner = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE) title = models.CharField(max_length=64) - chat_id = models.IntegerField(db_index=True) + chat_id = models.CharField(db_index=True, max_length=64) def __str__(self): return self.title class Chat(models.Model): - chat_id = models.IntegerField(db_index=True) + chat_id = models.CharField(db_index=True, max_length=64) title = models.TextField() username = models.CharField(max_length=64, null=True, blank=True) photo = models.ImageField(null=True, blank=True)