Skip to content

Commit

Permalink
kamtrunks: match against dlg_var(ddiId) instead of against DDIE164
Browse files Browse the repository at this point in the history
  • Loading branch information
cruzccl committed Dec 19, 2024
1 parent ae28c60 commit 6c8ba34
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions kamailio/trunks/config/kamailio.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -578,7 +578,7 @@ route[CHECK_BOUNCE] {
#!endif

$xavp(ra) = $null;
sql_xquery("cb", "SELECT type FROM DDIs WHERE DDIE164='$rU'", "ra");
sql_xquery("cb", "SELECT type FROM DDIs WHERE id='$dlg_var(ddiId)'", "ra");
if ($xavp(ra=>type) != $null) {
if ($xavp(ra=>type) == 'out') {
xnotice("[$dlg_var(cidhash)] CHECK-BOUNCE: Call is to one of my outbound DDIs, do not bounce\n");
Expand Down Expand Up @@ -1476,7 +1476,7 @@ route[APPLY_TRANSFORMATION] {
route[GET_INFO_FROM_MATCHED_DDI] {
if ($dlg_var(type) == 'unassigned') return;

sql_xquery("cb", "SELECT c.companyMediaRelaySetId, c.maxCalls AS maxCallsCompany, b.maxCalls AS maxCallsBrand, d.recordCalls, c.distributeMethod, c.applicationServerSetId, d.routeType, d.residentialDeviceId, d.retailAccountId, d.faxId FROM DDIs d JOIN Companies c ON d.companyId=c.id JOIN Brands b ON c.brandId=b.id WHERE d.DDIE164='$rU'", "ra");
sql_xquery("cb", "SELECT c.companyMediaRelaySetId, c.maxCalls AS maxCallsCompany, b.maxCalls AS maxCallsBrand, d.recordCalls, c.distributeMethod, c.applicationServerSetId, d.routeType, d.residentialDeviceId, d.retailAccountId, d.faxId FROM DDIs d JOIN Companies c ON d.companyId=c.id JOIN Brands b ON c.brandId=b.id WHERE d.id='$dlg_var(ddiId)'", "ra");

# Matched DDI
$dlg_var(maxCallsCompany) = $xavp(ra=>maxCallsCompany);
Expand Down Expand Up @@ -1635,7 +1635,7 @@ route[SETUP_KAMUSERS_CALL] {

# Check DDI is routed to a retail account
$xavp(ra) = $null;
sql_xquery("cb", "SELECT RA.name AS username, DS.domain AS domain FROM DDIs D INNER JOIN RetailAccounts RA ON D.retailAccountId=RA.id INNER JOIN Domains DS ON RA.domainId=DS.id WHERE DDIE164='$rU'", "ra");
sql_xquery("cb", "SELECT RA.name AS username, DS.domain AS domain FROM DDIs D INNER JOIN RetailAccounts RA ON D.retailAccountId=RA.id INNER JOIN Domains DS ON RA.domainId=DS.id WHERE D.id='$dlg_var(ddiId)'", "ra");
if ($xavp(ra) == $null) {
xwarn("[$dlg_var(cidhash)] SETUP-KAMUSERS-CALL: $rU retail DDI not assigned to any retail account, reject\n");
send_reply("404", "No destination [SKC]");
Expand Down Expand Up @@ -1744,7 +1744,7 @@ route[CLASSIFY] {
set_dlg_profile("outboundCallsCompany", "$dlg_var(companyId)");
set_dlg_profile("outboundCallsBrand", "$dlg_var(brandId)");
} else {
sql_xquery("cb", "SELECT B.id AS brandId, C.id AS companyId, C.type FROM DDIs D JOIN Brands B ON B.id=D.brandId LEFT JOIN Companies C ON D.companyId=C.id WHERE DDIE164='$rU'", "rp");
sql_xquery("cb", "SELECT B.id AS brandId, C.id AS companyId, C.type FROM DDIs D JOIN Brands B ON B.id=D.brandId LEFT JOIN Companies C ON D.companyId=C.id WHERE D.id='$dlg_var(ddiId)'", "rp");
$dlg_var(brandId) = $xavp(rp=>brandId);
$dlg_var(companyId) = $xavp(rp=>companyId);

Expand Down

0 comments on commit 6c8ba34

Please sign in to comment.