From 39a239cefced02a077630e97adffdfb554dd0014 Mon Sep 17 00:00:00 2001 From: ionutboangiu Date: Thu, 14 Oct 2021 18:20:39 +0300 Subject: [PATCH] Update GetOpts functions to consider the values of opts with no tenant specified --- engine/libfilters.go | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/engine/libfilters.go b/engine/libfilters.go index 7662b152e..6e16926bb 100644 --- a/engine/libfilters.go +++ b/engine/libfilters.go @@ -37,7 +37,7 @@ func GetFloat64Opts(ctx *context.Context, tnt string, ev *utils.CGREvent, fS *Fi } evDP := ev.AsDataProvider() for _, opt := range dynOpts { // iterate through the options - if opt.Tenant != utils.MetaAny && opt.Tenant != tnt { + if !utils.IsSliceMember([]string{utils.EmptyString, utils.MetaAny, tnt}, opt.Tenant) { continue } if pass, err := fS.Pass(ctx, tnt, opt.FilterIDs, evDP); err != nil { // check if the filter is passing for the DataProvider and return the option if it does @@ -60,7 +60,7 @@ func GetDurationOpts(ctx *context.Context, tnt string, ev *utils.CGREvent, fS *F } evDP := ev.AsDataProvider() for _, opt := range dynOpts { // iterate through the options - if opt.Tenant != utils.MetaAny && opt.Tenant != tnt { + if !utils.IsSliceMember([]string{utils.EmptyString, utils.MetaAny, tnt}, opt.Tenant) { continue } if pass, err := fS.Pass(ctx, tnt, opt.FilterIDs, evDP); err != nil { // check if the filter is passing for the DataProvider and return the option if it does @@ -83,7 +83,7 @@ func GetStringOpts(ctx *context.Context, tnt string, ev *utils.CGREvent, fS *Fil } evDP := ev.AsDataProvider() for _, opt := range dynOpts { // iterate through the options - if opt.Tenant != utils.MetaAny && opt.Tenant != tnt { + if !utils.IsSliceMember([]string{utils.EmptyString, utils.MetaAny, tnt}, opt.Tenant) { continue } if pass, err := fS.Pass(ctx, tnt, opt.FilterIDs, evDP); err != nil { // check if the filter is passing for the DataProvider and return the option if it does @@ -106,7 +106,7 @@ func GetTimeOpts(ctx *context.Context, tnt string, ev *utils.CGREvent, fS *Filte } evDP := ev.AsDataProvider() for _, opt := range dynOpts { // iterate through the options - if opt.Tenant != utils.MetaAny && opt.Tenant != tnt { + if !utils.IsSliceMember([]string{utils.EmptyString, utils.MetaAny, tnt}, opt.Tenant) { continue } var pass bool @@ -130,7 +130,7 @@ func GetStringSliceOpts(ctx *context.Context, tnt string, ev *utils.CGREvent, fS } evDP := ev.AsDataProvider() for _, opt := range dynOpts { // iterate through the options - if opt.Tenant != utils.MetaAny && opt.Tenant != tnt { + if !utils.IsSliceMember([]string{utils.EmptyString, utils.MetaAny, tnt}, opt.Tenant) { continue } if pass, err := fS.Pass(ctx, tnt, opt.FilterIDs, evDP); err != nil { // check if the filter is passing for the DataProvider and return the option if it does @@ -157,7 +157,7 @@ func GetIntOpts(ctx *context.Context, tnt string, ev *utils.CGREvent, fS *Filter } evDP := ev.AsDataProvider() for _, opt := range dynOpts { // iterate through the options - if opt.Tenant != utils.MetaAny && opt.Tenant != tnt { + if !utils.IsSliceMember([]string{utils.EmptyString, utils.MetaAny, tnt}, opt.Tenant) { continue } if pass, err := fS.Pass(ctx, tnt, opt.FilterIDs, evDP); err != nil { // check if the filter is passing for the DataProvider and return the option if it does @@ -180,7 +180,7 @@ func GetBoolOpts(ctx *context.Context, tnt string, ev *utils.CGREvent, fS *Filte } evDP := ev.AsDataProvider() for _, opt := range dynOpts { // iterate through the options - if opt.Tenant != utils.MetaAny && opt.Tenant != tnt { + if !utils.IsSliceMember([]string{utils.EmptyString, utils.MetaAny, tnt}, opt.Tenant) { continue } if pass, err := fS.Pass(ctx, tnt, opt.FilterIDs, evDP); err != nil { // check if the filter is passing for the DataProvider and return the option if it does @@ -203,7 +203,7 @@ func GetDecimalBigOpts(ctx *context.Context, tnt string, ev *utils.CGREvent, fS } evDP := ev.AsDataProvider() for _, opt := range dynOpts { // iterate through the options - if opt.Tenant != utils.MetaAny && opt.Tenant != tnt { + if !utils.IsSliceMember([]string{utils.EmptyString, utils.MetaAny, tnt}, opt.Tenant) { continue } if pass, err := fS.Pass(ctx, tnt, opt.FilterIDs, evDP); err != nil { // check if the filter is passing for the DataProvider and return the option if it does @@ -226,7 +226,7 @@ func GetInterfaceOpts(ctx *context.Context, tnt string, ev *utils.CGREvent, fS * } evDP := ev.AsDataProvider() for _, opt := range dynOpts { // iterate through the options - if opt.Tenant != utils.MetaAny && opt.Tenant != tnt { + if !utils.IsSliceMember([]string{utils.EmptyString, utils.MetaAny, tnt}, opt.Tenant) { continue } if pass, err := fS.Pass(ctx, tnt, opt.FilterIDs, evDP); err != nil { // check if the filter is passing for the DataProvider and return the option if it does @@ -253,7 +253,7 @@ func GetIntPointerOpts(ctx *context.Context, tnt string, ev *utils.CGREvent, fS } evDP := ev.AsDataProvider() for _, opt := range dynOpts { // iterate through the options - if opt.Tenant != utils.MetaAny && opt.Tenant != tnt { + if !utils.IsSliceMember([]string{utils.EmptyString, utils.MetaAny, tnt}, opt.Tenant) { continue } if pass, err := fS.Pass(ctx, tnt, opt.FilterIDs, evDP); err != nil { // check if the filter is passing for the DataProvider and return the option if it does