]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
FS-8652 handle early-only param in replaces header
authorLuis Azedo <luis@2600hz.com>
Sun, 13 Dec 2015 15:28:26 +0000 (15:28 +0000)
committerLuis Azedo <luis@2600hz.com>
Mon, 23 May 2016 17:59:42 +0000 (18:59 +0100)
src/mod/endpoints/mod_sofia/sofia.c

index 5269b720ca08ce019e2b166d830600bc98e370d2..d2f06b5586acaca817aeb62e17b3840f5e395d2a 100644 (file)
@@ -10306,13 +10306,20 @@ void sofia_handle_sip_i_invite(switch_core_session_t *session, nua_t *nua, sofia
                                                }
                                        } else {
                                                if (!zstr(bridge_uuid)) {
-                                                       switch_channel_mark_hold(b_channel, SWITCH_FALSE);
-                                                       tech_pvt->caller_profile->destination_number = switch_core_sprintf(tech_pvt->caller_profile->pool, "answer,intercept:%s", bridge_uuid);
-                                                       if (sofia_test_pflag(profile, PFLAG_FIRE_TRANFER_EVENTS)
-                                                               && switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, MY_EVENT_INTERCEPTED) == SWITCH_STATUS_SUCCESS) {
-                                                               switch_channel_event_set_data(b_channel, event);
-                                                               switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "intercepted_by", sip->sip_call_id->i_id);
-                                                               switch_event_fire(&event);
+                                                       if (sip->sip_replaces && sip->sip_replaces->rp_params && sip->sip_replaces->rp_call_id && switch_channel_test_flag(b_channel, CF_BRIDGED) &&
+                                                               switch_true(switch_find_parameter(*(sip->sip_replaces->rp_params), "early-only", switch_core_session_get_pool(session)))) {
+                                                               switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "call %s intercept rejected\n", bridge_uuid);
+                                                               tech_pvt->caller_profile->destination_number = switch_core_sprintf(tech_pvt->caller_profile->pool, "hangup:CALL_REJECTED");
+                                                       } else {
+                                                                       switch_channel_mark_hold(b_channel, SWITCH_FALSE);
+                                                                       tech_pvt->caller_profile->destination_number = switch_core_sprintf(tech_pvt->caller_profile->pool, "answer,intercept:%s", bridge_uuid);
+                                                                       switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "call %s intercepted\n", bridge_uuid);
+                                                                       if (sofia_test_pflag(profile, PFLAG_FIRE_TRANFER_EVENTS) &&
+                                                                               switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, MY_EVENT_INTERCEPTED) == SWITCH_STATUS_SUCCESS) {
+                                                                                       switch_channel_event_set_data(b_channel, event);
+                                                                                       switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "intercepted_by", sip->sip_call_id->i_id);
+                                                                                       switch_event_fire(&event);
+                                                                       }
                                                        }
                                                } else {
                                                        const char *b_app = switch_channel_get_variable(b_channel, SWITCH_CURRENT_APPLICATION_VARIABLE);