diff --git a/src/mod/endpoints/mod_sofia/sofia_presence.c b/src/mod/endpoints/mod_sofia/sofia_presence.c index fdc3bd4d9a..c6ba6ce749 100644 --- a/src/mod/endpoints/mod_sofia/sofia_presence.c +++ b/src/mod/endpoints/mod_sofia/sofia_presence.c @@ -1417,6 +1417,11 @@ static int sofia_presence_sub_callback(void *pArg, int argc, char **argv, char * } if (!(nh = nua_handle_by_call_id(profile->nua, call_id))) { + + if (mod_sofia_globals.debug_presence > 0) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to find handle for call id %s\n", call_id); + } + goto end; } @@ -1468,12 +1473,18 @@ static int sofia_presence_sub_callback(void *pArg, int argc, char **argv, char * const char *astate = switch_str_nil(switch_event_get_header(helper->event, "astate")); const char *answer_state = switch_str_nil(switch_event_get_header(helper->event, "answer-state")); const char *dft_state; - const char *from_id = switch_str_nil(switch_event_get_header(helper->event, "Other-Leg-Caller-ID-Number")); + const char *from_id; const char *to_user = switch_str_nil(switch_event_get_header(helper->event, "variable_sip_to_user")); const char *from_user = switch_str_nil(switch_event_get_header(helper->event, "variable_sip_from_user")); char *clean_to_user = NULL; char *clean_from_user = NULL; int force_status = 0; + + if (!strcasecmp(direction, "inbound")) { + from_id = switch_str_nil(switch_event_get_header(helper->event, "Caller-Destination-Number")); + } else { + from_id = switch_str_nil(switch_event_get_header(helper->event, "Other-Leg-Caller-ID-Number")); + } #if 0 char *buf; switch_event_serialize(helper->event, &buf, SWITCH_FALSE);