From 73f4875d2180828bba0ba65431cddf8552344814 Mon Sep 17 00:00:00 2001 From: lazedo Date: Mon, 4 Mar 2019 08:31:12 +0000 Subject: [PATCH] remove watchers on registration expiration --- kamailio/presence-notify.cfg | 16 +++++++++++++++- kamailio/registrar-role.cfg | 4 ++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/kamailio/presence-notify.cfg b/kamailio/presence-notify.cfg index bd99b01..7c263e6 100644 --- a/kamailio/presence-notify.cfg +++ b/kamailio/presence-notify.cfg @@ -1,3 +1,5 @@ +#!trydef KZ_PRESENCE_REMOVE_WATCHER_ON_EXPIRED_REGISTRATION 1 + kazoo.presence_notify = 1 descr "enable/disable sending notify callback to omnipresence" kazoo.presence_notify_timeout = 3500 descr "timeout in ms waiting for notify reply" kazoo.presence_notify_log_body = 0 descr "logs the body sent in the notification" @@ -7,6 +9,7 @@ kazoo.presence_notify_log_to_amqp = 0 descr "logs notify/reply to amqp" kazoo.presence_notify_record_route = 1 descr "add record route header to notify msg sent" kazoo.presence_notify_log_init_body = 0 descr "logs the body before its sent" kazoo.presence_notify_force_send_socket = 1 descr "forces the send socket to the contact" +kazoo.presence_remove_watcher_on_expired_registration = KZ_PRESENCE_REMOVE_WATCHER_ON_EXPIRED_REGISTRATION descr "removes watcher on expired registration" ######## Generic Hash Table container in shared memory ######## modparam("htable", "htable", "notify=>size=16;autoexpire=3600;updateexpire=1;initval=0") @@ -191,4 +194,15 @@ route[PRESENCE_DEFERRED_INIT] xlog("L_NOTICE", "scheduled update for $var(nrows) watched presentities/event\n"); } } -} \ No newline at end of file +} + +route[PRESENCE_EXPIRED_REGISTRATION] +{ + if($sel(cfg_get.kazoo.presence_remove_watcher_on_expired_registration) == 1) { + $var(watcher) = $_s(sip:$ulc(exp=>aor)); + $var(watcher_username) = $(var(watcher){uri.user}); + $var(watcher_domain) = $(var(watcher){uri.host}); + $var(Query) = $_s(DELETE FROM active_watchers WHERE watcher_username = "$var(watcher_username)" and watcher_domain = "$var(watcher_domain)";); + mq_add("presence_last_notity", "$uuid(g)", "$var(Query)"); + } +} diff --git a/kamailio/registrar-role.cfg b/kamailio/registrar-role.cfg index d8b4f2b..e281ad4 100644 --- a/kamailio/registrar-role.cfg +++ b/kamailio/registrar-role.cfg @@ -444,6 +444,10 @@ route[REGISTRAR_BOUNDS] ## event_route[usrloc:contact-expired] { + #!ifdef PRESENCE_ROLE + route(PRESENCE_EXPIRED_REGISTRATION); + #!endif + ## return until we handle this in ecallmr xlog("L_INFO", "$ulc(exp=>callid)|expired|removed registration for $ulc(exp=>aor) with contact : $ulc(exp=>addr)\n"); return;