mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-24 08:38:45 +05:00
Diameter CCA field templates matching also in answer - fixes #348; field filters not anymore passing if the field id not found in message
This commit is contained in:
@@ -235,9 +235,9 @@ func passesFieldFilter(m *diam.Message, fieldFilter *utils.RSRField) (bool, int)
|
||||
if err != nil {
|
||||
return false, 0
|
||||
} else if len(avps) == 0 {
|
||||
return true, 0
|
||||
return false, 0 // No AVPs with field filter ID
|
||||
}
|
||||
for avpIdx, avpVal := range avps {
|
||||
for avpIdx, avpVal := range avps { // First match wins due to index
|
||||
if fieldFilter.FilterPasses(avpValAsString(avpVal)) {
|
||||
return true, avpIdx
|
||||
}
|
||||
@@ -620,6 +620,9 @@ func (self *CCA) AsDiameterMessage() *diam.Message {
|
||||
func (self *CCA) SetProcessorAVPs(reqProcessor *config.DARequestProcessor, maxUsage float64) error {
|
||||
for _, cfgFld := range reqProcessor.CCAFields {
|
||||
fmtOut, err := fieldOutVal(self.ccrMessage, cfgFld, maxUsage)
|
||||
if err == ErrFilterNotPassing { // Field not in or filter not passing, try match in answer
|
||||
fmtOut, err = fieldOutVal(self.diamMessage, cfgFld, maxUsage)
|
||||
}
|
||||
if err != nil {
|
||||
if err == ErrFilterNotPassing {
|
||||
continue
|
||||
|
||||
@@ -265,6 +265,9 @@ func TestRSRFilterPass(t *testing.T) {
|
||||
if fltr.Pass("full_match1") {
|
||||
t.Error("Passing!")
|
||||
}
|
||||
if fltr.Pass("") {
|
||||
t.Error("Passing!")
|
||||
}
|
||||
fltr, err = NewRSRFilter("^prefixMatch") // Prefix pass
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
|
||||
Reference in New Issue
Block a user