2019-01-27 21:30:40 +00:00
|
|
|
from celery_once import QueueOnce
|
|
|
|
|
|
|
|
from aggregator.client import get_client
|
|
|
|
from config.celery import app
|
|
|
|
|
|
|
|
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):
|
2019-01-27 21:32:34 +00:00
|
|
|
from .models import Chat
|
|
|
|
|
2019-01-27 21:30:40 +00:00
|
|
|
chat = Chat.objects.get(pk=chat_id)
|
|
|
|
with get_client() as client:
|
|
|
|
_collect_new_messages(client, chat)
|