Browse Source

presence reset updates

update-rsyslog-config
lazedo 7 years ago
parent
commit
06fdce2a0a
5 changed files with 28 additions and 12 deletions
  1. +8
    -4
      kamailio/db_queries_kazoo.cfg
  2. +1
    -1
      kamailio/default.cfg
  3. +0
    -2
      kamailio/defs.cfg
  4. +9
    -2
      kamailio/presence-notify.cfg
  5. +10
    -3
      kamailio/presence-reset.cfg

+ 8
- 4
kamailio/db_queries_kazoo.cfg View File

@ -6,11 +6,15 @@
#!substdef "!KZQ_EVENT_PRESENCE_RESET_DELETE!delete from presentity where domain=\"\$(kzE{kz.json,Realm})\" and username = \"\$(kzE{kz.json,Username})\"!g" #!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_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_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_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)\" and callid in(select callid from active_watchers where presentity_uri = \"\$var(presentity_uri)\")!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_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_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"
#!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" #!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"
# # #!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_RESET_PUBLISHER_UPDATE!INSERT INTO tmp_probe select distinct a.event, a.presentity_uri from presentities a inner join active_watchers b on a.presentity_uri = b.presentity_uri and a.event = b.event where sender = \"\$var(MediaUrl)\" and state in('early', 'confirmed', 'onthephone', 'busy')!g"
#!substdef "!KZQ_PRESENCE_RESET!delete from presentity where sender = \"\$var(MediaUrl)\"!g"
# # #!substdef "!KZQ_RESET_ACCOUNT_UPDATE!update active_watchers set expires = \$TS where watcher_domain=\"\$(kzE{kz.json,Realm})\"!g"
#!substdef "!KZQ_RESET_ACCOUNT_UPDATE!INSERT INTO tmp_probe select distinct a.event, a.presentity_uri from presentities a inner join active_watchers b on a.presentity_uri = b.presentity_uri and a.event = b.event where domain=\"\$(kzE{kz.json,Realm})\" and state in('early', 'confirmed', 'onthephone', 'busy')!g"
#!substdef "!KZQ_RESET_ACCOUNT_RESET!delete from presentity where domain=\"\$(kzE{kz.json,Realm})\"!g"

+ 1
- 1
kamailio/default.cfg View File

@ -979,7 +979,7 @@ event_route[evrexec:DEFERRED_INIT]
xlog("L_INFO", "processing deferred init\n"); xlog("L_INFO", "processing deferred init\n");
#!ifdef PRESENCE_ROLE #!ifdef PRESENCE_ROLE
route(PRESENCE_INITIAL_CLEANUP);
route(PRESENCE_PUBLISHER_CLEANUP);
#!endif #!endif
#!import_file "custom-init.cfg" #!import_file "custom-init.cfg"


+ 0
- 2
kamailio/defs.cfg View File

@ -39,8 +39,6 @@
#!substdef "!MY_AMQP_ZONE!local!g" #!substdef "!MY_AMQP_ZONE!local!g"
#!endif #!endif
#!trydef PRESENCE_RESET_BLF_DEFER_UPDATE 0
#!ifdef PRESENCE_ROLE #!ifdef PRESENCE_ROLE
#!trydef MY_AMQP_PUA_MODE 1 #!trydef MY_AMQP_PUA_MODE 1
#!else #!else


+ 9
- 2
kamailio/presence-notify.cfg View File

@ -139,9 +139,9 @@ route[PRESENCE_CLEANUP]
mq_add("presence_last_notity", "$uuid(g)", "$var(Query)"); mq_add("presence_last_notity", "$uuid(g)", "$var(Query)");
} }
route[PRESENCE_INITIAL_CLEANUP]
route[PRESENCE_PUBLISHER_CLEANUP]
{ {
xlog("L_INFO", "processing presence initial cleanup\n");
xlog("L_INFO", "processing presence publisher cleanup\n");
if (sql_xquery("cb", "select * from tmp_probe", "ra") == 1) if (sql_xquery("cb", "select * from tmp_probe", "ra") == 1)
{ {
while($xavp(ra) != $null) { while($xavp(ra) != $null) {
@ -150,4 +150,11 @@ route[PRESENCE_INITIAL_CLEANUP]
pv_unset("$xavp(ra)"); pv_unset("$xavp(ra)");
} }
} }
$var(sqlres) = sql_query("cb", "delete from tmp_probe");
if($var(sqlres) < 0) {
xlog("L_ERROR", "$var(ci)|log|error cleaning tmp_probe\n");
} else {
$var(nrows) = $sqlrows(cb);
xlog("L_INFO", "presence publisher cleanup processed $var(nrows) rows\n");
}
} }

