feat: remind_push

This commit is contained in:
caoqianming 2023-09-01 09:38:07 +08:00
parent 83957c8e9c
commit efa6651748
1 changed files with 12 additions and 3 deletions

View File

@ -1,10 +1,10 @@
from __future__ import absolute_import, unicode_literals
import os
from threading import Thread
from channels.layers import get_channel_layer
from asgiref.sync import async_to_sync
from celery import shared_task
import requests
from apps.am.models import Area
from apps.ecm.models import EventCate, Eventdo, Event
from apps.ecm.service import notify_event, snap_and_analyse
@ -202,4 +202,13 @@ def compressed_all_ecm_image():
for event in events:
if event.global_img and event.global_img_compressed is None:
event.global_img_compressed = compress_global_img(event.global_img)
event.save()
event.save()
@shared_task(base=CustomTask)
def remind_push(userId: str):
channel_layer = get_channel_layer()
data = {
'type': 'event',
'msg': ''
}
async_to_sync(channel_layer.group_send)(f"user_{userId}", data)