From 2f1076b75b0c07b24d30d8e01b3801fb40c5ed66 Mon Sep 17 00:00:00 2001 From: bakatrouble Date: Thu, 31 Jan 2019 00:26:06 +0300 Subject: [PATCH] fix --- aggregator/models.py | 2 ++ aggregator/signals.py | 6 ------ 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/aggregator/models.py b/aggregator/models.py index bd9ee43..9558917 100644 --- a/aggregator/models.py +++ b/aggregator/models.py @@ -48,6 +48,8 @@ class Chat(models.Model): obj.photo.save(os.path.basename(path), f, save=True) obj.photo_id = chat.photo.small_file_id obj.save() + if created: + transaction.on_commit(lambda: collect_new_messages.delay(obj.pk)) return obj def __str__(self): diff --git a/aggregator/signals.py b/aggregator/signals.py index 803d8f6..4920885 100644 --- a/aggregator/signals.py +++ b/aggregator/signals.py @@ -2,7 +2,6 @@ from pyrogram import Error from .client import get_client from .models import Chat, AggregationSource -from .tasks import collect_new_messages def aggregation_source_deleted(sender, instance: AggregationSource, **kwargs): @@ -10,11 +9,6 @@ def aggregation_source_deleted(sender, instance: AggregationSource, **kwargs): Chat.objects.filter(chat_id=instance.chat_id).delete() -def chat_created(sender, instance: Chat, created, **kwargs): - if created: - collect_new_messages.delay(instance.pk) - - def chat_deleted(sender, instance: Chat, **kwargs): with get_client() as client: try: