fix chat_id fields

This commit is contained in:
bakatrouble 2019-01-28 00:49:17 +03:00
parent 188c8c1b1a
commit 5306a033b2
3 changed files with 28 additions and 5 deletions

View File

@ -15,10 +15,10 @@ Session.notice_displayed = True
def get_client(): def get_client():
config._reload_maybe() config._reload_maybe()
pyrogram_session = config.pyrogram_session.replace('.session', '') if not config.pyrogram_session or not config.pyrogram_app_id or not config.pyrogram_app_hash:
if not pyrogram_session or not config.pyrogram_app_id or not config.pyrogram_app_hash:
raise RuntimeError('Pyrogram is not configured') 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) return Client(session_path, config.pyrogram_app_id, config.pyrogram_app_hash)

View File

@ -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),
),
]

View File

@ -11,14 +11,14 @@ from pyrogram import Chat as PyrogramChat, Message as PyrogramMessage
class AggregationSource(models.Model): class AggregationSource(models.Model):
owner = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE) owner = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE)
title = models.CharField(max_length=64) 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): def __str__(self):
return self.title return self.title
class Chat(models.Model): class Chat(models.Model):
chat_id = models.IntegerField(db_index=True) chat_id = models.CharField(db_index=True, max_length=64)
title = models.TextField() title = models.TextField()
username = models.CharField(max_length=64, null=True, blank=True) username = models.CharField(max_length=64, null=True, blank=True)
photo = models.ImageField(null=True, blank=True) photo = models.ImageField(null=True, blank=True)