32 lines
940 B
Python
32 lines
940 B
Python
from __future__ import absolute_import, unicode_literals
|
|
|
|
from celery import shared_task
|
|
from apps.notifications.models import Notification
|
|
from django.conf import settings
|
|
from gooyal_accounts.celery import app
|
|
from kavenegar import *
|
|
api = KavenegarAPI(settings.SMS_KAVENEGAR_TOKEN)
|
|
|
|
@shared_task
|
|
def send_sms(notification_uuid):
|
|
notification = Notification.objects.get(uuid=notification_uuid)
|
|
params = {
|
|
'sender': settings.SMS_KAVENEGAR_SENDER,
|
|
'receptor': notification.phone_number,
|
|
'message': notification.body
|
|
}
|
|
response = api.sms_send(params)
|
|
mock_response = [
|
|
{'messageid': 1088480346,
|
|
'message': 'Gooyal OTP: 12345',
|
|
'status': 1,
|
|
'statustext': 'در صف ارسال',
|
|
'sender': '1000596446',
|
|
'receptor': '09106853582',
|
|
'date': 1584797465,
|
|
'cost': 402
|
|
}
|
|
]
|
|
# notification.state =
|
|
|
|
print(response)
|