(domain, contact, phone_number, text, metadata=None, logged_subevent=None)
return queue_outgoing_sms(msg)
Sends an outbound SMS. Returns false if it fails.
Sends an outbound SMS. Returns false if it fails.
Sends an outbound SMS . Returns false if it fails .
def send_sms(domain, contact, phone_number, text, metadata=None, logged_subevent=None):
    """
    Sends an outbound SMS. Returns false if it fails.
    """
    if phone_number is None:
        return False
    if isinstance(phone_number, int):
        phone_number = str(phone_number)
    phone_number = clean_phone_number(phone_number)

    msg = get_sms_class()(
        domain=domain,
        phone_number=phone_number,
        direction=OUTGOING,
        date=get_utcnow(),
        backend_id=None,
        location_id=get_location_id_by_contact(domain, contact),
        text=text
    )
    if contact:
        msg.couch_recipient = contact.get_id
        msg.couch_recipient_doc_type = contact.doc_type

    if domain and contact and is_commcarecase(contact):
        backend_name = contact.get_case_property('contact_backend_id')
        backend_name = backend_name.strip() if isinstance(backend_name, str) else ''

        if backend_name:
            try:
                backend = SQLMobileBackend.load_by_name(SQLMobileBackend.SMS, domain, backend_name)
            except BadSMSConfigException as e:
                if logged_subevent:
                    logged_subevent.error(MessagingEvent.ERROR_GATEWAY_NOT_FOUND,
                        additional_error_text=str(e))
                return False

            msg.backend_id = backend.couch_id

    add_msg_tags(msg, metadata)

    return queue_outgoing_sms(msg)
def send_sms ( domain , contact , phone_number , text , metadata = None , logged_subevent = None ) : if phone_number is None : return False if isinstance ( phone_number , int ) : phone_number = str ( phone_number ) phone_number = clean_phone_number ( phone_number ) msg = get_sms_class ( ) ( domain = domain , phone_number = phone_number , direction = OUTGOING , date = get_utcnow ( ) , backend_id = None , location_id = get_location_id_by_contact ( domain , contact ) , text = text ) if contact : msg . couch_recipient = contact . get_id msg . couch_recipient_doc_type = contact . doc_type if domain and contact and is_commcarecase ( contact ) : backend_name = contact . get_case_property ( 'contact_backend_id' ) backend_name = backend_name . strip ( ) if isinstance ( backend_name , str ) else '' if backend_name : try : backend = SQLMobileBackend . load_by_name ( SQLMobileBackend . SMS , domain , backend_name ) except BadSMSConfigException as e : if logged_subevent : logged_subevent . error ( MessagingEvent . ERROR_GATEWAY_NOT_FOUND , additional_error_text = str ( e ) ) return False msg . backend_id = backend . couch_id add_msg_tags ( msg , metadata ) return queue_outgoing_sms ( msg )