#!substdef "!KZQ_RESET_ACCOUNT_DELETE!delete from presentity where domain=\"\$(kzE{kz.json,Realm})\"!g"
#!substdef "!KZQ_RESET_ACCOUNT_UPDATE!update active_watchers set expires = \$TS where watcher_domain=\"\$(kzE{kz.json,Realm})\"!g"
#!substdef "!KZQ_RESET_PUBLISHER_UPDATE!update active_watchers set expires = \$TS where id in (select b.id from presentity a inner join active_watchers b on a.username = b.to_user and a.domain = b.to_domain and a.event = b.event where a.sender = \"\$var(MediaUrl)\")!g"
#!substdef "!KZQ_PRESENCE_SEARCH_DETAIL!select * from active_watchers_log where presentity_uri = \"\$var(presentity_uri)\"!g"
#!substdef "!KZQ_PRESENCE_SEARCH_SUMMARY!select * from active_watchers where watcher_domain = \"\$var(Domain)\"!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_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_PRESENCE_RESET!delete from presentity where sender = \"\$var(MediaUrl)\"!g"
sql_query("exec", "insert into dispatcher (setid, destination, flags, attrs, description) select $var(SetId), \"$var(MediaUrl)\", $var(flags), \"$var(attrs)\", \"added by nodes role\" where not exists(select * from dispatcher where destination=\"$var(MediaUrl)\")");
@ -63,12 +64,10 @@ kazoo.presence_ignore_status_probe_resp = KZ_PRESENCE_IGNORE_STATUS_PROBE_RESP d
#!ifdef FAST_PICKUP_ROLE
#!include_file "fast-pickup-role.cfg"
#!endif
#!ifdef PRESENCE_QUERY_ROLE
#!include_file "presence_query-role.cfg"
#!endif
#!ifdef PRESENCE_NOTIFY_SYNC_ROLE
#!include_file "presence_notify_sync-role.cfg"
#!endif
#!include_file "presence-query.cfg"
#!include_file "presence-notify.cfg"
#!include_file "presence-reset.cfg"
####### Presence Logic ########
@ -90,8 +89,25 @@ route[HANDLE_SUBSCRIBE]
return;
}
if ($hdr(Event) !="dialog"
&& $hdr(Event) !="presence"
&& $hdr(Event) !="message-summary") {
xlog("L_INFO", "$ci|presence|subscribe event $hdr(Event) not supported\n");
send_reply(489, "Bad Event");
exit();
}
if (!t_newtran()) {
sl_reply_error();
exit;
}
#!ifdef SIP_TRACE_ROLE
route(SEND_SIP_TRACE);
#!endif
#!ifdef NAT_TRAVERSAL_ROLE
route(PRESENCE_NAT);
route(PRESENCE_NAT);
#!endif
if(has_totag()) {
@ -100,11 +116,6 @@ route[HANDLE_SUBSCRIBE]
record_route();
if (!t_newtran()) {
sl_reply_error();
exit;
}
if(has_totag()) {
route(HANDLE_RESUBSCRIBE);
} else {
@ -116,6 +127,11 @@ route[HANDLE_SUBSCRIBE]
exit;
}
route[DELETE_DUPLICATED_SUBSCRIPTIONS]
{
sql_query("exec", '$_s(DELETE FROM ACTIVE_WATCHERS WHERE FROM_USER="$subs(from_user)" AND FROM_DOMAIN="$subs(from_domain)" AND EVENT="$subs(event)" AND PRESENTITY_URI="$subs(uri)" AND CALLID <> "$subs(callid)")');
xlog("L_INFO", "$(kzE{kz.json,Call-ID})|log|received $(kzE{kz.json,Event-Package}) update for $(kzE{kz.json,From}) state $(kzE{kz.json,State}) from $(kzE{kz.json,Switch-URI}) at $(kzE{kz.json,AMQP-Received})/$var(Now)\n");
xlog("L_INFO", "$(kzE{kz.json,Call-ID})|log|received $(kzE{kz.json,Event-Package}) update for $(kzE{kz.json,From}) state $(kzE{kz.json,State}) from $(kzE{kz.json,AMQP-Broker-Zone})=> $(kzE{kz.json,Switch-URI}) (Δ1 $(kzE{kz.json,AMQP-Elapsed-Micro}) μs , Δ2 $var(delta_to_start) μs)\n");
$var(JObj)=$kzE;
#!ifdef FAST_PICKUP_ROLE
route(FAST_PICKUP_INIT);
#!endif
$var(presentity)=$(kzE{kz.json,From});
$var(payload)=$kzE;
route(PRESENCE_UPDATE);
xlog("L_INFO", "$(kzE{kz.json,Call-ID})|log|finished processing $(kzE{kz.json,Event-Package}) update for $(kzE{kz.json,From}) state $(kzE{kz.json,State}) from $(kzE{kz.json,Switch-URI}) at $(kzE{kz.json,AMQP-Received})/$var(Now)/$TS\n");
xlog("L_DEBUG", "$(kzE{kz.json,Call-ID})|log|skip message-summary update for $(kzE{kz.json,From})\n");
}
route(MWI_AS_PRESENCE);
xlog("L_INFO", "$(kzE{kz.json,Call-ID})|log|finished processing message-summary update for $(kzE{kz.json,From}) light should be on ? $(kzE{kz.json,Messages-Waiting}) at $(kzE{kz.json,AMQP-Received})/$var(Now)/$TS\n");
xlog("L_DBG", "$(kzE{kz.json,Call-ID})|log|finished processing message-summary update for $(kzE{kz.json,From}) light should be on ? $(kzE{kz.json,Messages-Waiting}) at $(kzE{kz.json,AMQP-Received})/$var(Now)/$TS\n");
xlog("L_INFO", "$(kzE{kz.json,Call-ID})|log|finished processing $(kzE{kz.json,Event-Package}) update for $(kzE{kz.json,From}) state $(kzE{kz.json,State}) from $(kzE{kz.json,Switch-URI}) at $(kzE{kz.json,AMQP-Received})/$var(Now)/$TS\n");
xlog("L_DEBUG", "$(kzE{kz.json,Call-ID})|log|finished processing $(kzE{kz.json,Event-Package}) update for $(kzE{kz.json,From}) state $(kzE{kz.json,State}) from $(kzE{kz.json,Switch-URI}) Δ at $(kzE{kz.json,AMQP-Received})/$var(Now)/$TS\n");
}
route[PRESENCE_UPDATE]
@ -366,20 +401,23 @@ route[PRESENCE_UPDATE]
}
if($xavp(watchers=>dialog) > 0) {
xlog("L_INFO", "$(var(payload){kz.json,Call-ID})|log|publishing $var(presentity) dialog update for $xavp(watchers=>dialog) watchers\n");