Browse Source

Merge pull request #41 from 2600hz/presence-tweaks

presence tweaks
4.2 4.2.4
bitbashing 8 years ago
committed by GitHub
parent
commit
a78db831c7
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 25 additions and 11 deletions
  1. +7
    -0
      kamailio/default.cfg
  2. +15
    -9
      kamailio/presence-role.cfg
  3. +2
    -1
      kamailio/presence_notify_sync-role.cfg
  4. +1
    -1
      kamailio/presence_query-role.cfg

+ 7
- 0
kamailio/default.cfg View File

@ -411,6 +411,9 @@ route[HANDLE_OPTIONS]
route[HANDLE_NOTIFY] route[HANDLE_NOTIFY]
{ {
if (has_totag())
return;
if (is_method("NOTIFY")) { if (is_method("NOTIFY")) {
if (isflagset(FLAG_INTERNALLY_SOURCED)) { if (isflagset(FLAG_INTERNALLY_SOURCED)) {
if (loose_route()) { if (loose_route()) {
@ -527,6 +530,10 @@ route[HANDLE_IN_DIALOG_REQUESTS]
if (is_method("INVITE") && !isflagset(FLAG_INTERNALLY_SOURCED) && is_audio_on_hold()) { if (is_method("INVITE") && !isflagset(FLAG_INTERNALLY_SOURCED) && is_audio_on_hold()) {
setflag(FLAG_ASSOCIATE_USER); setflag(FLAG_ASSOCIATE_USER);
} }
if ( is_method("NOTIFY") ) {
# Add Record-Route for in-dialog NOTIFY as per RFC 6665.
record_route();
}
route(RELAY); route(RELAY);
} else if (isflagset(FLAG_INTERNALLY_SOURCED)) { } else if (isflagset(FLAG_INTERNALLY_SOURCED)) {
xlog("L_INFO", "$ci|log|relay internally sourced in-dialog message without loose_route\n"); xlog("L_INFO", "$ci|log|relay internally sourced in-dialog message without loose_route\n");


+ 15
- 9
kamailio/presence-role.cfg View File

@ -4,7 +4,7 @@
#!trydef PRESENCE_MAX_EXPIRES 3600 #!trydef PRESENCE_MAX_EXPIRES 3600
modparam("htable", "htable", "p=>size=32;autoexpire=3600;") modparam("htable", "htable", "p=>size=32;autoexpire=3600;")
modparam("htable", "htable", "first=>size=32;autoexpire=3600;initval =0;updateexpire=1")
modparam("htable", "htable", "first=>size=32;autoexpire=3600;initval =0;updateexpire=1;")
loadmodule "presence.so" loadmodule "presence.so"
loadmodule "presence_dialoginfo.so" loadmodule "presence_dialoginfo.so"
@ -53,6 +53,7 @@ modparam("nat_traversal", "keepalive_state_file", "KAZOO_DATA_DIR/keep_alive_sta
modparam("nat_traversal", "keepalive_interval", 45) modparam("nat_traversal", "keepalive_interval", 45)
#!endif #!endif
kazoo.presence_sync_amqp = 0 descr "sync subscriptions to amqp"
#!ifdef FAST_PICKUP_ROLE #!ifdef FAST_PICKUP_ROLE
#!include_file "fast-pickup-role.cfg" #!include_file "fast-pickup-role.cfg"
@ -88,11 +89,17 @@ route[HANDLE_SUBSCRIBE]
route(PRESENCE_NAT); route(PRESENCE_NAT);
#!endif #!endif
if(has_totag()) {
loose_route();
}
record_route();
if (!t_newtran()) { if (!t_newtran()) {
sl_reply_error(); sl_reply_error();
exit; exit;
} }
if(has_totag()) { if(has_totag()) {
route(HANDLE_RESUBSCRIBE); route(HANDLE_RESUBSCRIBE);
} else { } else {
@ -106,8 +113,7 @@ route[HANDLE_SUBSCRIBE]
route[HANDLE_RESUBSCRIBE] route[HANDLE_RESUBSCRIBE]
{ {
loose_route();
if(handle_subscribe()) { if(handle_subscribe()) {
if($subs(remote_cseq) < 5) { if($subs(remote_cseq) < 5) {
$sht(first=>$subs(callid)) = $null; $sht(first=>$subs(callid)) = $null;
@ -151,8 +157,6 @@ route[HANDLE_NEW_SUBSCRIBE]
} }
} }
record_route();
if (handle_subscribe()) { if (handle_subscribe()) {
route(SUBSCRIBE_AMQP); route(SUBSCRIBE_AMQP);
xlog("L_INFO","$ci|end|new $hdr(Event) subscription from $fU to $tU in realm $fd : $sht(first=>$ci) : $sht(first=>$fU::$tU::$fd::$hdr(Event))\n"); xlog("L_INFO","$ci|end|new $hdr(Event) subscription from $fU to $tU in realm $fd : $sht(first=>$ci) : $sht(first=>$fU::$tU::$fd::$hdr(Event))\n");
@ -167,9 +171,11 @@ route[HANDLE_NEW_SUBSCRIBE]
route[SUBSCRIBE_AMQP] route[SUBSCRIBE_AMQP]
{ {
$var(rk) = "subscribe." + $(subs(to_domain){kz.encode}) + "." + $(subs(to_user){kz.encode});
$var(amqp_payload_request) = $_s({"Event-Category" : "presence", "Event-Name" : "subscription", "Event-Package" : "$hdr(event)", "Expires" : $subs(expires), "Queue" : "BLF-MY_HOSTNAME", "Server-ID" : "BLF-MY_HOSTNAME" , "Contact" : "$(ct{s.escape.common}{s.replace,\','}{s.replace,$$,})", "Call-ID" : "$ci", "From" : "$fu", "User" : "$subs(uri)", "User-Agent" : "$(ua{s.escape.common}{s.replace,\','}{s.replace,$$,})" });
kazoo_publish("omnipresence", "$var(rk)", $var(amqp_payload_request));
if(@cfg_get.kazoo.presence_sync_amqp == 1) {
$var(rk) = "subscribe." + $(subs(to_domain){kz.encode}) + "." + $(subs(to_user){kz.encode});
$var(amqp_payload_request) = $_s({"Event-Category" : "presence", "Event-Name" : "subscription", "Event-Package" : "$hdr(event)", "Expires" : $subs(expires), "Queue" : "BLF-MY_HOSTNAME", "Server-ID" : "BLF-MY_HOSTNAME" , "Contact" : "$(ct{s.escape.common}{s.replace,\','}{s.replace,$$,})", "Call-ID" : "$ci", "From" : "$fu", "User" : "$subs(uri)", "User-Agent" : "$(ua{s.escape.common}{s.replace,\','}{s.replace,$$,})" });
kazoo_publish("omnipresence", "$var(rk)", $var(amqp_payload_request));
}
} }
route[HANDLE_PUBLISH] route[HANDLE_PUBLISH]


+ 2
- 1
kamailio/presence_notify_sync-role.cfg View File

@ -4,7 +4,7 @@ kazoo.presence_notify_log_body = 0 descr "logs the body sent in the notification
kazoo.presence_notify_log_resp_body = 0 descr "logs the body received from notification" kazoo.presence_notify_log_resp_body = 0 descr "logs the body received from notification"
kazoo.presence_notify_log_to_table = 1 descr "logs notify/reply to active_watchers_log table" kazoo.presence_notify_log_to_table = 1 descr "logs notify/reply to active_watchers_log table"
kazoo.presence_notify_log_to_amqp = 0 descr "logs notify/reply to amqp" kazoo.presence_notify_log_to_amqp = 0 descr "logs notify/reply to amqp"
kazoo.presence_notify_record_route = 0 descr "add record route header to notify msg sent"
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_log_init_body = 0 descr "logs the body before its sent"
kazoo.presence_notify_force_send_socket = 0 descr "forces the send socket to the contact" kazoo.presence_notify_force_send_socket = 0 descr "forces the send socket to the contact"
@ -53,6 +53,7 @@ event_route[presence:notify-reply]
if($notify_reply($rs) == 200) { if($notify_reply($rs) == 200) {
$sht(notify=>$ci) = $null; $sht(notify=>$ci) = $null;
$sht(notify=>$ci::count) = 0;
xlog("L_INFO", "$ci|end|notified $subs(watcher_username)@$subs(watcher_domain) on behalf of $subs(pres_uri)\n"); xlog("L_INFO", "$ci|end|notified $subs(watcher_username)@$subs(watcher_domain) on behalf of $subs(pres_uri)\n");
} else if($notify_reply($rs) == 481 && $subs(reason) == "timeout") { } else if($notify_reply($rs) == 481 && $subs(reason) == "timeout") {
xlog("L_INFO","$ci|end|sent subscription $hdr(Subscription-State)\n"); xlog("L_INFO","$ci|end|sent subscription $hdr(Subscription-State)\n");


+ 1
- 1
kamailio/presence_query-role.cfg View File

@ -47,7 +47,7 @@ route[PRESENCE_SEARCH_SUMMARY]
} }
xlog("L_DEBUG", "$ci| RESULT \"Subscriptions\" : { $var(Subs) }\n"); xlog("L_DEBUG", "$ci| RESULT \"Subscriptions\" : { $var(Subs) }\n");
$var(amqp_payload_request) = '{"Event-Category" : "presence", "Event-Name" : "search_resp", "Msg-ID" : "$(kzE{kz.json,Msg-ID})", "Subscriptions" : { $var(Subs) } }';
$var(amqp_payload_request) = $_s({"Event-Category" : "presence", "Event-Name" : "search_resp", "Msg-ID" : "$(kzE{kz.json,Msg-ID})", "Subscriptions" : { $var(Subs) } });
kazoo_publish("targeted", "$var(Queue)", $var(amqp_payload_request)); kazoo_publish("targeted", "$var(Queue)", $var(amqp_payload_request));
} }


Loading…
Cancel
Save