]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
FS-3635 --resolve
authorAnthony Minessale <anthm@freeswitch.org>
Tue, 25 Oct 2011 12:42:08 +0000 (07:42 -0500)
committerAnthony Minessale <anthm@freeswitch.org>
Tue, 25 Oct 2011 12:42:08 +0000 (07:42 -0500)
src/mod/applications/mod_sms/mod_sms.c

index 5c1e8c5ab5bce293a9d7a29829dbe48be2e644b8..50778da81f6ca9f61a3b626f223f85b4a1400ed9 100644 (file)
@@ -368,7 +368,31 @@ static switch_status_t chat_send(switch_event_t *message_event)
                                                                 {
        switch_status_t status = SWITCH_STATUS_SUCCESS;
        switch_event_t *exten;
-       
+       int forwards = 0;
+       const char *var;
+
+       var = switch_event_get_header(message_event, "max_forwards");
+
+       if (!var) {
+               forwards = 70;
+       } else {
+               forwards = atoi(var);
+               
+               if (forwards) {
+                       forwards--;
+               }
+
+               if (!forwards) {
+                       switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Max forwards reached\n");
+                       DUMP_EVENT(message_event);
+                       return SWITCH_STATUS_FALSE;
+               }
+       }
+
+       if (forwards) {
+               switch_event_add_header(message_event, SWITCH_STACK_BOTTOM, "max_forwards", "%d", forwards);
+       }
+
        if ((exten = chatplan_hunt(message_event))) {
                switch_event_header_t *hp;
                
@@ -402,6 +426,8 @@ SWITCH_STANDARD_CHAT_APP(send_function)
                dest_proto = switch_event_get_header(message, "dest_proto");
        }
 
+       switch_event_add_header(message, SWITCH_STACK_BOTTOM, "skip_global_process", "true");
+
        switch_core_chat_send(dest_proto, message);
 
        return SWITCH_STATUS_SUCCESS;