diff --git a/polls/utils.py b/polls/utils.py index 5733698..64124fc 100644 --- a/polls/utils.py +++ b/polls/utils.py @@ -35,11 +35,12 @@ acs_client = AcsClient("LTAI4GDaSp41vp1X4mCb7uCa", region_provider.add_endpoint( "Dyvmsapi", "cn-hangzhou", "dyvmsapi.aliyuncs.com") -def send_voice_notify(phone): +def send_voice_notify(phone, type): business_id = uuid.uuid4() ttsRequest = SingleCallByTtsRequest.SingleCallByTtsRequest() # 申请的语音通知tts模板编码,必填 - ttsRequest.set_TtsCode("TTS_205890042") + template_code = "TTS_205885979" if type == 1 else "TTS_205890042" + ttsRequest.set_TtsCode(template_code) # 设置业务请求流水号,必填。后端服务基于此标识区分是否重复请求的判断 ttsRequest.set_OutId(business_id) # 语音通知的被叫号码,必填。 diff --git a/polls/views/message.py b/polls/views/message.py index e1d67bd..5f4f84a 100644 --- a/polls/views/message.py +++ b/polls/views/message.py @@ -6,7 +6,7 @@ import datetime from polls.decorators import polls_login_required from django.core.exceptions import ObjectDoesNotExist from polls.models import Message, TaskRecord -from dashboard.models import Userprofile +from dashboard.models import Group_user, Userprofile @csrf_exempt @@ -84,5 +84,8 @@ def read_message(request): if not message_id: return JsonResponse({'status': 'success', 'message': False}, safe=False) message = Message.objects.get(id=message_id) - obj, created = TaskRecord.objects.get_or_create(user=user, task=message.task) + group_id = message.send_to_id + is_exists = Group_user.objects.filter(group_id=group_id, user_id=user.id).exists() + if is_exists: + obj, created = TaskRecord.objects.get_or_create(user=user, task=message.task) return JsonResponse({'status': 'success', 'message': True}, safe=False) diff --git a/polls/views/task.py b/polls/views/task.py index 583ac06..2368702 100644 --- a/polls/views/task.py +++ b/polls/views/task.py @@ -109,12 +109,3 @@ def get_task(request): result['added'] = task.added.strftime("%Y-%m-%d %H:%M:%S") return JsonResponse({'status': 'success', 'message': result}) - -@csrf_exempt -def create_test_task(request): - if request.method == 'GET': - return HttpResponse(status=405) - channel_layer = get_channel_layer() - async_to_sync(channel_layer.group_send)( - "testroom", {"type": "chat.message", "message": "helo"}) - return JsonResponse({'status': 'success'})