fix imports
This commit is contained in:
parent
fbfe72c774
commit
cba3643e02
@ -7,8 +7,6 @@ from django.conf import settings
|
||||
from django.db import models
|
||||
from pyrogram import Chat as PyrogramChat, Message as PyrogramMessage
|
||||
|
||||
from aggregator.tasks import collect_new_messages
|
||||
|
||||
|
||||
class AggregationSource(models.Model):
|
||||
owner = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE)
|
||||
@ -28,6 +26,8 @@ class Chat(models.Model):
|
||||
|
||||
@classmethod
|
||||
def from_obj(cls, chat: PyrogramChat, client):
|
||||
from aggregator.tasks import collect_new_messages
|
||||
|
||||
obj, created = Chat.objects.update_or_create(
|
||||
chat_id=chat.id,
|
||||
defaults={
|
||||
|
@ -3,12 +3,13 @@ from celery_once import QueueOnce
|
||||
from aggregator.client import get_client
|
||||
from config.celery import app
|
||||
|
||||
from .models import Chat
|
||||
from .client import collect_new_messages as _collect_new_messages
|
||||
|
||||
|
||||
@app.task(base=QueueOnce, once={'keys': ['chat_id'], 'graceful': True})
|
||||
def collect_new_messages(chat_id):
|
||||
from .models import Chat
|
||||
|
||||
chat = Chat.objects.get(pk=chat_id)
|
||||
with get_client() as client:
|
||||
_collect_new_messages(client, chat)
|
||||
|
Loading…
Reference in New Issue
Block a user