From f5be8ad5c797897909f76b92256042c71938d5d2 Mon Sep 17 00:00:00 2001 From: lazedo Date: Fri, 14 Dec 2018 18:41:56 +0000 Subject: [PATCH] presence detail should query based on active watchers --- kamailio/db_queries_kazoo.cfg | 4 +++- kamailio/presence-query.cfg | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/kamailio/db_queries_kazoo.cfg b/kamailio/db_queries_kazoo.cfg index 315c327..7ce9458 100644 --- a/kamailio/db_queries_kazoo.cfg +++ b/kamailio/db_queries_kazoo.cfg @@ -6,8 +6,10 @@ #!substdef "!KZQ_EVENT_PRESENCE_RESET_DELETE!delete from presentity where domain=\"\$(kzE{kz.json,Realm})\" and username = \"\$(kzE{kz.json,Username})\"!g" #!substdef "!KZQ_HANDLE_NEW_SUBSCRIBE_DELETE1!delete from active_watchers where callid = \"\$ci\"!g" #!substdef "!KZQ_HANDLE_NEW_SUBSCRIBE_DELETE2!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)\"!g" -#!substdef "!KZQ_PRESENCE_SEARCH_DETAIL!select * from active_watchers_log where presentity_uri = \"\$var(presentity_uri)\" and callid in(select callid from active_watchers where presentity_uri = \"\$var(presentity_uri)\")!g" + #!substdef "!KZQ_PRESENCE_SEARCH_SUMMARY!select * from active_watchers where to_domain = \"\$var(Domain)\"!g" +#!substdef "!KZQ_PRESENCE_SEARCH_DETAIL!select a.*, b.time, b.result, b.sent_msg, b.received_msg from active_watchers a left outer join active_watchers_log b on a.presentity_uri = b.presentity_uri and a.event = b.event and a.callid = b.callid where a.presentity_uri = \"\$var(presentity_uri)\" !g" + #!substdef "!KZQ_HAS_PRESENTITY!select count(*) as count from presentity where username = \"\$subs(to_user)\" and domain = \"\$subs(to_domain)\" and event = \"\$subs(event)\"!g" #!substdef "!KZQ_REPLACE_WATCHERS_LOG!REPLACE INTO active_watchers_log (presentity_uri, watcher_username, watcher_domain, event, callid, to_user, to_domain, user_agent, time, result, sent_msg, received_msg) VALUES (\"\$subs(uri)\", \"\$subs(watcher_username)\", \"\$subs(watcher_domain)\", \"\$subs(event)\",\"\$subs(callid)\",\"\$subs(to_user)\",\"\$subs(to_domain)\", '\$(subs(user_agent){s.escape.common}{s.replace,\\\',''}{s.replace,\$\$,})', \$TS, \$notify_reply(\$rs), '\$(mb{s.escape.common}{s.replace,\\\',''}{s.replace,\$\$,})', '\$(notify_reply(\$mb){s.escape.common}{s.replace,\\\',''}{s.replace,\$\$,})')!g" diff --git a/kamailio/presence-query.cfg b/kamailio/presence-query.cfg index 2041cb0..ce48eea 100644 --- a/kamailio/presence-query.cfg +++ b/kamailio/presence-query.cfg @@ -65,7 +65,7 @@ route[PRESENCE_SEARCH_DETAIL] $var(Items) = ""; $var(Query) = $_s(KZQ_PRESENCE_SEARCH_DETAIL); if($var(Event) != "") { - $var(Query) = $var(Query) + $_s( and event = "$var(Event)"); + $var(Query) = $var(Query) + $_s( and a.event = "$var(Event)"); } $var(Query) = $var(Query) + " order by event, watcher_username, callid"; xlog("L_DEBUG", "$ci| STATUS QUERY $var(Query)\n");