switch_channel_set_variable(channel, SWITCH_BRIDGE_VARIABLE, NULL);
switch_channel_set_variable(other_channel, SWITCH_BRIDGE_VARIABLE, NULL);
- if (switch_channel_get_state(other_channel) < CS_HANGUP
+ if (switch_channel_test_flag(other_channel, CF_ANSWERED) && switch_channel_get_state(other_channel) < CS_HANGUP
&& switch_true(switch_channel_get_variable(other_channel, SWITCH_HANGUP_AFTER_BRIDGE_VARIABLE))) {
switch_channel_hangup(other_channel, switch_channel_get_cause(channel));
} else {
done:
- if (switch_channel_get_state(caller_channel) < CS_HANGUP &&
+ if (switch_channel_test_flag(caller_channel, CF_ANSWERED) && switch_channel_get_state(caller_channel) < CS_HANGUP &&
switch_true(switch_channel_get_variable(caller_channel, SWITCH_HANGUP_AFTER_BRIDGE_VARIABLE))) {
switch_channel_hangup(caller_channel, switch_channel_get_cause(peer_channel));
}