Skip to content

Commit

Permalink
Merge pull request #2618 from irontec/PROVIDER-1606-kamtrunks-unassig…
Browse files Browse the repository at this point in the history
…ned-ddis-handling

kamtrunks: unassigned DDIs handling
  • Loading branch information
cruzccl authored Apr 11, 2024
2 parents fd171cc + 59b04d7 commit ef1044f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 2 additions & 0 deletions asterisk/config/dialplan/default.conf
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
[trunks]
exten => _[+*0-9]!,1,NoOp(Incoming external call from ${CALLERID(all)} to ${EXTEN})
same => n,AGI(agi://${FASTAGI_SERVER}/fastagi-runner.php?command=Dialplan/Trunks)
; Playback specific sounds and leave
include => sounds

;; Context for user calls (from proxyUsers)
;; ${EXTEN} may match a Company Extension, Company Service or External number
Expand Down
15 changes: 14 additions & 1 deletion kamailio/trunks/config/kamailio.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -1476,6 +1476,8 @@ route[APPLY_TRANSFORMATION] {
}

route[GET_INFO_FROM_MATCHED_DDI] {
if ($dlg_var(type) == 'unassigned') return;

sql_xquery("cb", "SELECT c.mediaRelaySetsId, c.maxCalls AS maxCallsCompany, b.maxCalls AS maxCallsBrand, d.recordCalls, c.distributeMethod, AppS.ip AS asAddress, d.routeType, d.residentialDeviceId, d.retailAccountId, d.faxId FROM DDIs d JOIN Companies c ON d.companyId=c.id LEFT JOIN ApplicationServers AppS ON AppS.id=c.applicationServerId JOIN Brands b ON c.brandId=b.id WHERE d.DDIE164='$rU'", "ra");

# Matched DDI
Expand Down Expand Up @@ -1741,9 +1743,18 @@ route[CLASSIFY] {
set_dlg_profile("outboundCallsCompany", "$dlg_var(companyId)");
set_dlg_profile("outboundCallsBrand", "$dlg_var(brandId)");
} else {
sql_xquery("cb", "SELECT C.brandId, C.id AS companyId, C.type FROM DDIs D 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 DDIE164='$rU'", "rp");
$dlg_var(brandId) = $xavp(rp=>brandId);
$dlg_var(companyId) = $xavp(rp=>companyId);

if ($dlg_var(brandId) != $null && $dlg_var(companyId) == $null) {
xnotice("[$dlg_var(cidhash)] CLASSIFY: inbound call to unassigned DDI $rU (b$dlg_var(brandId))");
$dlg_var(skipRealtime) = 'yes'; # Skip this call in realtime
$dlg_var(type) = 'unassigned';
$rU = 'noclient';
return;
}

$dlg_var(type) = $xavp(rp=>type);

if ($dlg_var(type) == 'wholesale') {
Expand Down Expand Up @@ -2340,6 +2351,8 @@ route[RECORD] {
}

route[CONTROL_MAXCALLS] {
if ($dlg_var(type) == 'unassigned') return;

if (!get_profile_size("activeCallsCompany", "$dlg_var(companyId)", "$avp(activeCallsCompany)")) {
xerr("[$dlg_var(cidhash)] CONTROL-MAXCALLS: company$dlg_var(companyId) $avp(activeCallsCompany)/$dlg_var(maxCallsCompany) calls (error obtaining value)\n");
if ($dlg_var(maxCallsCompany) > 0) {
Expand Down

0 comments on commit ef1044f

Please sign in to comment.