load last 10 messages on chat add

This commit is contained in:
2019-01-28 00:30:40 +03:00
parent b7e68abb03
commit fbfe72c774
3 changed files with 25 additions and 4 deletions
+14
View File
@@ -0,0 +1,14 @@
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):
chat = Chat.objects.get(pk=chat_id)
with get_client() as client:
_collect_new_messages(client, chat)