]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
FS-7464 mod_callcenter moh-sound needs to be expanded when containing variables.
authorItalo Rossi <italorossib@gmail.com>
Sun, 3 May 2015 23:25:42 +0000 (20:25 -0300)
committerItalo Rossi <italorossib@gmail.com>
Sun, 3 May 2015 23:25:42 +0000 (20:25 -0300)
src/mod/applications/mod_callcenter/mod_callcenter.c

index 6db5f8a2cd9608e7ab2cff893f459faf73a838a4..fcf89a6845749c16f39d0fbabe890bb8efc13d92 100644 (file)
@@ -25,7 +25,7 @@
  * 
  * Marc Olivier Chouinard <mochouinard@moctel.com>
  * Emmanuel Schmidbauer <e.schmidbauer@gmail.com>
- *
+ * Ítalo Rossi <italorossib@gmail.com>
  *
  * mod_callcenter.c -- Call Center Module
  *
@@ -2518,6 +2518,7 @@ SWITCH_STANDARD_APP(callcenter_function)
        const char *cc_base_score = switch_channel_get_variable(member_channel, "cc_base_score");
        int cc_base_score_int = 0;
        const char *cur_moh = NULL;
+       char *moh_expanded = NULL;
        char start_epoch[64];
        switch_event_t *event;
        switch_time_t t_member_called = local_epoch_time_now(NULL);
@@ -2679,6 +2680,7 @@ SWITCH_STANDARD_APP(callcenter_function)
                cur_moh = switch_core_session_strdup(member_session, queue->moh);
        }
        queue_rwunlock(queue);
+       moh_expanded = switch_channel_expand_variables(member_channel, cur_moh);
 
        while (switch_channel_ready(member_channel)) {
                switch_input_args_t args = { 0 };
@@ -2701,9 +2703,8 @@ SWITCH_STANDARD_APP(callcenter_function)
 
                switch_core_session_flush_private_events(member_session);
 
-               if (moh_valid && cur_moh) {
-                       switch_status_t status = switch_ivr_play_file(member_session, NULL, cur_moh, &args);
-
+               if (moh_valid && moh_expanded) {
+                       switch_status_t status = switch_ivr_play_file(member_session, NULL, moh_expanded, &args);
                        if (status == SWITCH_STATUS_FALSE /* Invalid Recording */ && SWITCH_READ_ACCEPTABLE(status)) { 
                                /* Sadly, there doesn't seem to be a return to switch_ivr_play_file that tell you the file wasn't found.  FALSE also mean that the channel got switch to BRAKE state, so we check for read acceptable */
                                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(member_session), SWITCH_LOG_WARNING, "Couldn't play file '%s', continuing wait with no audio\n", cur_moh);
@@ -2724,6 +2725,9 @@ SWITCH_STANDARD_APP(callcenter_function)
                }
                switch_yield(1000);
        }
+       if (moh_expanded != cur_moh) {
+               switch_safe_free(moh_expanded);
+       }
 
        /* Make sure an agent was found, as we might break above without setting it */
        if (!agent_found && (p = switch_channel_get_variable(member_channel, "cc_agent_found"))) {