]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
FS-6688: don't update the contact when the original had fs_path, the new one doesnt...
authorMichael Jerris <mike@jerris.com>
Thu, 4 Dec 2014 17:34:05 +0000 (12:34 -0500)
committerMichael Jerris <mike@jerris.com>
Wed, 10 Dec 2014 15:33:43 +0000 (10:33 -0500)
src/mod/endpoints/mod_sofia/sofia_presence.c

index 4c0e3be89ec30864c6940f51245e4a155375eb2c..69a86668d2196006211c630dc6a1eaa4ba171fd7 100644 (file)
@@ -3882,7 +3882,7 @@ void sofia_presence_handle_sip_i_subscribe(int status,
        }
 
        if ((sub_state != nua_substate_terminated)) {
-               sql = switch_mprintf("select call_id from sip_subscriptions where call_id='%q' and profile_name='%q' and hostname='%q'",
+               sql = switch_mprintf("select contact from sip_subscriptions where call_id='%q' and profile_name='%q' and hostname='%q'",
                                                         call_id, profile->name, mod_sofia_globals.hostname);
                sofia_glue_execute_sql2str(profile, profile->dbh_mutex, sql, buf, sizeof(buf));
 
@@ -3900,15 +3900,24 @@ void sofia_presence_handle_sip_i_subscribe(int status,
        }
 
        if (sub_state == nua_substate_active) {
+               char *contact = contact_str;
 
                sstr = switch_mprintf("active;expires=%ld", exp_delta);
                
+               if (strstr(buf, "fs_path=") && !strstr(contact_str, "fs_path=")) {
+                       char *e = strchr(buf,';');
+                       size_t l = e ? buf-e : strlen(buf);
+                       if (strncmp(contact_str,buf,l)) {
+                               contact = buf;
+                       }
+               }
+
                sql = switch_mprintf("update sip_subscriptions "
                                                         "set expires=%ld, "
-                                                        "network_ip='%q',network_port='%d',sip_user='%q',sip_host='%q',full_via='%q',full_to='%q',full_from='%q' "
+                                                        "network_ip='%q',network_port='%d',sip_user='%q',sip_host='%q',full_via='%q',full_to='%q',full_from='%q',contact='%q' "
                                                         "where call_id='%q' and profile_name='%q' and hostname='%q'",
                                                         (long) switch_epoch_time_now(NULL) + exp_delta, 
-                                                        np.network_ip, np.network_port, from_user, from_host, full_via, full_to, full_from,
+                                                        np.network_ip, np.network_port, from_user, from_host, full_via, full_to, full_from, contact,
                                                         
                                                         call_id, profile->name, mod_sofia_globals.hostname);