Skip to content

Commit

Permalink
fix: sms_callback
Browse files Browse the repository at this point in the history
Теперь можно прописать call_back в настройках sms.ru и получать обновления статусов отправленных сообщений
  • Loading branch information
iredun committed Jan 19, 2021
1 parent 76366ee commit dabf6f3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 0 additions & 2 deletions smsru/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)


12 changes: 7 additions & 5 deletions smsru/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

0 comments on commit dabf6f3

Please sign in to comment.