Browse Source

update message role

update-rsyslog-config
lazedo 7 years ago
parent
commit
01cd1b7a2b
1 changed files with 48 additions and 1 deletions
  1. +48
    -1
      kamailio/message-role.cfg

+ 48
- 1
kamailio/message-role.cfg View File

@ -1,5 +1,52 @@
modparam("htable", "htable", "msg=>size=32;autoexpire=60;") modparam("htable", "htable", "msg=>size=32;autoexpire=60;")
route[HANDLE_MESSAGE]
{
if (!is_method("MESSAGE")) return;
xlog("L_INFO", "$ci|log|MESSAGE from $fu to $tu\n");
if (isflagset(FLAG_INTERNALLY_SOURCED) || src_ip == myself) {
xlog("L_INFO", "$ci| routing MESSAGE to external from $fu to $tu\n");
if (registered("location")) {
lookup("location");
xlog("L_INFO", "$ci|log|routing to $ruid\n");
} else {
xlog("L_INFO", "$ci|end|user is not registered\n");
append_to_reply("$def(AOR_NOT_SUBSCRIBED_REASON)\r\n");
sl_send_reply("410", "Not registered");
exit;
}
} else {
route(AUTH);
$xavp(regcfg=>match_received) = $su;
if($avp(is_registred) != "true") {
sl_send_reply("403", "Forbidden");
exit;
} else {
if($hdr(Content-Type) == "text/plain") {
route(MESSAGE_INBOUND);
} else {
xlog("L_WARN", "$ci|end|dropping MESSAGE $hdr(Content-Type)\n");
sl_send_reply("200", "OK");
exit;
}
}
}
}
route[MESSAGE_INBOUND]
{
route(AUTH_HEADERS_JSON);
$var(Payload) = $_s({"Event-Category" : "message", "Event-Name" : "inbound", "Call-ID" : "$ci", "Message-ID" : "$ci", "Route-Type" : "on-net", "Route-ID" : "sip", "From" : "$fU@$fd", "To" : "$tU@$td", "Request" : "$rU@$rd", "Caller-ID-Number" : "$fU", "Callee-ID-Number" : "$tU", "Body" : "$rb", "Custom-SIP-Headers" : $var(headers_json), "Msg-ID" : "$uuid(g)"});
$var(exchange) = "sms";
$var(RoutingKey) = $_s(message.inbound.sip.$(ci{kz.encode}));
xlog("L_INFO", "$ci|msg|sending inbound message $var(RoutingKey) => $var(Payload)\n");
kazoo_publish($var(exchange), $var(RoutingKey), $var(Payload));
sl_send_reply("200", "OK");
exit;
}
event_route[kazoo:consumer-event-message-route] event_route[kazoo:consumer-event-message-route]
{ {
@ -39,7 +86,7 @@ route[MESSAGE_REPLY]
$var(Result) = "Success"; $var(Result) = "Success";
} }
$var(Payload) = '{ "Event-Category" : "message", "Event-Name" : "delivery", "Call-ID" : "$(sht(msg=>$ci){kz.json,Call-ID})", "Message-ID" : "$(sht(msg=>$ci){kz.json,Message-ID})" , "Delivery-Result-Code" : "sip:$T_reply_code", "Msg-ID" : "$(sht(msg=>$ci){kz.json,Msg-ID})" , "Status" : "$var(Result)"}';
$var(Payload) = $_s({ "Event-Category" : "message", "Event-Name" : "delivery", "Call-ID" : "$(sht(msg=>$ci){kz.json,Call-ID})", "Message-ID" : "$(sht(msg=>$ci){kz.json,Message-ID})" , "Delivery-Result-Code" : "sip:$T_reply_code", "Msg-ID" : "$(sht(msg=>$ci){kz.json,Msg-ID})" , "Status" : "$var(Result)"});
$var(RoutingKey) = $(sht(msg=>$ci){kz.json,Server-ID}); $var(RoutingKey) = $(sht(msg=>$ci){kz.json,Server-ID});
$var(exchange) = "targeted"; $var(exchange) = "targeted";


Loading…
Cancel
Save