mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 18:16:24 +05:00
fallback subject list with |
This commit is contained in:
@@ -40,8 +40,8 @@ const (
|
||||
CSTMID = "cgr_cstmid"
|
||||
CALL_DEST_NR = "dialed_extension"
|
||||
PARK_TIME = "start_epoch"
|
||||
ANSWER_TIME = "answer_epoch"
|
||||
HANGUP_TIME = "end_epoch"
|
||||
ANSWER_TIME = "answer_epoch"
|
||||
HANGUP_TIME = "end_epoch"
|
||||
DURATION = "billsec"
|
||||
USERNAME = "user_name"
|
||||
FS_IP = "sip_local_network_addr"
|
||||
@@ -107,7 +107,7 @@ func (fsCdr FSCdr) GetReqType() string {
|
||||
func (fsCdr FSCdr) GetExtraFields() map[string]string {
|
||||
extraFields := make(map[string]string, len(cfg.CDRSExtraFields))
|
||||
for _, field := range cfg.CDRSExtraFields {
|
||||
extraFields[field] := fsCdr[field]
|
||||
extraFields[field] = fsCdr[field]
|
||||
}
|
||||
return extraFields
|
||||
}
|
||||
|
||||
@@ -85,6 +85,14 @@ func TestFallbackDirect(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestFallbackMultiple(t *testing.T) {
|
||||
cd := &CallDescriptor{TOR: "0", Direction: "OUT", Tenant: "vdf", Subject: "fall", Destination: "0723045"}
|
||||
cd.LoadActivationPeriods()
|
||||
if len(cd.ActivationPeriods) != 1 {
|
||||
t.Error("Error restoring activation periods: ", len(cd.ActivationPeriods))
|
||||
}
|
||||
}
|
||||
|
||||
func TestFallbackWithBackTrace(t *testing.T) {
|
||||
cd := &CallDescriptor{TOR: "0", Direction: "OUT", Tenant: "CUSTOMER_2", Subject: "danb:87.139.12.167", Destination: "4123"}
|
||||
cd.LoadActivationPeriods()
|
||||
@@ -94,7 +102,7 @@ func TestFallbackWithBackTrace(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestFallbackDefault(t *testing.T) {
|
||||
cd := &CallDescriptor{TOR: "0", Direction: "OUT", Tenant: "CUSTOMER_2", Subject: "danb:87.139.12.167", Destination: "4123"}
|
||||
cd := &CallDescriptor{TOR: "0", Direction: "OUT", Tenant: "vdf", Subject: "one", Destination: "0723"}
|
||||
cd.LoadActivationPeriods()
|
||||
if len(cd.ActivationPeriods) != 1 {
|
||||
t.Error("Error restoring activation periods: ", len(cd.ActivationPeriods))
|
||||
@@ -102,7 +110,15 @@ func TestFallbackDefault(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestFallbackNoInfiniteLoop(t *testing.T) {
|
||||
cd := &CallDescriptor{Tenant: "vdf", Subject: "rif", Destination: "0721"}
|
||||
cd := &CallDescriptor{TOR: "0", Direction: "OUT", Tenant: "vdf", Subject: "rif", Destination: "0721"}
|
||||
cd.LoadActivationPeriods()
|
||||
if len(cd.ActivationPeriods) != 0 {
|
||||
t.Error("Error restoring activation periods: ", len(cd.ActivationPeriods))
|
||||
}
|
||||
}
|
||||
|
||||
func TestFallbackNoInfiniteLoopSelf(t *testing.T) {
|
||||
cd := &CallDescriptor{TOR: "0", Direction: "OUT", Tenant: "vdf", Subject: "inf", Destination: "0721"}
|
||||
cd.LoadActivationPeriods()
|
||||
if len(cd.ActivationPeriods) != 0 {
|
||||
t.Error("Error restoring activation periods: ", len(cd.ActivationPeriods))
|
||||
|
||||
@@ -25,6 +25,7 @@ import (
|
||||
"github.com/cgrates/cgrates/utils"
|
||||
"log/syslog"
|
||||
"math"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
@@ -38,7 +39,7 @@ func init() {
|
||||
}
|
||||
|
||||
const (
|
||||
RECURSION_MAX_DEPTH = 4
|
||||
RECURSION_MAX_DEPTH = 10
|
||||
FALLBACK_SUBJECT = "*all"
|
||||
VERSION = "0.9.1rc2"
|
||||
)
|
||||
@@ -169,7 +170,11 @@ func (cd *CallDescriptor) getActivationPeriodsForPrefix(key string, recursionDep
|
||||
if err != nil {
|
||||
if rp.FallbackKey != "" {
|
||||
recursionDepth++
|
||||
return cd.getActivationPeriodsForPrefix(rp.FallbackKey, recursionDepth)
|
||||
for _, fbk := range strings.Split(rp.FallbackKey, "|") {
|
||||
if destPrefix, values, err := cd.getActivationPeriodsForPrefix(fbk, recursionDepth); err == nil {
|
||||
return destPrefix, values, err
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -72,6 +72,9 @@ vdf,0,OUT,rif,,EVENING,2012-01-01T00:00:00Z
|
||||
vdf,0,OUT,rif,,EVENING,2012-02-28T00:00:00Z
|
||||
vdf,0,OUT,minu,,EVENING,2012-01-01T00:00:00Z
|
||||
vdf,0,OUT,*all,,EVENING,2012-02-28T00:00:00Z
|
||||
vdf,0,OUT,one,,STANDARD,2012-02-28T00:00:00Z
|
||||
vdf,0,OUT,inf,inf,STANDARD,2012-02-28T00:00:00Z
|
||||
vdf,0,OUT,fall,one|rif,PREMIUM,2012-02-28T00:00:00Z
|
||||
`
|
||||
actions = `
|
||||
MINI,TOPUP,MINUTES,OUT,100,NAT,ABSOLUTE,0,10,10
|
||||
@@ -129,7 +132,7 @@ func TestLoadRateTimings(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestLoadRatingProfiles(t *testing.T) {
|
||||
if len(csvr.ratingProfiles) != 6 {
|
||||
if len(csvr.ratingProfiles) != 9 {
|
||||
t.Error("Failed to load rating profiles: ", len(csvr.ratingProfiles), csvr.ratingProfiles)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user