From b8f0d11a8a32446637ff6ef3d783a0cd68bc5abf Mon Sep 17 00:00:00 2001 From: William King Date: Wed, 14 Nov 2012 16:45:32 -0800 Subject: [PATCH] Fire an event on successful sms delivery, as well as clearify if the delivery method was blocking or not. --- src/mod/applications/mod_sms/mod_sms.c | 3 +++ src/switch_loadable_module.c | 19 +++++++++++++------ 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/src/mod/applications/mod_sms/mod_sms.c b/src/mod/applications/mod_sms/mod_sms.c index 372e7903b5..d90896f74d 100644 --- a/src/mod/applications/mod_sms/mod_sms.c +++ b/src/mod/applications/mod_sms/mod_sms.c @@ -50,6 +50,9 @@ static void event_handler(switch_event_t *event) switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Delivery Failure\n"); DUMP_EVENT(event); + return; + } else if ( check_failure && switch_false(check_failure) ) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "SMS Delivery Success\n"); return; } diff --git a/src/switch_loadable_module.c b/src/switch_loadable_module.c index 26e93a8071..a94c274b6d 100644 --- a/src/switch_loadable_module.c +++ b/src/switch_loadable_module.c @@ -512,6 +512,7 @@ static switch_status_t do_chat_send(switch_event_t *message_event) switch_chat_interface_t *ci; switch_status_t status = SWITCH_STATUS_FALSE; switch_hash_index_t *hi; + switch_event_t *dup = NULL; const void *var; void *val; const char *proto; @@ -588,14 +589,20 @@ static switch_status_t do_chat_send(switch_event_t *message_event) } } - if (status != SWITCH_STATUS_SUCCESS) { - switch_event_t *dup; - switch_event_dup(&dup, message_event); - switch_event_add_header_string(dup, SWITCH_STACK_BOTTOM, "Delivery-Failure", "true"); - switch_event_fire(&dup); + + switch_event_dup(&dup, message_event); + + if ( switch_true(switch_event_get_header(message_event, "blocking")) ) { + if (status == SWITCH_STATUS_SUCCESS) { + switch_event_add_header_string(dup, SWITCH_STACK_BOTTOM, "Delivery-Failure", "false"); + } else { + switch_event_add_header_string(dup, SWITCH_STACK_BOTTOM, "Delivery-Failure", "true"); + } + } else { + switch_event_add_header_string(dup, SWITCH_STACK_BOTTOM, "Nonblocking-Delivery", "true"); } - + switch_event_fire(&dup); return status; }