diff --git a/engine/attributes.go b/engine/attributes.go index 62d27592c..2de214530 100644 --- a/engine/attributes.go +++ b/engine/attributes.go @@ -125,8 +125,8 @@ func (flds *AttrSProcessEventReply) UniqueAlteredFields() (unFlds utils.StringSe // AttrSProcessEventReply reply used for proccess event type AttrSProcessEventReply struct { AlteredFields []*FieldsAltered - *utils.CGREvent - blocker bool // internally used to stop further processRuns + CGREvent *utils.CGREvent + blocker bool // internally used to stop further processRuns } // Digest returns serialized version of alteredFields in AttrSProcessEventReply @@ -177,7 +177,7 @@ func (alS *AttributeS) processEvent(ctx *context.Context, tnt string, args *util CGREvent: args, blocker: blocker, } - rply.Tenant = tnt + rply.CGREvent.Tenant = tnt for _, attribute := range attrPrf.Attributes { //in case that we have filter for attribute send them to FilterS to be processed if len(attribute.FilterIDs) != 0 { diff --git a/engine/routes.go b/engine/routes.go index d3dd83503..447322b31 100644 --- a/engine/routes.go +++ b/engine/routes.go @@ -298,7 +298,7 @@ func (rpS *RouteS) V1GetRoutes(ctx *context.Context, args *utils.CGREvent, reply if err := rpS.connMgr.Call(ctx, rpS.cfg.RouteSCfg().AttributeSConns, utils.AttributeSv1ProcessEvent, args, &rplyEv); err == nil && len(rplyEv.AlteredFields) != 0 { args = rplyEv.CGREvent - args.APIOpts = rplyEv.APIOpts + args.APIOpts = rplyEv.CGREvent.APIOpts } else if err = utils.CastRPCErr(err); err != utils.ErrNotFound { return utils.NewErrRouteS(err) } diff --git a/engine/z_attributes_test.go b/engine/z_attributes_test.go index 9abd43f3e..61f6dc05a 100644 --- a/engine/z_attributes_test.go +++ b/engine/z_attributes_test.go @@ -5461,11 +5461,11 @@ func TestAttributesProcessEventPasswordAttribute(t *testing.T) { t.Fatalf("expected: <%+v>,\nreceived: <%+v>", utils.ToJSON(exp.AlteredFields), utils.ToJSON(reply.AlteredFields)) } else { - hashedPw = utils.IfaceAsString(reply.Event["Password"]) + hashedPw = utils.IfaceAsString(reply.CGREvent.Event["Password"]) if !utils.VerifyHash(hashedPw, "abcd123") { t.Fatalf("expected: <%+v>, \nreceived: <%+v>", "abcd123", hashedPw) } - exp.Event["Password"] = hashedPw + exp.CGREvent.Event["Password"] = hashedPw if !reflect.DeepEqual(reply.CGREvent, exp.CGREvent) { t.Fatalf("expected: <%+v>, \nreceived: <%+v>", utils.ToJSON(exp.CGREvent), utils.ToJSON(reply.CGREvent)) diff --git a/general_tests/analyzers_doc_it_test.go b/general_tests/analyzers_doc_it_test.go index d39ee3fef..dbe4f463a 100644 --- a/general_tests/analyzers_doc_it_test.go +++ b/general_tests/analyzers_doc_it_test.go @@ -121,7 +121,7 @@ func TestAnzDocIT(t *testing.T) { anzStringQuery(t, client, 7, "", "*lte:~*hdr.RequestID:2") anzStringQuery(t, client, -1, "", "*gt:~*hdr.RequestDuration:1ms") - anzStringQuery(t, client, 1, `+RequestMethod:"AttributeSv1.ProcessEvent"`, "*notstring:~*rep.Event.Cost:0") + anzStringQuery(t, client, 1, `+RequestMethod:"AttributeSv1.ProcessEvent"`, "*notstring:~*rep.CGREvent.Event.Cost:0") anzStringQuery(t, client, 1, `+RequestMethod:"CoreSv1.Status"`, "*gt:~*rep.goroutines:47") } @@ -432,7 +432,7 @@ func attrProcessEvents(t *testing.T, client *birpc.Client) { utils.Cost: 2.01, }, } - expectedReply := `{"AlteredFields":[{"MatchedProfileID":"cgrates.org:ATTR_1001","Fields":["*req.RequestType"]}],"Tenant":"cgrates.org","ID":"call1001to1002","Event":{"Account":"1001","AnswerTime":"2013-11-07T08:42:28Z","Category":"call","Cost":1.01,"Destination":"1002","OriginHost":"192.168.1.1","OriginID":"abcdef","RequestType":"*rated","RunID":"*default","SetupTime":"2013-11-07T08:42:25Z","Subject":"1001","Tenant":"cgrates.org","ToR":"*voice","Usage":10000000000},"APIOpts":{}}` + expectedReply := `{"AlteredFields":[{"MatchedProfileID":"cgrates.org:ATTR_1001","Fields":["*req.RequestType"]}],"CGREvent":{"Tenant":"cgrates.org","ID":"call1001to1002","Event":{"Account":"1001","AnswerTime":"2013-11-07T08:42:28Z","Category":"call","Cost":1.01,"Destination":"1002","OriginHost":"192.168.1.1","OriginID":"abcdef","RequestType":"*rated","RunID":"*default","SetupTime":"2013-11-07T08:42:25Z","Subject":"1001","Tenant":"cgrates.org","ToR":"*voice","Usage":10000000000},"APIOpts":{}}}` var rplyEv engine.AttrSProcessEventReply if err := client.Call(context.Background(), utils.AttributeSv1ProcessEvent, eventCall1001to1002, &rplyEv); err != nil { @@ -441,7 +441,7 @@ func attrProcessEvents(t *testing.T, client *birpc.Client) { t.Errorf("expected: <%+v>, \nreceived: <%+v>", expectedReply, jsonReply) } - expectedReply = `{"AlteredFields":[{"MatchedProfileID":"cgrates.org:ATTR_PRF_11","Fields":["*req.Cost"]},{"MatchedProfileID":"cgrates.org:ATTR_1101","Fields":["*req.RequestType"]}],"Tenant":"cgrates.org","ID":"call1011to1002","Event":{"Account":"1101","AnswerTime":"2013-11-07T08:42:35Z","Category":"call","Cost":"0","Destination":"1002","OriginHost":"192.168.1.1","OriginID":"ghijkl","RequestType":"*prepaid","RunID":"*default","SetupTime":"2013-11-07T08:42:28Z","Subject":"1101","Tenant":"cgrates.org","ToR":"*voice","Usage":15000000000},"APIOpts":{}}` + expectedReply = `{"AlteredFields":[{"MatchedProfileID":"cgrates.org:ATTR_PRF_11","Fields":["*req.Cost"]},{"MatchedProfileID":"cgrates.org:ATTR_1101","Fields":["*req.RequestType"]}],"CGREvent":{"Tenant":"cgrates.org","ID":"call1011to1002","Event":{"Account":"1101","AnswerTime":"2013-11-07T08:42:35Z","Category":"call","Cost":"0","Destination":"1002","OriginHost":"192.168.1.1","OriginID":"ghijkl","RequestType":"*prepaid","RunID":"*default","SetupTime":"2013-11-07T08:42:28Z","Subject":"1101","Tenant":"cgrates.org","ToR":"*voice","Usage":15000000000},"APIOpts":{}}}` if err := client.Call(context.Background(), utils.AttributeSv1ProcessEvent, eventCall1101to1002, &rplyEv); err != nil { t.Error(err) @@ -449,7 +449,7 @@ func attrProcessEvents(t *testing.T, client *birpc.Client) { t.Errorf("expected: <%+v>, \nreceived: <%+v>", expectedReply, jsonReply) } - expectedReply = `{"AlteredFields":[{"MatchedProfileID":"cgrates.org:ATTR_PRF_11","Fields":["*req.Cost"]},{"MatchedProfileID":"cgrates.org:ATTR_1102","Fields":["*req.RequestType"]}],"Tenant":"cgrates.org","ID":"call1102to1001","Event":{"Account":"1102","AnswerTime":"2013-11-07T08:42:42Z","Category":"call","Cost":"0","Destination":"1001","OriginHost":"192.168.1.1","OriginID":"uvwxyz","RequestType":"*pseudoprepaid","RunID":"*default","SetupTime":"2013-11-07T08:42:35Z","Subject":"1102","Tenant":"cgrates.org","ToR":"*voice","Usage":20000000000},"APIOpts":{}}` + expectedReply = `{"AlteredFields":[{"MatchedProfileID":"cgrates.org:ATTR_PRF_11","Fields":["*req.Cost"]},{"MatchedProfileID":"cgrates.org:ATTR_1102","Fields":["*req.RequestType"]}],"CGREvent":{"Tenant":"cgrates.org","ID":"call1102to1001","Event":{"Account":"1102","AnswerTime":"2013-11-07T08:42:42Z","Category":"call","Cost":"0","Destination":"1001","OriginHost":"192.168.1.1","OriginID":"uvwxyz","RequestType":"*pseudoprepaid","RunID":"*default","SetupTime":"2013-11-07T08:42:35Z","Subject":"1102","Tenant":"cgrates.org","ToR":"*voice","Usage":20000000000},"APIOpts":{}}}` if err := client.Call(context.Background(), utils.AttributeSv1ProcessEvent, eventCall1102to1001, &rplyEv); err != nil { t.Error(err)