switch_core_hash_init(&sh->hash, sh->pool);
sql = switch_mprintf("select sip_from_user,sip_from_host,call_info,call_info_state,uuid from sip_dialogs "
- "where hostname='%q' and ((sip_from_user='%q' and sip_from_host='%q') or presence_id='%q@%q')",
+ "where call_info_state is not null and hostname='%q' and ((sip_from_user='%q' and sip_from_host='%q') or presence_id='%q@%q')",
mod_sofia_globals.hostname, to_user, to_host, to_user, to_host);
if (hangup_cause == SWITCH_CAUSE_LOSE_RACE) {
+ switch_channel_presence(channel, "unknown", "cancelled", NULL);
switch_channel_set_variable(channel, "presence_call_info", NULL);
}