예제 #1
0
def send_marketing_sms_job(receivers, sms_code, promotional, message=None, template=None):
    sms_provider = get_current_sms_provider()
    receiver_list = get_receiver_list(receivers, sms_provider.max_receiver_count)
    if len(receiver_list) == 1:
        receivers = receiver_list[0]
        send(receivers, sms_code, transactional=False, promotional=promotional, message=message, template=template)
    else:
        for receivers_ in receiver_list:
            queue().enqueue(send_marketing_sms_job, receivers=receivers_, sms_code=sms_code, promotional=promotional, message=message, template=template)
예제 #2
0
def send_transactional_sms_job(receivers, sms_code, promotional, last_sms_code=None, message=None, template=None):
    sms_provider = get_current_sms_provider()
    receiver_list = get_receiver_list(receivers, sms_provider.max_receiver_count)
    if len(receiver_list) == 1:
        receivers = receiver_list[0]
        send(receivers, sms_code, last_sms_code=last_sms_code, promotional=promotional, message=message, template=template)
        with redis().pipeline() as pipe:
            for receiver in receivers:
                pipe.setex(sent_sms_redis_key(receiver, sms_code), SENT_SMS_RECORD_ALIVE_IN_SECONDS, sms_provider.sms_provider_id)
            pipe.execute()
    else:
        for receivers_ in receiver_list:
            queue().enqueue(send_transactional_sms_job, receivers=receivers_, sms_code=sms_code, promotional=promotional, last_sms_code=last_sms_code,
                            message=message, template=template)
예제 #3
0
def send_sms(receivers, sms_code, transactional=False, promotional=True, last_sms_code=None, message=None, template=None):
    assert message is not None or template is not None, 'message or template must be provided'
    if transactional:
        if promotional:
            queue().enqueue(send_slow_transactional_sms_job, receivers=receivers, sms_code=sms_code, promotional=promotional, message=message,
                            template=to_json(template))
        else:
            queue().enqueue(send_transactional_sms_job, receivers=receivers, sms_code=sms_code, promotional=promotional, last_sms_code=last_sms_code,
                            message=message, template=to_json(template))
    else:
        queue().enqueue(send_marketing_sms_job, receivers=receivers, sms_code=sms_code, promotional=promotional, message=message, template=to_json(template))
예제 #4
0
def send_validation_code_via_voice(receiver, code, sms_code, last_sms_code=None):
    queue().enqueue(send_voice_validation_code_job, receiver=receiver, code=code, sms_code=sms_code, last_sms_code=last_sms_code)