+ 10
- 3
kamailio/presence-reset.cfg View File

@ -1,3 +1,4 @@
#!trydef PRESENCE_RESET_BLF_DEFER_UPDATE 0
kazoo.presence_reset_blf_defer_update = PRESENCE_RESET_BLF_DEFER_UPDATE descr "defers blf reset" kazoo.presence_reset_blf_defer_update = PRESENCE_RESET_BLF_DEFER_UPDATE descr "defers blf reset"
@ -27,7 +28,7 @@ route[PRESENCE_RESET_BINDINGS]
route[RESET_PUBLISHER] route[RESET_PUBLISHER]
{ {
xlog("L_INFO", "$var(Msg-ID)|reset|received presence reset for publisher $var(MediaUrl))\n");
xlog("L_INFO", "$var(Msg-ID)|reset|received presence reset for publisher $var(MediaUrl)\n");
if($sel(cfg_get.kazoo.presence_reset_blf_defer_update) == 0) { if($sel(cfg_get.kazoo.presence_reset_blf_defer_update) == 0) {
$var(Query) = $_s(KZQ_RESET_PUBLISHER_UPDATE); $var(Query) = $_s(KZQ_RESET_PUBLISHER_UPDATE);
sql_query("exec", "$var(Query)"); sql_query("exec", "$var(Query)");
@ -36,6 +37,9 @@ route[RESET_PUBLISHER]
sql_query("exec", "$var(Query)"); sql_query("exec", "$var(Query)");
$var(presentities) = $sqlrows(exec); $var(presentities) = $sqlrows(exec);
xlog("L_INFO", "$var(Msg-ID)|reset|removed $var(presentities) presentities from publisher $var(MediaUrl)\n"); xlog("L_INFO", "$var(Msg-ID)|reset|removed $var(presentities) presentities from publisher $var(MediaUrl)\n");
if($var(presentities) > 0) {
route(PRESENCE_PUBLISHER_CLEANUP);
}
} }
route[RESET_ALL] route[RESET_ALL]
@ -62,11 +66,14 @@ route[RESET_SERVER]
route[RESET_ACCOUNT] route[RESET_ACCOUNT]
{ {
xlog("L_INFO", "$(kzE{kz.json,Msg-ID})|reset|received presence reset for realm $(kzE{kz.json,Realm})\n"); xlog("L_INFO", "$(kzE{kz.json,Msg-ID})|reset|received presence reset for realm $(kzE{kz.json,Realm})\n");
sql_query("exec", 'KZQ_RESET_ACCOUNT_DELETE');
$var(presentities) = $sqlrows(exec);
sql_query("exec", 'KZQ_RESET_ACCOUNT_UPDATE'); sql_query("exec", 'KZQ_RESET_ACCOUNT_UPDATE');
$var(watchers) = $sqlrows(exec); $var(watchers) = $sqlrows(exec);
sql_query("exec", 'KZQ_RESET_ACCOUNT_RESET');
$var(presentities) = $sqlrows(exec);
xlog("L_INFO", "$(kzE{kz.json,Msg-ID})|reset|removed $var(presentities) presentities and expired $var(watchers) subscribers for realm $(kzE{kz.json,Realm})\n"); xlog("L_INFO", "$(kzE{kz.json,Msg-ID})|reset|removed $var(presentities) presentities and expired $var(watchers) subscribers for realm $(kzE{kz.json,Realm})\n");
if($var(watchers) > 0) {
route(PRESENCE_PUBLISHER_CLEANUP);
}
} }
route[RESET_WILDCARD] route[RESET_WILDCARD]


Loading…
Cancel
Save