From 75fc37db2c2018f18f7696e4f84bdbaf4c6ac1e4 Mon Sep 17 00:00:00 2001 From: porosnicuadrian Date: Fri, 25 Feb 2022 10:53:52 +0200 Subject: [PATCH] renamed into Filters + uniqueAlteredFields --- accounts/libaccounts.go | 2 +- agents/astagent.go | 34 ++++++++++--------- agents/diamagent_test.go | 6 ++-- agents/fsagent.go | 34 ++++++++++--------- agents/kamevent_test.go | 4 +-- apis/attributes_it_test.go | 24 ++++++------- apis/attributes_test.go | 2 +- dispatchers/attributes_it_test.go | 8 ++--- ees/ees.go | 2 +- ees/ees_test.go | 2 +- engine/attributes.go | 17 +++++++--- .../attributes_filters_index_it_test.go | 2 +- general_tests/attributes_it_test.go | 28 +++++++-------- sessions/libsessions.go | 10 +++--- sessions/sessions_test.go | 2 +- 15 files changed, 94 insertions(+), 83 deletions(-) diff --git a/accounts/libaccounts.go b/accounts/libaccounts.go index 8b0b92174..913c45d65 100644 --- a/accounts/libaccounts.go +++ b/accounts/libaccounts.go @@ -222,7 +222,7 @@ func maxDebitAbstractsFromConcretes(ctx *context.Context, aUnits *decimal.Big, attributeIDs); err != nil { return } - if len(rplyAttrS.AlteredFields) != 0 { // event was altered + if len(rplyAttrS.Fields) != 0 { // event was altered cgrEv = rplyAttrS.CGREvent } } diff --git a/agents/astagent.go b/agents/astagent.go index 13300be59..8287e17cf 100644 --- a/agents/astagent.go +++ b/agents/astagent.go @@ -182,22 +182,24 @@ func (sma *AsteriskAgent) handleStasisStart(ev *SMAsteriskEvent) { return } if authReply.Attributes != nil { - for _, altered := range authReply.Attributes.AlteredFields { - for _, fldName := range altered.AlteredFields { - fldName = strings.TrimPrefix(fldName, utils.MetaReq+utils.NestingSep) - if _, has := authReply.Attributes.CGREvent.Event[fldName]; !has { - continue //maybe removed - } - fldVal, err := authReply.Attributes.CGREvent.FieldAsString(fldName) - if err != nil { - utils.Logger.Warning( - fmt.Sprintf( - "<%s> error <%s> extracting attribute field: <%s>", - utils.AsteriskAgent, err.Error(), fldName)) - } - if !sma.setChannelVar(ev.ChannelID(), fldName, fldVal) { - return - } + var altrFlds utils.StringSet + for _, altered := range authReply.Attributes.Fields { + altrFlds.AddSlice(altered.AlteredFields) + } + for fldName := range altrFlds { + fldName = strings.TrimPrefix(fldName, utils.MetaReq+utils.NestingSep) + if _, has := authReply.Attributes.CGREvent.Event[fldName]; !has { + continue //maybe removed + } + fldVal, err := authReply.Attributes.CGREvent.FieldAsString(fldName) + if err != nil { + utils.Logger.Warning( + fmt.Sprintf( + "<%s> error <%s> extracting attribute field: <%s>", + utils.AsteriskAgent, err.Error(), fldName)) + } + if !sma.setChannelVar(ev.ChannelID(), fldName, fldVal) { + return } } } diff --git a/agents/diamagent_test.go b/agents/diamagent_test.go index 7be65f6c1..b10f7d38d 100644 --- a/agents/diamagent_test.go +++ b/agents/diamagent_test.go @@ -196,7 +196,7 @@ func TestProcessRequest(t *testing.T) { } *prply = sessions.V1InitSessionReply{ Attributes: &engine.AttrSProcessEventReply{ - AlteredFields: []*engine.FieldsAltered{ + Fields: []*engine.FieldsAltered{ { MatchedProfileID: "ATTR_1001_SESSIONAUTH", AlteredFields: []string{"*req.Password", "*req.PaypalAccount", "*req.RequestType", "*req.LCRProfile"}, @@ -263,7 +263,7 @@ func TestProcessRequest(t *testing.T) { } *prply = sessions.V1UpdateSessionReply{ Attributes: &engine.AttrSProcessEventReply{ - AlteredFields: []*engine.FieldsAltered{ + Fields: []*engine.FieldsAltered{ { MatchedProfileID: "ATTR_1001_SESSIONAUTH", AlteredFields: []string{"*req.Password", "*req.PaypalAccount", "*req.RequestType", "*req.LCRProfile"}, @@ -403,7 +403,7 @@ func TestProcessRequest(t *testing.T) { } *prply = sessions.V1ProcessMessageReply{ Attributes: &engine.AttrSProcessEventReply{ - AlteredFields: []*engine.FieldsAltered{ + Fields: []*engine.FieldsAltered{ { MatchedProfileID: "ATTR_1001_SESSIONAUTH", AlteredFields: []string{"*req.Password", "*req.PaypalAccount", "*req.RequestType", "*req.LCRProfile"}, diff --git a/agents/fsagent.go b/agents/fsagent.go index d864f15db..13ecedc87 100644 --- a/agents/fsagent.go +++ b/agents/fsagent.go @@ -161,22 +161,24 @@ func (fsa *FSsessions) onChannelPark(fsev FSEvent, connIdx int) { return } if authReply.Attributes != nil { - for _, altered := range authReply.Attributes.AlteredFields { - for _, fldName := range altered.AlteredFields { - fldName = strings.TrimPrefix(fldName, utils.MetaReq+utils.NestingSep) - if _, has := authReply.Attributes.CGREvent.Event[fldName]; !has { - continue //maybe removed - } - if _, err := fsa.conns[connIdx].SendApiCmd( - fmt.Sprintf("uuid_setvar %s %s %s\n\n", fsev.GetUUID(), fldName, - authReply.Attributes.CGREvent.Event[fldName])); err != nil { - utils.Logger.Info( - fmt.Sprintf("<%s> error %s setting channel variabile: %s", - utils.FreeSWITCHAgent, err.Error(), fldName)) - fsa.unparkCall(fsev.GetUUID(), connIdx, - fsev.GetCallDestNr(utils.MetaDefault), err.Error()) - return - } + var altrFlds utils.StringSet + for _, altered := range authReply.Attributes.Fields { + altrFlds.AddSlice(altered.AlteredFields) + } + for fldName := range altrFlds { + fldName = strings.TrimPrefix(fldName, utils.MetaReq+utils.NestingSep) + if _, has := authReply.Attributes.CGREvent.Event[fldName]; !has { + continue //maybe removed + } + if _, err := fsa.conns[connIdx].SendApiCmd( + fmt.Sprintf("uuid_setvar %s %s %s\n\n", fsev.GetUUID(), fldName, + authReply.Attributes.CGREvent.Event[fldName])); err != nil { + utils.Logger.Info( + fmt.Sprintf("<%s> error %s setting channel variabile: %s", + utils.FreeSWITCHAgent, err.Error(), fldName)) + fsa.unparkCall(fsev.GetUUID(), connIdx, + fsev.GetCallDestNr(utils.MetaDefault), err.Error()) + return } } } diff --git a/agents/kamevent_test.go b/agents/kamevent_test.go index 9089dbdc4..99908f966 100644 --- a/agents/kamevent_test.go +++ b/agents/kamevent_test.go @@ -175,7 +175,7 @@ func TestKamEvAsKamAuthReply(t *testing.T) { } authRply = &sessions.V1AuthorizeReply{ Attributes: &engine.AttrSProcessEventReply{ - AlteredFields: []*engine.FieldsAltered{ + Fields: []*engine.FieldsAltered{ { MatchedProfileID: "ATTR_1001_ACCOUNT_PROFILE", AlteredFields: []string{"*req.Password", utils.MetaReq + utils.NestingSep + utils.RequestType}, @@ -248,7 +248,7 @@ func TestKamEvAsKamProcessEventReply(t *testing.T) { } procEvhRply = &sessions.V1ProcessMessageReply{ Attributes: &engine.AttrSProcessEventReply{ - AlteredFields: []*engine.FieldsAltered{ + Fields: []*engine.FieldsAltered{ { MatchedProfileID: "ATTR_1001_ACCOUNT_PROFILE", AlteredFields: []string{"*req.Password", utils.MetaReq + utils.NestingSep + utils.RequestType}, diff --git a/apis/attributes_it_test.go b/apis/attributes_it_test.go index a25c80262..0963d0fae 100644 --- a/apis/attributes_it_test.go +++ b/apis/attributes_it_test.go @@ -864,7 +864,7 @@ func testAttributeProcessEvent(t *testing.T) { }, } expEvReply := &engine.AttrSProcessEventReply{ - AlteredFields: []*engine.FieldsAltered{ + Fields: []*engine.FieldsAltered{ { MatchedProfileID: "cgrates.org:TEST_ATTRIBUTES_IT_TEST", AlteredFields: []string{"*tenant", utils.AccountField}, @@ -887,8 +887,8 @@ func testAttributeProcessEvent(t *testing.T) { args, &evRply); err != nil { t.Error(err) } else { - sort.Strings(expEvReply.AlteredFields[0].AlteredFields) - sort.Strings(evRply.AlteredFields[0].AlteredFields) + sort.Strings(expEvReply.Fields[0].AlteredFields) + sort.Strings(evRply.Fields[0].AlteredFields) if !reflect.DeepEqual(evRply, expEvReply) { t.Errorf("Expected %+v, received %+v", expEvReply, evRply) } @@ -934,7 +934,7 @@ func testAttributeProcessEventWithSearchAndReplace(t *testing.T) { }, } eRply := &engine.AttrSProcessEventReply{ - AlteredFields: []*engine.FieldsAltered{ + Fields: []*engine.FieldsAltered{ { MatchedProfileID: "cgrates.org:ATTR_Search_and_replace", AlteredFields: []string{"*req.Category"}, @@ -1050,7 +1050,7 @@ func testAttributeSProcessWithMultipleRuns(t *testing.T) { }, } eRply := &engine.AttrSProcessEventReply{ - AlteredFields: []*engine.FieldsAltered{ + Fields: []*engine.FieldsAltered{ { MatchedProfileID: "cgrates.org:ATTR_1", AlteredFields: []string{"*req.Field1"}, @@ -1084,8 +1084,8 @@ func testAttributeSProcessWithMultipleRuns(t *testing.T) { attrArgs, &rplyEv); err != nil { t.Fatal(err) } - if !reflect.DeepEqual(eRply.AlteredFields, rplyEv.AlteredFields) { - t.Errorf("Expecting %+v, received: %+v", eRply.AlteredFields, rplyEv.AlteredFields) + if !reflect.DeepEqual(eRply.Fields, rplyEv.Fields) { + t.Errorf("Expecting %+v, received: %+v", eRply.Fields, rplyEv.Fields) } else if !reflect.DeepEqual(eRply.CGREvent.Event, rplyEv.CGREvent.Event) { t.Errorf("Expecting %+v, received: %+v", eRply.CGREvent.Event, rplyEv.CGREvent.Event) } @@ -1179,7 +1179,7 @@ func testAttributeSProcessWithMultipleRuns2(t *testing.T) { }, } eRply := &engine.AttrSProcessEventReply{ - AlteredFields: []*engine.FieldsAltered{ + Fields: []*engine.FieldsAltered{ { MatchedProfileID: "cgrates.org:ATTR_1", AlteredFields: []string{"*req.Field1"}, @@ -1219,11 +1219,11 @@ func testAttributeSProcessWithMultipleRuns2(t *testing.T) { attrArgs, &rplyEv); err != nil { t.Fatal(err) } - sort.Slice(rplyEv.AlteredFields, func(i, j int) bool { - return rplyEv.AlteredFields[i].MatchedProfileID < rplyEv.AlteredFields[j].MatchedProfileID + sort.Slice(rplyEv.Fields, func(i, j int) bool { + return rplyEv.Fields[i].MatchedProfileID < rplyEv.Fields[j].MatchedProfileID }) - if !reflect.DeepEqual(eRply.AlteredFields, rplyEv.AlteredFields) { - t.Errorf("Expecting %+v, received: %+v", utils.ToJSON(eRply.AlteredFields), utils.ToJSON(rplyEv.AlteredFields)) + if !reflect.DeepEqual(eRply.Fields, rplyEv.Fields) { + t.Errorf("Expecting %+v, received: %+v", utils.ToJSON(eRply.Fields), utils.ToJSON(rplyEv.Fields)) } else if !reflect.DeepEqual(eRply.CGREvent.Event, rplyEv.CGREvent.Event) { t.Errorf("Expecting %+v, received: %+v", eRply.CGREvent.Event, rplyEv.CGREvent.Event) } diff --git a/apis/attributes_test.go b/apis/attributes_test.go index 8f73a67d8..97052c18d 100644 --- a/apis/attributes_test.go +++ b/apis/attributes_test.go @@ -521,7 +521,7 @@ func TestAttributesGetAttributeForEvent(t *testing.T) { ev.Event[utils.RequestType] = utils.MetaPseudoPrepaid //now we will process the event for our attr expectedEv := engine.AttrSProcessEventReply{ - AlteredFields: []*engine.FieldsAltered{ + Fields: []*engine.FieldsAltered{ { MatchedProfileID: "cgrates.org:TestGetAttributeProfile", AlteredFields: []string{"*req.RequestType"}, diff --git a/dispatchers/attributes_it_test.go b/dispatchers/attributes_it_test.go index 03d2b3b24..b0a0315eb 100644 --- a/dispatchers/attributes_it_test.go +++ b/dispatchers/attributes_it_test.go @@ -244,7 +244,7 @@ func testDspAttrGetAttrFailover(t *testing.T) { } eRply := &engine.AttrSProcessEventReply{ - AlteredFields: []*engine.FieldsAltered{ + Fields: []*engine.FieldsAltered{ { MatchedProfileID: "cgrates.org:ATTR_1002_SIMPLEAUTH", AlteredFields: []string{"*req.Password"}, @@ -441,7 +441,7 @@ func testDspAttrTestAuthKey2(t *testing.T) { } eRply := &engine.AttrSProcessEventReply{ - AlteredFields: []*engine.FieldsAltered{ + Fields: []*engine.FieldsAltered{ { MatchedProfileID: "cgrates.org:ATTR_1001_SIMPLEAUTH", AlteredFields: []string{"*req.Password"}, @@ -525,7 +525,7 @@ func testDspAttrGetAttrRoundRobin(t *testing.T) { } eRply := &engine.AttrSProcessEventReply{ - AlteredFields: []*engine.FieldsAltered{ + Fields: []*engine.FieldsAltered{ { MatchedProfileID: "cgrates.org:ATTR_1002_SIMPLEAUTH", AlteredFields: []string{"*req.Password"}, @@ -600,7 +600,7 @@ func testDspAttrGetAttrInternal(t *testing.T) { } eRply := &engine.AttrSProcessEventReply{ - AlteredFields: []*engine.FieldsAltered{ + Fields: []*engine.FieldsAltered{ { MatchedProfileID: "cgrates.org:ATTR_1003_SIMPLEAUTH", AlteredFields: []string{"*req.Password"}, diff --git a/ees/ees.go b/ees/ees.go index 0e07bb0c3..198c77dad 100644 --- a/ees/ees.go +++ b/ees/ees.go @@ -114,7 +114,7 @@ func (eeS *EeS) attrSProcessEvent(ctx *context.Context, cgrEv *utils.CGREvent, a if err = eeS.connMgr.Call(ctx, eeS.cfg.EEsNoLksCfg().AttributeSConns, utils.AttributeSv1ProcessEvent, - cgrEv, &rplyEv); err == nil && len(rplyEv.AlteredFields) != 0 { + cgrEv, &rplyEv); err == nil && len(rplyEv.Fields) != 0 { } else if err != nil && err.Error() == utils.ErrNotFound.Error() { err = nil // cancel ErrNotFound diff --git a/ees/ees_test.go b/ees/ees_test.go index c602a2014..d1a74dd7f 100644 --- a/ees/ees_test.go +++ b/ees/ees_test.go @@ -87,7 +87,7 @@ func TestAttrSProcessEvent(t *testing.T) { calls: map[string]func(_ *context.Context, _, _ interface{}) error{ utils.AttributeSv1ProcessEvent: func(_ *context.Context, args, reply interface{}) error { rplyEv := &engine.AttrSProcessEventReply{ - AlteredFields: []*engine.FieldsAltered{{ + Fields: []*engine.FieldsAltered{{ AlteredFields: []string{"testcase"}, }}, } diff --git a/engine/attributes.go b/engine/attributes.go index a233badce..5821357a9 100644 --- a/engine/attributes.go +++ b/engine/attributes.go @@ -114,6 +114,18 @@ func (alS *AttributeS) attributeProfileForEvent(ctx *context.Context, tnt string return apWw.AttributeProfile, nil } +type FieldsAltered struct { + MatchedProfileID string + AlteredFields []string +} + +func (flds *FieldsAltered) UniqueAlteredFields() (unFlds utils.StringSet) { + for _, fldName := range flds.AlteredFields { + unFlds.Add(fldName) + } + return +} + // AttrSProcessEventReply reply used for proccess event type AttrSProcessEventReply struct { Fields []*FieldsAltered @@ -140,11 +152,6 @@ func (attrReply *AttrSProcessEventReply) Digest() (rplyDigest string) { return } -type FieldsAltered struct { - MatchedProfileID string - AlteredFields []string -} - // processEvent will match event with attribute profile and do the necessary replacements func (alS *AttributeS) processEvent(ctx *context.Context, tnt string, args *utils.CGREvent, evNm utils.MapStorage, dynDP utils.DataProvider, lastID string, processedPrfNo map[string]int, profileRuns int) (rply *AttrSProcessEventReply, err error) { diff --git a/general_tests/attributes_filters_index_it_test.go b/general_tests/attributes_filters_index_it_test.go index 02c527b1b..76e47d746 100644 --- a/general_tests/attributes_filters_index_it_test.go +++ b/general_tests/attributes_filters_index_it_test.go @@ -216,7 +216,7 @@ func testAttributeSetFltr2(t *testing.T) { APIOpts: map[string]interface{}{}, } exp := engine.AttrSProcessEventReply{ - AlteredFields: []*engine.FieldsAltered{ + Fields: []*engine.FieldsAltered{ { MatchedProfileID: "cgrates.org:ApierTest", AlteredFields: []string{"*req.FL1"}, diff --git a/general_tests/attributes_it_test.go b/general_tests/attributes_it_test.go index e8f44958c..5216f576f 100644 --- a/general_tests/attributes_it_test.go +++ b/general_tests/attributes_it_test.go @@ -151,7 +151,7 @@ func testAttributeSProcessEvent(t *testing.T) { }, } eRply := engine.AttrSProcessEventReply{ - AlteredFields: []*engine.FieldsAltered{ + Fields: []*engine.FieldsAltered{ { MatchedProfileID: "cgrates.org:ATTR_VARIABLE", AlteredFields: []string{utils.MetaReq + utils.NestingSep + utils.Category}, @@ -228,7 +228,7 @@ func testAttributeSProcessEventWithAccount(t *testing.T) { } eRply := engine.AttrSProcessEventReply{ - AlteredFields: []*engine.FieldsAltered{ + Fields: []*engine.FieldsAltered{ { MatchedProfileID: "cgrates.org:ATTR_ACCOUNT", AlteredFields: []string{utils.MetaReq + utils.NestingSep + "Balance"}, @@ -303,7 +303,7 @@ func testAttributeSProcessEventWithAccountFull(t *testing.T) { } eRply := engine.AttrSProcessEventReply{ - AlteredFields: []*engine.FieldsAltered{ + Fields: []*engine.FieldsAltered{ { MatchedProfileID: "cgrates.org:ATTR_ACCOUNT2", AlteredFields: []string{utils.MetaReq + utils.NestingSep + "FullAccount"}, @@ -324,9 +324,9 @@ func testAttributeSProcessEventWithAccountFull(t *testing.T) { ev, &rplyEv); err != nil { t.Fatal(err) } - if !reflect.DeepEqual(rplyEv.AlteredFields, eRply.AlteredFields) { + if !reflect.DeepEqual(rplyEv.Fields, eRply.Fields) { t.Errorf("Expecting: %s, received: %s", - utils.ToJSON(eRply.AlteredFields), utils.ToJSON(rplyEv.AlteredFields)) + utils.ToJSON(eRply.Fields), utils.ToJSON(rplyEv.Fields)) } } @@ -413,7 +413,7 @@ func testAttributeSProcessEventWithStat(t *testing.T) { } eRply := engine.AttrSProcessEventReply{ - AlteredFields: []*engine.FieldsAltered{ + Fields: []*engine.FieldsAltered{ { MatchedProfileID: "cgrates.org:ATTR_STATS", AlteredFields: []string{utils.MetaReq + utils.NestingSep + "AcdMetric"}, @@ -489,7 +489,7 @@ func testAttributeSProcessEventWithStatFull(t *testing.T) { } eRply := engine.AttrSProcessEventReply{ - AlteredFields: []*engine.FieldsAltered{ + Fields: []*engine.FieldsAltered{ { MatchedProfileID: "cgrates.org:ATTR_STATS2", AlteredFields: []string{utils.MetaReq + utils.NestingSep + "AllMetrics"}, @@ -629,7 +629,7 @@ func testAttributeSProcessEventWithResource(t *testing.T) { } eRply := engine.AttrSProcessEventReply{ - AlteredFields: []*engine.FieldsAltered{ + Fields: []*engine.FieldsAltered{ { MatchedProfileID: "cgrates.org:ATTR_RESOURCE", AlteredFields: []string{utils.MetaReq + utils.NestingSep + "ResourceTotalUsages"}, @@ -707,7 +707,7 @@ func testAttributeSProcessEventWithResourceFull(t *testing.T) { } eRply := engine.AttrSProcessEventReply{ - AlteredFields: []*engine.FieldsAltered{ + Fields: []*engine.FieldsAltered{ { MatchedProfileID: "cgrates.org:ATTR_RESOURCE2", AlteredFields: []string{utils.MetaReq + utils.NestingSep + "FullResource"}, @@ -727,9 +727,9 @@ func testAttributeSProcessEventWithResourceFull(t *testing.T) { ev, &rplyEv); err != nil { t.Fatal(err) } - if !reflect.DeepEqual(rplyEv.AlteredFields, eRply.AlteredFields) { + if !reflect.DeepEqual(rplyEv.Fields, eRply.Fields) { t.Errorf("Expecting: %s, received: %s", - utils.ToJSON(eRply.AlteredFields), utils.ToJSON(rplyEv.AlteredFields)) + utils.ToJSON(eRply.Fields), utils.ToJSON(rplyEv.Fields)) } // some fields are generated(e.g. Time) and compare only some part of the string strRes := utils.IfaceAsString(rplyEv.CGREvent.Event["FullResource"]) @@ -792,7 +792,7 @@ func testAttributeSProcessEventWithLibPhoneNumber(t *testing.T) { } eRply := engine.AttrSProcessEventReply{ - AlteredFields: []*engine.FieldsAltered{ + Fields: []*engine.FieldsAltered{ { MatchedProfileID: "cgrates.org:ATTR_LIBPHONENUMBER2", AlteredFields: []string{utils.MetaReq + utils.NestingSep + "DestinationCarrier"}, @@ -877,7 +877,7 @@ func testAttributeSProcessEventWithLibPhoneNumberComposed(t *testing.T) { } eRply := engine.AttrSProcessEventReply{ - AlteredFields: []*engine.FieldsAltered{ + Fields: []*engine.FieldsAltered{ { MatchedProfileID: "cgrates.org:ATTR_LIBPHONENUMBER_COMPOSED", AlteredFields: []string{utils.MetaReq + utils.NestingSep + "DestinationCarrier"}, @@ -957,7 +957,7 @@ func testAttributeSProcessEventWithLibPhoneNumberFull(t *testing.T) { } eRply := engine.AttrSProcessEventReply{ - AlteredFields: []*engine.FieldsAltered{ + Fields: []*engine.FieldsAltered{ { MatchedProfileID: "cgrates.org:ATTR_LIBPHONENUMBER", AlteredFields: []string{utils.MetaReq + utils.NestingSep + "DestinationDetails"}, diff --git a/sessions/libsessions.go b/sessions/libsessions.go index 7980796f5..84cb0f7a0 100644 --- a/sessions/libsessions.go +++ b/sessions/libsessions.go @@ -309,7 +309,7 @@ func (v1Rply *V1ProcessEventReply) AsNavigableMap() map[string]*utils.DataNode { atts := &utils.DataNode{Type: utils.NMMapType, Map: make(map[string]*utils.DataNode)} for k, att := range v1Rply.Attributes { attrs := &utils.DataNode{Type: utils.NMMapType, Map: make(map[string]*utils.DataNode)} - for _, altered := range att.AlteredFields { + for _, altered := range att.Fields { for _, fldName := range altered.AlteredFields { fldName = strings.TrimPrefix(fldName, utils.MetaReq+utils.NestingSep) if att.CGREvent.HasField(fldName) { @@ -401,7 +401,7 @@ func (v1Rply *V1ProcessMessageReply) AsNavigableMap() map[string]*utils.DataNode if v1Rply.Attributes != nil { attrs := &utils.DataNode{Type: utils.NMMapType, Map: make(map[string]*utils.DataNode)} - for _, altered := range v1Rply.Attributes.AlteredFields { + for _, altered := range v1Rply.Attributes.Fields { for _, fldName := range altered.AlteredFields { fldName = strings.TrimPrefix(fldName, utils.MetaReq+utils.NestingSep) if v1Rply.Attributes.CGREvent.HasField(fldName) { @@ -457,7 +457,7 @@ func (v1AuthReply *V1AuthorizeReply) AsNavigableMap() map[string]*utils.DataNode cgrReply := make(map[string]*utils.DataNode) if v1AuthReply.Attributes != nil { attrs := &utils.DataNode{Type: utils.NMMapType, Map: make(map[string]*utils.DataNode)} - for _, altered := range v1AuthReply.Attributes.AlteredFields { + for _, altered := range v1AuthReply.Attributes.Fields { for _, fldName := range altered.AlteredFields { fldName = strings.TrimPrefix(fldName, utils.MetaReq+utils.NestingSep) if v1AuthReply.Attributes.CGREvent.HasField(fldName) { @@ -532,7 +532,7 @@ func (v1Rply *V1InitSessionReply) AsNavigableMap() map[string]*utils.DataNode { cgrReply := make(map[string]*utils.DataNode) if v1Rply.Attributes != nil { attrs := &utils.DataNode{Type: utils.NMMapType, Map: make(map[string]*utils.DataNode)} - for _, altered := range v1Rply.Attributes.AlteredFields { + for _, altered := range v1Rply.Attributes.Fields { for _, fldName := range altered.AlteredFields { fldName = strings.TrimPrefix(fldName, utils.MetaReq+utils.NestingSep) if v1Rply.Attributes.CGREvent.HasField(fldName) { @@ -599,7 +599,7 @@ func (v1Rply *V1UpdateSessionReply) AsNavigableMap() map[string]*utils.DataNode cgrReply := make(map[string]*utils.DataNode) if v1Rply.Attributes != nil { attrs := &utils.DataNode{Type: utils.NMMapType, Map: make(map[string]*utils.DataNode)} - for _, altered := range v1Rply.Attributes.AlteredFields { + for _, altered := range v1Rply.Attributes.Fields { for _, fldName := range altered.AlteredFields { fldName = strings.TrimPrefix(fldName, utils.MetaReq+utils.NestingSep) if v1Rply.Attributes.CGREvent.HasField(fldName) { diff --git a/sessions/sessions_test.go b/sessions/sessions_test.go index 21a4a8151..6aa9b58fb 100644 --- a/sessions/sessions_test.go +++ b/sessions/sessions_test.go @@ -32,7 +32,7 @@ import ( ) var attrs = &engine.AttrSProcessEventReply{ - AlteredFields: []*engine.FieldsAltered{ + Fields: []*engine.FieldsAltered{ { MatchedProfileID: "ATTR_ACNT_1001", AlteredFields: []string{"*req.OfficeGroup"},