diff --git a/src/mod/endpoints/mod_sofia/mod_sofia.h b/src/mod/endpoints/mod_sofia/mod_sofia.h index 32f0af7441..ec036e0aea 100644 --- a/src/mod/endpoints/mod_sofia/mod_sofia.h +++ b/src/mod/endpoints/mod_sofia/mod_sofia.h @@ -874,8 +874,6 @@ switch_status_t sofia_glue_do_invite(switch_core_session_t *session); uint8_t sofia_glue_negotiate_sdp(switch_core_session_t *session, const char *r_sdp); -void sofia_presence_establish_presence(sofia_profile_t *profile); - void sofia_handle_sip_i_refer(nua_t *nua, sofia_profile_t *profile, nua_handle_t *nh, switch_core_session_t *session, sip_t const *sip, sofia_dispatch_event_t *de, tagi_t tags[]); diff --git a/src/mod/endpoints/mod_sofia/sofia.c b/src/mod/endpoints/mod_sofia/sofia.c index 00d291f8db..3e287248d5 100644 --- a/src/mod/endpoints/mod_sofia/sofia.c +++ b/src/mod/endpoints/mod_sofia/sofia.c @@ -2022,10 +2022,6 @@ void *SWITCH_THREAD_FUNC sofia_profile_thread_run(switch_thread_t *thread, void sofia_glue_add_profile(profile->name, profile); - if (profile->pres_type) { - sofia_presence_establish_presence(profile); - } - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Starting thread for %s\n", profile->name); profile->started = switch_epoch_time_now(NULL); diff --git a/src/mod/endpoints/mod_sofia/sofia_glue.c b/src/mod/endpoints/mod_sofia/sofia_glue.c index d685091e6b..947eeb1e9f 100644 --- a/src/mod/endpoints/mod_sofia/sofia_glue.c +++ b/src/mod/endpoints/mod_sofia/sofia_glue.c @@ -6092,11 +6092,11 @@ int sofia_glue_init_sql(sofia_profile_t *profile) } - test_sql = switch_mprintf("delete from sip_registrations where (contact like '%%TCP%%' " + test_sql = switch_mprintf("delete from sip_registrations where (sub_host is null or contact like '%%TCP%%' " "or status like '%%TCP%%' or status like '%%TLS%%') and hostname='%q' " "and network_ip like '%%' and network_port like '%%' and sip_username " "like '%%' and mwi_user like '%%' and mwi_host like '%%' " - "and orig_server_host like '%%' and orig_hostname like '%%' and sub_host like '%%'", mod_sofia_globals.hostname); + "and orig_server_host like '%%' and orig_hostname like '%%'", mod_sofia_globals.hostname); switch_cache_db_test_reactive(dbh, test_sql, "drop table sip_registrations", reg_sql); diff --git a/src/mod/endpoints/mod_sofia/sofia_presence.c b/src/mod/endpoints/mod_sofia/sofia_presence.c index e5f98b75c5..9389c3209f 100644 --- a/src/mod/endpoints/mod_sofia/sofia_presence.c +++ b/src/mod/endpoints/mod_sofia/sofia_presence.c @@ -384,25 +384,6 @@ void sofia_presence_cancel(void) } } -void sofia_presence_establish_presence(sofia_profile_t *profile) -{ - struct resub_helper h = { 0 }; - h.profile = profile; - - if (sofia_glue_execute_sql_callback(profile, profile->ireg_mutex, - "select sip_user,sip_host,'Registered','unknown','' from sip_registrations", - sofia_presence_resub_callback, &h) != SWITCH_TRUE) { - return; - } - - if (sofia_glue_execute_sql_callback(profile, profile->ireg_mutex, - "select sub_to_user,sub_to_host,'Online','unknown',proto from sip_subscriptions " - "where expires > -1 and version > -1 and proto='ext' or proto='user' or proto='conf'", - sofia_presence_resub_callback, &h) != SWITCH_TRUE) { - return; - } -} - char *sofia_presence_translate_rpid(char *in, char *ext) { char *r = in; diff --git a/src/mod/endpoints/mod_sofia/sofia_reg.c b/src/mod/endpoints/mod_sofia/sofia_reg.c index 8c73bd08ff..ba159c7f7f 100644 --- a/src/mod/endpoints/mod_sofia/sofia_reg.c +++ b/src/mod/endpoints/mod_sofia/sofia_reg.c @@ -1090,10 +1090,10 @@ uint8_t sofia_reg_handle_register(nua_t *nua, sofia_profile_t *profile, nua_hand switch_goto_int(r, 1, end); } - if (!reg_host) { + if (zstr(reg_host)) { reg_host = to_host; } - if (!sub_host) { + if (zstr(sub_host)) { sub_host = to_host; } @@ -1526,7 +1526,12 @@ uint8_t sofia_reg_handle_register(nua_t *nua, sofia_profile_t *profile, nua_hand agent, from_user, guess_ip4, profile->name, mod_sofia_globals.hostname, network_ip, network_port_c, username, realm, mwi_user, mwi_host, guess_ip4, mod_sofia_globals.hostname, sub_host); } else { - sql = switch_mprintf("update sip_registrations set expires = %ld where sip_user='%q' and sip_host='%q' and contact='%q'", (long) switch_epoch_time_now(NULL) + (long) exptime + 60, to_user, reg_host, contact_str); + sql = switch_mprintf("update sip_registrations set " + "sub_host='%q', network_ip='%q',network_port='%q'," + "expires = %ld where sip_user='%q' and sip_host='%q' and contact='%q'", + sub_host, network_ip, network_port_c, + (long) switch_epoch_time_now(NULL) + (long) exptime + 60, + to_user, reg_host, contact_str); } if (sql) {