From 16b51dfe4bd7730ce2382a3a9ba25b75acd8b7b9 Mon Sep 17 00:00:00 2001 From: lazedo Date: Fri, 23 Jun 2017 12:40:59 +0100 Subject: [PATCH] fix absence of subscriptions/subscribers of an event --- kamailio/nodes-role.cfg | 4 ++-- kamailio/presence-role.cfg | 10 ++++++---- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/kamailio/nodes-role.cfg b/kamailio/nodes-role.cfg index 7fb20a7..9fe4668 100644 --- a/kamailio/nodes-role.cfg +++ b/kamailio/nodes-role.cfg @@ -44,8 +44,8 @@ route[NODES_ADVERTISE_ROUTE] #!ifdef PRESENCE_ROLE route(COUNT_ALL_SUBSCRIBERS); - $var(Subscriptions) = $_s("Subscriptions" : {"message-summary" : $xavp(watchers=>message-summary), "dialog" : $xavp(watchers=>dialog), "presence" : $xavp(watchers=>presence)}); - $var(Subscribers) = $_s("Subscribers" : {"message-summary" : $xavp(watchers=>message-summary_unique), "dialog" : $xavp(watchers=>dialog_unique), "presence" : $xavp(watchers=>presence_unique)}); + $var(Subscriptions) = $_s("Subscriptions" : { $var(Subscriptions) }); + $var(Subscribers) = $_s("Subscribers" : { $var(Subscribers) }); route(COUNT_ALL_PRESENTITIES); $var(Presentities) = $_s("Presentities" : {"message-summary" : $xavp(watchers=>message-summary), "dialog" : $xavp(watchers=>dialog), "presence" : $xavp(watchers=>presence)}); diff --git a/kamailio/presence-role.cfg b/kamailio/presence-role.cfg index 471d1e9..1311968 100644 --- a/kamailio/presence-role.cfg +++ b/kamailio/presence-role.cfg @@ -210,16 +210,18 @@ route[COUNT_ALL_PRESENTITIES] route[COUNT_ALL_SUBSCRIBERS] { $var(Query) = $_s(select a.event, count(distinct watcher_username || "@" || watcher_domain) count_unique, count(*) count from event_list a, active_watchers b where b.event = a.event group by a.event); - $var(p) = "uri=none"; if (sql_xquery("cb", "$var(Query)", "subs") == 1) { + $var(sep) = ""; + $var(Subscribers) = ""; + $var(Subscriptions) = ""; while($xavp(subs) != $null) { - $var(p) = $var(p) + ";" + $xavp(subs=>event) + "=" + $xavp(subs=>count); - $var(p) = $var(p) + ";" + $xavp(subs=>event) + "_unique=" + $xavp(subs=>count_unique); + $var(Subscribers) = $var(Subscribers) + $var(sep) + $_s("$xavp(subs=>event)" : $xavp(subs=>count_unique)); + $var(Subscriptions) = $var(Subscriptions) + $var(sep) + $_s("$xavp(subs=>event)" : $xavp(subs=>count)); + $var(sep) = " , "; pv_unset("$xavp(subs)"); } } - xavp_params_explode($var(p), "watchers"); } route[COUNT_SUBSCRIBERS]