]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
if user has set presence_id, don't override it
authorTravis Cross <tc@traviscross.com>
Wed, 13 Jul 2011 04:32:00 +0000 (04:32 +0000)
committerTravis Cross <tc@traviscross.com>
Wed, 13 Jul 2011 07:08:18 +0000 (07:08 +0000)
src/mod/endpoints/mod_sofia/mod_sofia.c
src/mod/endpoints/mod_sofia/sofia.c

index 8504dc137e15a61f52a3b77d1dce9f3cc03df240..7ebbe33f701a1d23053b9e92ab03bd84f224bff0 100644 (file)
@@ -4358,7 +4358,10 @@ static switch_call_cause_t sofia_outgoing_channel(switch_core_session_t *session
        if (tech_pvt->local_url) {
                switch_channel_set_variable(nchannel, "sip_local_url", tech_pvt->local_url);
                if (profile->pres_type) {
-                       switch_channel_set_variable(nchannel, "presence_id", tech_pvt->local_url);
+                       const char *presence_id = switch_channel_get_variable(nchannel, "presence_id");
+                       if (zstr(presence_id)) {
+                               switch_channel_set_variable(nchannel, "presence_id", tech_pvt->local_url);
+                       }
                }
        }
        switch_channel_set_variable(nchannel, "sip_destination_url", tech_pvt->dest);
index 8817062e590cd2d56807a5332c347041d51c4db5..6823acf13394d846dca2106efa1e36dee83b9170 100644 (file)
@@ -7501,13 +7501,15 @@ void sofia_handle_sip_i_invite(nua_t *nua, sofia_profile_t *profile, nua_handle_
        }
 
        if (profile->pres_type) {
-               const char *user = switch_str_nil(sip->sip_from->a_url->url_user);
-               const char *host = switch_str_nil(sip->sip_from->a_url->url_host);
-
-               char *tmp = switch_mprintf("%s@%s", user, host);
-               switch_assert(tmp);
-               switch_channel_set_variable(channel, "presence_id", tmp);
-               free(tmp);
+               const char *presence_id = switch_channel_get_variable(channel, "presence_id");
+               if (zstr(presence_id)) {
+                       const char *user = switch_str_nil(sip->sip_from->a_url->url_user);
+                       const char *host = switch_str_nil(sip->sip_from->a_url->url_host);
+                       char *tmp = switch_mprintf("%s@%s", user, host);
+                       switch_assert(tmp);
+                       switch_channel_set_variable(channel, "presence_id", tmp);
+                       free(tmp);
+               }
        }