add message

This commit is contained in:
baoliang 2020-12-05 12:46:36 +08:00
parent 92cbb3280c
commit 361f25c4be
3 changed files with 8 additions and 13 deletions

View File

@ -35,11 +35,12 @@ acs_client = AcsClient("LTAI4GDaSp41vp1X4mCb7uCa",
region_provider.add_endpoint( region_provider.add_endpoint(
"Dyvmsapi", "cn-hangzhou", "dyvmsapi.aliyuncs.com") "Dyvmsapi", "cn-hangzhou", "dyvmsapi.aliyuncs.com")
def send_voice_notify(phone): def send_voice_notify(phone, type):
business_id = uuid.uuid4() business_id = uuid.uuid4()
ttsRequest = SingleCallByTtsRequest.SingleCallByTtsRequest() ttsRequest = SingleCallByTtsRequest.SingleCallByTtsRequest()
# 申请的语音通知tts模板编码,必填 # 申请的语音通知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) ttsRequest.set_OutId(business_id)
# 语音通知的被叫号码,必填。 # 语音通知的被叫号码,必填。

View File

@ -6,7 +6,7 @@ import datetime
from polls.decorators import polls_login_required from polls.decorators import polls_login_required
from django.core.exceptions import ObjectDoesNotExist from django.core.exceptions import ObjectDoesNotExist
from polls.models import Message, TaskRecord from polls.models import Message, TaskRecord
from dashboard.models import Userprofile from dashboard.models import Group_user, Userprofile
@csrf_exempt @csrf_exempt
@ -84,5 +84,8 @@ def read_message(request):
if not message_id: if not message_id:
return JsonResponse({'status': 'success', 'message': False}, safe=False) return JsonResponse({'status': 'success', 'message': False}, safe=False)
message = Message.objects.get(id=message_id) 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) return JsonResponse({'status': 'success', 'message': True}, safe=False)

View File

@ -109,12 +109,3 @@ def get_task(request):
result['added'] = task.added.strftime("%Y-%m-%d %H:%M:%S") result['added'] = task.added.strftime("%Y-%m-%d %H:%M:%S")
return JsonResponse({'status': 'success', 'message': result}) 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'})