]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
Differentiate when the sms message successfully matched an extension in the chatplan...
authorWilliam King <william.king@quentustech.com>
Thu, 15 Nov 2012 00:48:21 +0000 (16:48 -0800)
committerWilliam King <william.king@quentustech.com>
Thu, 15 Nov 2012 00:48:21 +0000 (16:48 -0800)
src/mod/applications/mod_sms/mod_sms.c
src/switch_loadable_module.c

index d90896f74d630e0b1ed55ce2612ffad86ce88b03..15d0de62335818ef6229804b3cf50fc8013553ca 100644 (file)
@@ -395,7 +395,7 @@ static switch_event_t *chatplan_hunt(switch_event_t *event)
 
 static switch_status_t chat_send(switch_event_t *message_event)
                                                                 {
-       switch_status_t status = SWITCH_STATUS_SUCCESS;
+       switch_status_t status = SWITCH_STATUS_BREAK;
        switch_event_t *exten;
        int forwards = 0;
        const char *var;
@@ -428,14 +428,15 @@ static switch_status_t chat_send(switch_event_t *message_event)
                for (hp = exten->headers; hp; hp = hp->next) {
                        status = switch_core_execute_chat_app(message_event, hp->name, hp->value);
                        if (!SWITCH_READ_ACCEPTABLE(status)) {
+                               status = SWITCH_STATUS_SUCCESS; 
                                break;
                        }
                }
 
                switch_event_destroy(&exten);
-               status = SWITCH_STATUS_BREAK;           
+       } else {
+               switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "SMS chatplan no actions found\n");
        }
-       
 
        return status;
 
index a94c274b6d156a87e382d2a181f52274e3d3124d..d63ff074f157797b06e383c448a7c0fb1bacace4 100644 (file)
@@ -564,12 +564,21 @@ static switch_status_t do_chat_send(switch_event_t *message_event)
                        if ((ci = (switch_chat_interface_t *) val)) {
                                if (ci->chat_send && !strncasecmp(ci->interface_name, "GLOBAL_", 7)) {
                                        status = ci->chat_send(message_event);
-                                       if (status == SWITCH_STATUS_BREAK) {
+                                       if (status == SWITCH_STATUS_SUCCESS) {
+                                               /* The event was handled by an extension in the chatplan, 
+                                                * so the event will be duplicated, modified and queued again, 
+                                                * but it won't be processed by the chatplan again.
+                                                * So this copy of the event can be destroyed by the caller.
+                                                */ 
+                                               switch_mutex_unlock(loadable_modules.mutex);
+                                               return SWITCH_STATUS_SUCCESS;
+                                       } else if (status == SWITCH_STATUS_BREAK) {
+                                               /* The event went through the chatplan, but no extension matched
+                                                * to handle the sms messsage. It'll be attempted to be delivered
+                                                * directly, and unless that works the sms delivery will have failed.
+                                                */
                                                do_skip = 1;
-                                               status = SWITCH_STATUS_SUCCESS;
-                                       }
-                                       
-                                       if (status != SWITCH_STATUS_SUCCESS && status != SWITCH_STATUS_BREAK) {
+                                       } else {
                                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Chat Interface Error [%s]!\n", dest_proto);
                                                break;
                                        }