You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

83 lines
2.6 KiB

######## Presence server module ########
loadmodule "presence.so"
loadmodule "presence_dialoginfo.so"
loadmodule "presence_mwi.so"
loadmodule "presence_xml.so"
modparam("presence", "subs_db_mode", 0)
modparam("presence", "expires_offset", 60)
modparam("presence", "publ_cache", 0)
modparam("presence", "min_expires", 0)
modparam("presence", "max_expires", 3600)
modparam("presence", "db_url", "MY_AMQP_URL/dialoginfo")
modparam("presence", "send_fast_notify", 0)
modparam("presence", "clean_period", 30)
modparam("presence_xml", "force_active", 1)
######## Presence User Agent module ########
#loadmodule "pua.so"
#modparam("pua", "db_mode", 0)
#modparam("pua", "db_url", "text:///etc/kazoo/kamailio/dbtext")
#modparam("pua", "update_period", 6)
#modparam("pua", "min_expires", 300)
#modparam("pua", "outbound_proxy", "sip:MY_IP_ADDRESS")
####### Presence Logic ########
route[HANDLE_SUBSCRIBE]
{
if (is_method("SUBSCRIBE")) {
#!ifdef NAT-TRAVERSAL-ROLE
route(NAT_TEST_AND_CORRECT);
#!endif
if (!t_newtran()) {
sl_reply_error();
exit;
}
handle_subscribe();
##RabbitMQ
$var(fs_path) = "%3C" + $rz + "%3A" + $Ri + "%3A" + $Rp + "%3Btransport=" + $proto + "%3Blr%3Breceived=" + $si+":"+$sp+"%3E";
$var(fs_contact) = "<" + $(ct{tobody.uri}) + ";fs_path=" + $var(fs_path) + ">";
if($(ct{tobody.params}) != $null) {
$var(fs_contact) = $var(fs_contact) + ";" + $(ct{tobody.params});
}
$var(amqp_payload_request) = "{'Event-Category' : 'presence', 'Event-Name' : 'subscription', 'Event-Package' : '" + $hdr(event) + "', 'Expires' : " + $hdr(Expires) + ", 'Queue' : 'BLF-MY_HOSTNAME', 'Server-ID' : 'BLF-MY_HOSTNAME' ,'Contact' : '" + $var(fs_contact) + "', 'Call-ID' : '" + $ci + "', 'From' : '" + $fu +"', 'User' : '" + $tu + "', 'User-Agent' : '" + $ua + "' }";
kazoo_publish("dialoginfo_subs", "dialoginfo_subs", $var(amqp_payload_request));
t_release();
exit;
}
}
route[HANDLE_PUBLISH]
{
if (is_method("PUBLISH")) {
if (!t_newtran()) {
sl_reply_error();
exit;
}
if($hdr(Sender)!= $null)
handle_publish("$hdr(Sender)");
else
handle_publish();
t_release();
exit;
}
}
event_route[kazoo:consumer-event-presence-update]
{
xlog("L_INFO", "received $(kzE{kz.json,Event-Package}) update for $(kzE{kz.json,From})");
kazoo_pua_publish($kzE);
pres_refresh_watchers("$(kzE{kz.json,From})", "$(kzE{kz.json,Event-Package})", 1);
}
# vim: tabstop=4 softtabstop=4 shiftwidth=4 expandtab