diff --git a/smsru/service.py b/smsru/service.py index ae309ce..d92d770 100644 --- a/smsru/service.py +++ b/smsru/service.py @@ -130,5 +130,3 @@ def send_multi_sms(self, phone_sms: dict) -> dict: post_param['multi'][phone_beautify] = msg return self._sms_request(post_param) - - diff --git a/smsru/views.py b/smsru/views.py index ce7a634..1544009 100644 --- a/smsru/views.py +++ b/smsru/views.py @@ -8,11 +8,13 @@ @csrf_exempt def sms_callback(request): if request.method == 'POST': - data = request.POST.getlist('data[]') + data = [item[1][0].split('\n') for item in request.POST.lists() if 'data[' in item[0]] hash = request.POST.get('hash') api = SmsRuApi() - if api.validate_callback(data, hash): - item = Log.objects.filter(sms_id=data[1]).first() - item.status_code = data[2] - item.save() + if api.validate_callback(["\n".join(el) for el in data], hash): + for data_item in data: + item = Log.objects.filter(sms_id=data_item[1]).first() + if item: + item.status_code = data_item[2] + item.save() return HttpResponse(100)