From c45886bd8645da6522b0f301759248580c8a729f Mon Sep 17 00:00:00 2001 From: lazedo Date: Fri, 10 Feb 2017 15:57:05 +0000 Subject: [PATCH] better handling of initial subscription duplicate --- kamailio/presence-role.cfg | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/kamailio/presence-role.cfg b/kamailio/presence-role.cfg index dc8b597..11962ab 100644 --- a/kamailio/presence-role.cfg +++ b/kamailio/presence-role.cfg @@ -95,7 +95,7 @@ route[HANDLE_RESUBSCRIBE] if(handle_subscribe()) { if($subs(remote_cseq) < 5) { $sht(first=>$subs(callid)) = $null; - $sht(first=>$subs(from_user)::$subs(to_user)::$subs(from_domain)::$subs(event)) = $null; + $sht(first=>$subs(from_user)::$subs(pres_uri)::$subs(from_domain)::$subs(event)) = $null; } route(SUBSCRIBE_AMQP); }; @@ -125,9 +125,13 @@ route[HANDLE_NEW_SUBSCRIBE] sql_query("exec", 'delete from active_watchers where callid = "$ci"'); xlog("L_INFO", "$ci|subscribe|resetting $hdr(Event) subscription from $fU to $tU in realm $fd : $sqlrows(exec)\n"); } else { - if($shtinc(first=>$fU::$tU::$fd::$hdr(Event)) > 1) { - sql_query("exec", 'delete from active_watchers where watcher_username="$fU" and to_user="$tU" and watcher_domain="$fd" and event="$hdr(Event)"'); - xlog("L_INFO", "$ci|subscribe|resetting $hdr(Event) subscription from $fU to $tU in realm $fd : $sqlrows(exec)\n"); + $var(presentity_uri) = $ru; + if($(var(presentity_uri){uri.user}) == "") { + $var(presentity_uri) = $tu; + } + if($shtinc(first=>$fU::$var(presentity_uri)::$fd::$hdr(Event)) > 1) { + sql_query("exec", 'delete from active_watchers where watcher_username="$fU" and presentity_uri="$var(presentity_uri)" and to_user="$tU" and watcher_domain="$fd" and event="$hdr(Event)"'); + xlog("L_INFO", "$ci|subscribe|resetting $hdr(Event) subscription from $fU to $var(presentity_uri) in realm $fd : $sqlrows(exec)\n"); } }