mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 18:16:24 +05:00
Move context out of CGREvent
This commit is contained in:
@@ -40,13 +40,12 @@ const (
|
||||
KamHashEntry = "h_entry"
|
||||
KamHashID = "h_id"
|
||||
KamReplyRoute = "reply_route"
|
||||
KamCGRContext = "cgr_context"
|
||||
EvapiConnID = "EvapiConnID" // used to share connID info in event for remote disconnects
|
||||
CGR_DLG_LIST = "CGR_DLG_LIST"
|
||||
)
|
||||
|
||||
var (
|
||||
kamReservedEventFields = []string{EVENT, KamTRIndex, KamTRLabel, utils.CGRSubsystems, KamCGRContext, KamReplyRoute}
|
||||
kamReservedEventFields = []string{EVENT, KamTRIndex, KamTRLabel, utils.CGRSubsystems, KamReplyRoute}
|
||||
kamReservedCDRFields = append(kamReservedEventFields, KamHashEntry, KamHashID) // HashEntry and id are needed in events for disconnects
|
||||
)
|
||||
|
||||
@@ -160,9 +159,6 @@ func (kev KamEvent) AsCGREvent(timezone string) (cgrEv *utils.CGREvent, err erro
|
||||
Time: &sTime,
|
||||
Event: kev.AsMapStringInterface(),
|
||||
}
|
||||
if ctx, has := kev[KamCGRContext]; has {
|
||||
cgrEv.Context = utils.StringPointer(ctx)
|
||||
}
|
||||
return cgrEv, nil
|
||||
}
|
||||
|
||||
|
||||
@@ -111,8 +111,7 @@ func TestKamEvAsCGREvent(t *testing.T) {
|
||||
"cgr_destination": "1002", "cgr_answertime": "1419839310",
|
||||
"cgr_duration": "3", "cgr_pdd": "4",
|
||||
utils.CGR_SUPPLIER: "supplier2",
|
||||
utils.CGR_DISCONNECT_CAUSE: "200",
|
||||
KamCGRContext: "account_profile"}
|
||||
utils.CGR_DISCONNECT_CAUSE: "200"}
|
||||
sTime, err := utils.ParseTimeDetectLayout(kamEv[utils.AnswerTime], timezone)
|
||||
if err != nil {
|
||||
return
|
||||
@@ -120,10 +119,9 @@ func TestKamEvAsCGREvent(t *testing.T) {
|
||||
expected := &utils.CGREvent{
|
||||
Tenant: utils.FirstNonEmpty(kamEv[utils.Tenant],
|
||||
config.CgrConfig().GeneralCfg().DefaultTenant),
|
||||
ID: utils.UUIDSha1Prefix(),
|
||||
Time: &sTime,
|
||||
Context: utils.StringPointer("account_profile"),
|
||||
Event: kamEv.AsMapStringInterface(),
|
||||
ID: utils.UUIDSha1Prefix(),
|
||||
Time: &sTime,
|
||||
Event: kamEv.AsMapStringInterface(),
|
||||
}
|
||||
if rcv, err := kamEv.AsCGREvent(timezone); err != nil {
|
||||
t.Error(err)
|
||||
@@ -240,9 +238,8 @@ func TestKamEvAsKamAuthReply(t *testing.T) {
|
||||
MatchedProfiles: []string{"ATTR_1001_ACCOUNT_PROFILE"},
|
||||
AlteredFields: []string{"Password", utils.RequestType},
|
||||
CGREvent: &utils.CGREvent{
|
||||
Tenant: "cgrates.org",
|
||||
ID: "TestKamEvAsKamAuthReply",
|
||||
Context: utils.StringPointer("account_profile"),
|
||||
Tenant: "cgrates.org",
|
||||
ID: "TestKamEvAsKamAuthReply",
|
||||
Event: map[string]interface{}{
|
||||
utils.Tenant: "cgrates.org",
|
||||
utils.Account: "1001",
|
||||
|
||||
@@ -179,6 +179,7 @@ func (dS *DispatcherService) authorizeEvent(ev *utils.CGREvent,
|
||||
reply *engine.AttrSProcessEventReply) (err error) {
|
||||
if err = dS.attrS.Call(utils.AttributeSv1ProcessEvent,
|
||||
&engine.AttrArgsProcessEvent{
|
||||
Context: utils.StringPointer(utils.MetaAuth),
|
||||
CGREvent: *ev}, reply); err != nil {
|
||||
if err.Error() == utils.ErrNotFound.Error() {
|
||||
err = utils.ErrUnknownApiKey
|
||||
@@ -193,10 +194,9 @@ func (dS *DispatcherService) authorize(method, tenant, apiKey string, evTime *ti
|
||||
return utils.NewErrMandatoryIeMissing(utils.APIKey)
|
||||
}
|
||||
ev := &utils.CGREvent{
|
||||
Tenant: tenant,
|
||||
ID: utils.UUIDSha1Prefix(),
|
||||
Context: utils.StringPointer(utils.MetaAuth),
|
||||
Time: evTime,
|
||||
Tenant: tenant,
|
||||
ID: utils.UUIDSha1Prefix(),
|
||||
Time: evTime,
|
||||
Event: map[string]interface{}{
|
||||
utils.APIKey: apiKey,
|
||||
},
|
||||
|
||||
@@ -330,7 +330,7 @@ func testDspSessionUpdate(t *testing.T) {
|
||||
utils.ToJSON(eAttrs), utils.ToJSON(rply.Attributes))
|
||||
}
|
||||
if *rply.MaxUsage != reqUsage {
|
||||
t.Errorf("Unexpected MaxUsage: %v", rply.MaxUsage)
|
||||
t.Errorf("Unexpected MaxUsage: %v", utils.ToJSON(rply))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -142,7 +142,8 @@ func (attrReply *AttrSProcessEventReply) Digest() (rplyDigest string) {
|
||||
|
||||
type AttrArgsProcessEvent struct {
|
||||
AttributeIDs []string
|
||||
ProcessRuns *int // number of loops for ProcessEvent
|
||||
Context *string // attach the event to a context
|
||||
ProcessRuns *int // number of loops for ProcessEvent
|
||||
utils.CGREvent
|
||||
}
|
||||
|
||||
|
||||
@@ -43,10 +43,10 @@ var (
|
||||
}
|
||||
attrEvs = []*AttrArgsProcessEvent{
|
||||
{
|
||||
Context: utils.StringPointer(utils.MetaSessionS),
|
||||
CGREvent: utils.CGREvent{ //matching AttributeProfile1
|
||||
Tenant: config.CgrConfig().GeneralCfg().DefaultTenant,
|
||||
ID: utils.GenUUID(),
|
||||
Context: utils.StringPointer(utils.MetaSessionS),
|
||||
Tenant: config.CgrConfig().GeneralCfg().DefaultTenant,
|
||||
ID: utils.GenUUID(),
|
||||
Event: map[string]interface{}{
|
||||
"Attribute": "AttributeProfile1",
|
||||
utils.AnswerTime: time.Date(2014, 7, 14, 14, 30, 0, 0, time.UTC),
|
||||
@@ -56,30 +56,30 @@ var (
|
||||
},
|
||||
},
|
||||
{
|
||||
Context: utils.StringPointer(utils.MetaSessionS),
|
||||
CGREvent: utils.CGREvent{ //matching AttributeProfile2
|
||||
Tenant: config.CgrConfig().GeneralCfg().DefaultTenant,
|
||||
ID: utils.GenUUID(),
|
||||
Context: utils.StringPointer(utils.MetaSessionS),
|
||||
Tenant: config.CgrConfig().GeneralCfg().DefaultTenant,
|
||||
ID: utils.GenUUID(),
|
||||
Event: map[string]interface{}{
|
||||
"Attribute": "AttributeProfile2",
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
Context: utils.StringPointer(utils.MetaSessionS),
|
||||
CGREvent: utils.CGREvent{ //matching AttributeProfilePrefix
|
||||
Tenant: config.CgrConfig().GeneralCfg().DefaultTenant,
|
||||
ID: utils.GenUUID(),
|
||||
Context: utils.StringPointer(utils.MetaSessionS),
|
||||
Tenant: config.CgrConfig().GeneralCfg().DefaultTenant,
|
||||
ID: utils.GenUUID(),
|
||||
Event: map[string]interface{}{
|
||||
"Attribute": "AttributeProfilePrefix",
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
Context: utils.StringPointer(utils.MetaSessionS),
|
||||
CGREvent: utils.CGREvent{ //matching AttributeProfilePrefix
|
||||
Tenant: config.CgrConfig().GeneralCfg().DefaultTenant,
|
||||
ID: utils.GenUUID(),
|
||||
Context: utils.StringPointer(utils.MetaSessionS),
|
||||
Tenant: config.CgrConfig().GeneralCfg().DefaultTenant,
|
||||
ID: utils.GenUUID(),
|
||||
Event: map[string]interface{}{
|
||||
"DistinctMatch": 20,
|
||||
},
|
||||
@@ -333,9 +333,8 @@ func TestAttributeEventReplyDigest(t *testing.T) {
|
||||
MatchedProfiles: []string{"ATTR_1"},
|
||||
AlteredFields: []string{utils.Account, utils.Subject},
|
||||
CGREvent: &utils.CGREvent{
|
||||
Tenant: "cgrates.org",
|
||||
ID: "testAttributeSProcessEvent",
|
||||
Context: utils.StringPointer(utils.MetaSessionS),
|
||||
Tenant: "cgrates.org",
|
||||
ID: "testAttributeSProcessEvent",
|
||||
Event: map[string]interface{}{
|
||||
utils.Account: "1001",
|
||||
utils.Subject: "1001",
|
||||
@@ -355,9 +354,8 @@ func TestAttributeEventReplyDigest2(t *testing.T) {
|
||||
MatchedProfiles: []string{"ATTR_1"},
|
||||
AlteredFields: []string{},
|
||||
CGREvent: &utils.CGREvent{
|
||||
Tenant: "cgrates.org",
|
||||
ID: "testAttributeSProcessEvent",
|
||||
Context: utils.StringPointer(utils.MetaSessionS),
|
||||
Tenant: "cgrates.org",
|
||||
ID: "testAttributeSProcessEvent",
|
||||
Event: map[string]interface{}{
|
||||
utils.Account: "1001",
|
||||
utils.Subject: "1001",
|
||||
@@ -377,9 +375,8 @@ func TestAttributeEventReplyDigest3(t *testing.T) {
|
||||
MatchedProfiles: []string{"ATTR_1"},
|
||||
AlteredFields: []string{"Subject"},
|
||||
CGREvent: &utils.CGREvent{
|
||||
Tenant: "cgrates.org",
|
||||
ID: "testAttributeSProcessEvent",
|
||||
Context: utils.StringPointer(utils.MetaSessionS),
|
||||
Tenant: "cgrates.org",
|
||||
ID: "testAttributeSProcessEvent",
|
||||
Event: map[string]interface{}{
|
||||
utils.Account: "1001",
|
||||
utils.Subject: "1001",
|
||||
@@ -399,9 +396,8 @@ func TestAttributeEventReplyDigest4(t *testing.T) {
|
||||
MatchedProfiles: []string{"ATTR_1"},
|
||||
AlteredFields: []string{"Subject"},
|
||||
CGREvent: &utils.CGREvent{
|
||||
Tenant: "cgrates.org",
|
||||
ID: "testAttributeSProcessEvent",
|
||||
Context: utils.StringPointer(utils.MetaSessionS),
|
||||
Tenant: "cgrates.org",
|
||||
ID: "testAttributeSProcessEvent",
|
||||
Event: map[string]interface{}{
|
||||
utils.Account: "1001",
|
||||
utils.Destinations: "+491511231234",
|
||||
@@ -559,11 +555,11 @@ func TestAttributeProcessWithMultipleRuns1(t *testing.T) {
|
||||
t.Errorf("Error: %+v", err)
|
||||
}
|
||||
attrArgs := &AttrArgsProcessEvent{
|
||||
Context: utils.StringPointer(utils.MetaSessionS),
|
||||
ProcessRuns: utils.IntPointer(4),
|
||||
CGREvent: utils.CGREvent{
|
||||
Tenant: config.CgrConfig().GeneralCfg().DefaultTenant,
|
||||
ID: utils.GenUUID(),
|
||||
Context: utils.StringPointer(utils.MetaSessionS),
|
||||
Tenant: config.CgrConfig().GeneralCfg().DefaultTenant,
|
||||
ID: utils.GenUUID(),
|
||||
Event: map[string]interface{}{
|
||||
"InitialField": "InitialValue",
|
||||
},
|
||||
@@ -573,9 +569,8 @@ func TestAttributeProcessWithMultipleRuns1(t *testing.T) {
|
||||
MatchedProfiles: []string{"ATTR_1", "ATTR_2", "ATTR_3"},
|
||||
AlteredFields: []string{"Field1", "Field2", "Field3"},
|
||||
CGREvent: &utils.CGREvent{
|
||||
Tenant: config.CgrConfig().GeneralCfg().DefaultTenant,
|
||||
ID: utils.GenUUID(),
|
||||
Context: utils.StringPointer(utils.MetaSessionS),
|
||||
Tenant: config.CgrConfig().GeneralCfg().DefaultTenant,
|
||||
ID: utils.GenUUID(),
|
||||
Event: map[string]interface{}{
|
||||
"InitialField": "InitialValue",
|
||||
"Field1": "Value1",
|
||||
@@ -674,11 +669,11 @@ func TestAttributeProcessWithMultipleRuns2(t *testing.T) {
|
||||
t.Errorf("Error: %+v", err)
|
||||
}
|
||||
attrArgs := &AttrArgsProcessEvent{
|
||||
Context: utils.StringPointer(utils.MetaSessionS),
|
||||
ProcessRuns: utils.IntPointer(4),
|
||||
CGREvent: utils.CGREvent{
|
||||
Tenant: config.CgrConfig().GeneralCfg().DefaultTenant,
|
||||
ID: utils.GenUUID(),
|
||||
Context: utils.StringPointer(utils.MetaSessionS),
|
||||
Tenant: config.CgrConfig().GeneralCfg().DefaultTenant,
|
||||
ID: utils.GenUUID(),
|
||||
Event: map[string]interface{}{
|
||||
"InitialField": "InitialValue",
|
||||
},
|
||||
@@ -688,9 +683,8 @@ func TestAttributeProcessWithMultipleRuns2(t *testing.T) {
|
||||
MatchedProfiles: []string{"ATTR_1", "ATTR_2"},
|
||||
AlteredFields: []string{"Field1", "Field2"},
|
||||
CGREvent: &utils.CGREvent{
|
||||
Tenant: config.CgrConfig().GeneralCfg().DefaultTenant,
|
||||
ID: utils.GenUUID(),
|
||||
Context: utils.StringPointer(utils.MetaSessionS),
|
||||
Tenant: config.CgrConfig().GeneralCfg().DefaultTenant,
|
||||
ID: utils.GenUUID(),
|
||||
Event: map[string]interface{}{
|
||||
"InitialField": "InitialValue",
|
||||
"Field1": "Value1",
|
||||
@@ -788,11 +782,11 @@ func TestAttributeProcessWithMultipleRuns3(t *testing.T) {
|
||||
t.Errorf("Error: %+v", err)
|
||||
}
|
||||
attrArgs := &AttrArgsProcessEvent{
|
||||
Context: utils.StringPointer(utils.MetaSessionS),
|
||||
ProcessRuns: utils.IntPointer(2),
|
||||
CGREvent: utils.CGREvent{
|
||||
Tenant: config.CgrConfig().GeneralCfg().DefaultTenant,
|
||||
ID: utils.GenUUID(),
|
||||
Context: utils.StringPointer(utils.MetaSessionS),
|
||||
Tenant: config.CgrConfig().GeneralCfg().DefaultTenant,
|
||||
ID: utils.GenUUID(),
|
||||
Event: map[string]interface{}{
|
||||
"InitialField": "InitialValue",
|
||||
},
|
||||
@@ -802,9 +796,8 @@ func TestAttributeProcessWithMultipleRuns3(t *testing.T) {
|
||||
MatchedProfiles: []string{"ATTR_1", "ATTR_2"},
|
||||
AlteredFields: []string{"Field1", "Field2"},
|
||||
CGREvent: &utils.CGREvent{
|
||||
Tenant: config.CgrConfig().GeneralCfg().DefaultTenant,
|
||||
ID: utils.GenUUID(),
|
||||
Context: utils.StringPointer(utils.MetaSessionS),
|
||||
Tenant: config.CgrConfig().GeneralCfg().DefaultTenant,
|
||||
ID: utils.GenUUID(),
|
||||
Event: map[string]interface{}{
|
||||
"InitialField": "InitialValue",
|
||||
"Field1": "Value1",
|
||||
@@ -881,11 +874,11 @@ func TestAttributeProcessWithMultipleRuns4(t *testing.T) {
|
||||
t.Errorf("Error: %+v", err)
|
||||
}
|
||||
attrArgs := &AttrArgsProcessEvent{
|
||||
Context: utils.StringPointer(utils.MetaSessionS),
|
||||
ProcessRuns: utils.IntPointer(4),
|
||||
CGREvent: utils.CGREvent{
|
||||
Tenant: config.CgrConfig().GeneralCfg().DefaultTenant,
|
||||
ID: utils.GenUUID(),
|
||||
Context: utils.StringPointer(utils.MetaSessionS),
|
||||
Tenant: config.CgrConfig().GeneralCfg().DefaultTenant,
|
||||
ID: utils.GenUUID(),
|
||||
Event: map[string]interface{}{
|
||||
"InitialField": "InitialValue",
|
||||
},
|
||||
@@ -895,9 +888,8 @@ func TestAttributeProcessWithMultipleRuns4(t *testing.T) {
|
||||
MatchedProfiles: []string{"ATTR_1", "ATTR_2"},
|
||||
AlteredFields: []string{"Field1", "Field2"},
|
||||
CGREvent: &utils.CGREvent{
|
||||
Tenant: config.CgrConfig().GeneralCfg().DefaultTenant,
|
||||
ID: utils.GenUUID(),
|
||||
Context: utils.StringPointer(utils.MetaSessionS),
|
||||
Tenant: config.CgrConfig().GeneralCfg().DefaultTenant,
|
||||
ID: utils.GenUUID(),
|
||||
Event: map[string]interface{}{
|
||||
"InitialField": "InitialValue",
|
||||
"Field1": "Value1",
|
||||
@@ -996,11 +988,11 @@ func TestAttributeMultipleProcessWithBlocker(t *testing.T) {
|
||||
t.Errorf("Error: %+v", err)
|
||||
}
|
||||
attrArgs := &AttrArgsProcessEvent{
|
||||
Context: utils.StringPointer(utils.MetaSessionS),
|
||||
ProcessRuns: utils.IntPointer(4),
|
||||
CGREvent: utils.CGREvent{
|
||||
Tenant: config.CgrConfig().GeneralCfg().DefaultTenant,
|
||||
ID: utils.GenUUID(),
|
||||
Context: utils.StringPointer(utils.MetaSessionS),
|
||||
Tenant: config.CgrConfig().GeneralCfg().DefaultTenant,
|
||||
ID: utils.GenUUID(),
|
||||
Event: map[string]interface{}{
|
||||
"InitialField": "InitialValue",
|
||||
},
|
||||
@@ -1010,9 +1002,8 @@ func TestAttributeMultipleProcessWithBlocker(t *testing.T) {
|
||||
MatchedProfiles: []string{"ATTR_1", "ATTR_2"},
|
||||
AlteredFields: []string{"Field1", "Field2"},
|
||||
CGREvent: &utils.CGREvent{
|
||||
Tenant: config.CgrConfig().GeneralCfg().DefaultTenant,
|
||||
ID: utils.GenUUID(),
|
||||
Context: utils.StringPointer(utils.MetaSessionS),
|
||||
Tenant: config.CgrConfig().GeneralCfg().DefaultTenant,
|
||||
ID: utils.GenUUID(),
|
||||
Event: map[string]interface{}{
|
||||
"InitialField": "InitialValue",
|
||||
"Field1": "Value1",
|
||||
@@ -1111,11 +1102,11 @@ func TestAttributeMultipleProcessWithBlocker2(t *testing.T) {
|
||||
t.Errorf("Error: %+v", err)
|
||||
}
|
||||
attrArgs := &AttrArgsProcessEvent{
|
||||
Context: utils.StringPointer(utils.MetaSessionS),
|
||||
ProcessRuns: utils.IntPointer(4),
|
||||
CGREvent: utils.CGREvent{
|
||||
Tenant: config.CgrConfig().GeneralCfg().DefaultTenant,
|
||||
ID: utils.GenUUID(),
|
||||
Context: utils.StringPointer(utils.MetaSessionS),
|
||||
Tenant: config.CgrConfig().GeneralCfg().DefaultTenant,
|
||||
ID: utils.GenUUID(),
|
||||
Event: map[string]interface{}{
|
||||
"InitialField": "InitialValue",
|
||||
},
|
||||
@@ -1125,9 +1116,8 @@ func TestAttributeMultipleProcessWithBlocker2(t *testing.T) {
|
||||
MatchedProfiles: []string{"ATTR_1"},
|
||||
AlteredFields: []string{"Field1"},
|
||||
CGREvent: &utils.CGREvent{
|
||||
Tenant: config.CgrConfig().GeneralCfg().DefaultTenant,
|
||||
ID: utils.GenUUID(),
|
||||
Context: utils.StringPointer(utils.MetaSessionS),
|
||||
Tenant: config.CgrConfig().GeneralCfg().DefaultTenant,
|
||||
ID: utils.GenUUID(),
|
||||
Event: map[string]interface{}{
|
||||
"InitialField": "InitialValue",
|
||||
"Field1": "Value1",
|
||||
@@ -1183,11 +1173,11 @@ func TestAttributeProcessSubstitute(t *testing.T) {
|
||||
t.Error(err)
|
||||
}
|
||||
attrArgs := &AttrArgsProcessEvent{
|
||||
Context: utils.StringPointer(utils.MetaSessionS),
|
||||
ProcessRuns: utils.IntPointer(1),
|
||||
CGREvent: utils.CGREvent{
|
||||
Tenant: config.CgrConfig().GeneralCfg().DefaultTenant,
|
||||
ID: utils.GenUUID(),
|
||||
Context: utils.StringPointer(utils.MetaSessionS),
|
||||
Tenant: config.CgrConfig().GeneralCfg().DefaultTenant,
|
||||
ID: utils.GenUUID(),
|
||||
Event: map[string]interface{}{
|
||||
"Field1": "Value1",
|
||||
},
|
||||
@@ -1197,9 +1187,8 @@ func TestAttributeProcessSubstitute(t *testing.T) {
|
||||
MatchedProfiles: []string{"ATTR_1"},
|
||||
AlteredFields: []string{"Field2"},
|
||||
CGREvent: &utils.CGREvent{
|
||||
Tenant: config.CgrConfig().GeneralCfg().DefaultTenant,
|
||||
ID: utils.GenUUID(),
|
||||
Context: utils.StringPointer(utils.MetaSessionS),
|
||||
Tenant: config.CgrConfig().GeneralCfg().DefaultTenant,
|
||||
ID: utils.GenUUID(),
|
||||
Event: map[string]interface{}{
|
||||
"Field1": "Value1",
|
||||
"Field2": "Value1",
|
||||
|
||||
@@ -193,10 +193,9 @@ type CallDescriptor struct {
|
||||
// AsCGREvent converts the CallDescriptor into CGREvent
|
||||
func (cd *CallDescriptor) AsCGREvent() *utils.CGREvent {
|
||||
cgrEv := &utils.CGREvent{
|
||||
Tenant: cd.Tenant,
|
||||
ID: utils.UUIDSha1Prefix(), // make it unique
|
||||
Context: utils.StringPointer(utils.MetaRating),
|
||||
Event: make(map[string]interface{}),
|
||||
Tenant: cd.Tenant,
|
||||
ID: utils.UUIDSha1Prefix(), // make it unique
|
||||
Event: make(map[string]interface{}),
|
||||
}
|
||||
for k, v := range cd.ExtraFields {
|
||||
cgrEv.Event[k] = v
|
||||
|
||||
@@ -1847,11 +1847,9 @@ func TestCDDebitBalanceSubjectWithFallback(t *testing.T) {
|
||||
}
|
||||
}
|
||||
func TestCallDescriptorUpdateFromCGREvent(t *testing.T) {
|
||||
context := "*rating"
|
||||
cgrEv := &utils.CGREvent{
|
||||
Tenant: "cgrates.org",
|
||||
ID: "Generated",
|
||||
Context: &context,
|
||||
Tenant: "cgrates.org",
|
||||
ID: "Generated",
|
||||
Event: map[string]interface{}{
|
||||
"Account": "acc1",
|
||||
"AnswerTime": time.Date(2015, 3, 23, 6, 0, 0, 0, time.UTC),
|
||||
@@ -1891,9 +1889,8 @@ func TestCallDescriptorUpdateFromCGREvent(t *testing.T) {
|
||||
}
|
||||
}
|
||||
cgrEv = &utils.CGREvent{
|
||||
Tenant: "cgrates.org",
|
||||
ID: "Generated",
|
||||
Context: &context,
|
||||
Tenant: "cgrates.org",
|
||||
ID: "Generated",
|
||||
Event: map[string]interface{}{
|
||||
"Account": "acc1",
|
||||
"AnswerTime": time.Date(2015, 3, 23, 6, 0, 0, 0, time.UTC),
|
||||
@@ -1926,10 +1923,8 @@ func TestCallDescriptorAsCGREvent(t *testing.T) {
|
||||
TimeEnd: time.Date(2015, 3, 23, 6, 30, 0, 0, time.UTC),
|
||||
MaxCostSoFar: 0,
|
||||
}
|
||||
context := "*rating"
|
||||
eCGREvent := &utils.CGREvent{Tenant: "cgrates.org",
|
||||
ID: "Generated",
|
||||
Context: &context,
|
||||
ID: "Generated",
|
||||
Event: map[string]interface{}{
|
||||
"Account": "max",
|
||||
"AnswerTime": time.Date(2015, 3, 23, 6, 0, 0, 0, time.UTC),
|
||||
|
||||
@@ -127,12 +127,11 @@ func (cS *ChargerService) processEvent(cgrEv *utils.CGREvent) (rply []*ChrgSProc
|
||||
if cS.attrS == nil {
|
||||
return nil, errors.New("no connection to AttributeS")
|
||||
}
|
||||
if clonedEv.Context == nil {
|
||||
clonedEv.Context = utils.StringPointer(utils.MetaChargers)
|
||||
}
|
||||
|
||||
var evReply AttrSProcessEventReply
|
||||
if err = cS.attrS.Call(utils.AttributeSv1ProcessEvent,
|
||||
&AttrArgsProcessEvent{cP.AttributeIDs, nil, *clonedEv},
|
||||
&AttrArgsProcessEvent{cP.AttributeIDs,
|
||||
utils.StringPointer(utils.MetaChargers), nil, *clonedEv},
|
||||
&evReply); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -66,9 +66,8 @@ var (
|
||||
}
|
||||
chargerEvents = []*utils.CGREvent{
|
||||
{
|
||||
Tenant: config.CgrConfig().GeneralCfg().DefaultTenant,
|
||||
ID: utils.GenUUID(),
|
||||
Context: utils.StringPointer(utils.MetaSessionS),
|
||||
Tenant: config.CgrConfig().GeneralCfg().DefaultTenant,
|
||||
ID: utils.GenUUID(),
|
||||
Event: map[string]interface{}{
|
||||
"Charger": "ChargerProfile1",
|
||||
utils.AnswerTime: time.Date(2014, 7, 14, 14, 30, 0, 0, time.UTC),
|
||||
@@ -77,18 +76,16 @@ var (
|
||||
},
|
||||
},
|
||||
{
|
||||
Tenant: config.CgrConfig().GeneralCfg().DefaultTenant,
|
||||
ID: utils.GenUUID(),
|
||||
Context: utils.StringPointer(utils.MetaSessionS),
|
||||
Tenant: config.CgrConfig().GeneralCfg().DefaultTenant,
|
||||
ID: utils.GenUUID(),
|
||||
Event: map[string]interface{}{
|
||||
"Charger": "ChargerProfile2",
|
||||
utils.AnswerTime: time.Date(2014, 7, 14, 14, 30, 0, 0, time.UTC),
|
||||
},
|
||||
},
|
||||
{
|
||||
Tenant: config.CgrConfig().GeneralCfg().DefaultTenant,
|
||||
ID: utils.GenUUID(),
|
||||
Context: utils.StringPointer(utils.MetaSessionS),
|
||||
Tenant: config.CgrConfig().GeneralCfg().DefaultTenant,
|
||||
ID: utils.GenUUID(),
|
||||
Event: map[string]interface{}{
|
||||
"Charger": "DistinctMatch",
|
||||
utils.AnswerTime: time.Date(2014, 7, 14, 14, 30, 0, 0, time.UTC),
|
||||
|
||||
@@ -456,10 +456,8 @@ func (spS *SupplierService) V1GetSuppliers(args *ArgsGetSuppliers, reply *Sorted
|
||||
return utils.NewErrMandatoryIeMissing("Event")
|
||||
}
|
||||
if spS.attributeS != nil {
|
||||
if args.CGREvent.Context == nil { // populate if not already in
|
||||
args.CGREvent.Context = utils.StringPointer(utils.MetaSuppliers)
|
||||
}
|
||||
attrArgs := &AttrArgsProcessEvent{
|
||||
Context: utils.StringPointer(utils.MetaSuppliers),
|
||||
CGREvent: args.CGREvent,
|
||||
}
|
||||
var rplyEv AttrSProcessEventReply
|
||||
|
||||
@@ -1584,10 +1584,8 @@ func (sS *SessionS) BiRPCv1AuthorizeEvent(clnt rpcclient.RpcClientConnection,
|
||||
if sS.attrS == nil {
|
||||
return utils.NewErrNotConnected(utils.AttributeS)
|
||||
}
|
||||
if args.CGREvent.Context == nil { // populate if not already in
|
||||
args.CGREvent.Context = utils.StringPointer(utils.MetaSessionS)
|
||||
}
|
||||
attrArgs := &engine.AttrArgsProcessEvent{
|
||||
Context: utils.StringPointer(utils.MetaSessionS),
|
||||
CGREvent: args.CGREvent,
|
||||
}
|
||||
var rplyEv engine.AttrSProcessEventReply
|
||||
@@ -1816,10 +1814,8 @@ func (sS *SessionS) BiRPCv1InitiateSession(clnt rpcclient.RpcClientConnection,
|
||||
if sS.attrS == nil {
|
||||
return utils.NewErrNotConnected(utils.AttributeS)
|
||||
}
|
||||
if args.CGREvent.Context == nil { // populate if not already in
|
||||
args.CGREvent.Context = utils.StringPointer(utils.MetaSessionS)
|
||||
}
|
||||
attrArgs := &engine.AttrArgsProcessEvent{
|
||||
Context: utils.StringPointer(utils.MetaSessionS),
|
||||
CGREvent: args.CGREvent,
|
||||
}
|
||||
var rplyEv engine.AttrSProcessEventReply
|
||||
@@ -2018,10 +2014,8 @@ func (sS *SessionS) BiRPCv1UpdateSession(clnt rpcclient.RpcClientConnection,
|
||||
if sS.attrS == nil {
|
||||
return utils.NewErrNotConnected(utils.AttributeS)
|
||||
}
|
||||
if args.CGREvent.Context == nil { // populate if not already in
|
||||
args.CGREvent.Context = utils.StringPointer(utils.MetaSessionS)
|
||||
}
|
||||
attrArgs := &engine.AttrArgsProcessEvent{
|
||||
Context: utils.StringPointer(utils.MetaSessionS),
|
||||
CGREvent: args.CGREvent,
|
||||
}
|
||||
var rplyEv engine.AttrSProcessEventReply
|
||||
@@ -2290,10 +2284,8 @@ func (sS *SessionS) BiRPCv1ProcessEvent(clnt rpcclient.RpcClientConnection,
|
||||
if sS.attrS == nil {
|
||||
return utils.NewErrNotConnected(utils.AttributeS)
|
||||
}
|
||||
if args.CGREvent.Context == nil { // populate if not already in
|
||||
args.CGREvent.Context = utils.StringPointer(utils.MetaSessionS)
|
||||
}
|
||||
attrArgs := &engine.AttrArgsProcessEvent{
|
||||
Context: utils.StringPointer(utils.MetaSessionS),
|
||||
CGREvent: args.CGREvent,
|
||||
}
|
||||
var rplyEv engine.AttrSProcessEventReply
|
||||
|
||||
@@ -32,9 +32,8 @@ var attrs = &engine.AttrSProcessEventReply{
|
||||
MatchedProfiles: []string{"ATTR_ACNT_1001"},
|
||||
AlteredFields: []string{"OfficeGroup"},
|
||||
CGREvent: &utils.CGREvent{
|
||||
Tenant: "cgrates.org",
|
||||
ID: "TestSSv1ItAuth",
|
||||
Context: utils.StringPointer(utils.MetaSessionS),
|
||||
Tenant: "cgrates.org",
|
||||
ID: "TestSSv1ItAuth",
|
||||
Event: map[string]interface{}{
|
||||
utils.CGRID: "5668666d6b8e44eb949042f25ce0796ec3592ff9",
|
||||
utils.Tenant: "cgrates.org",
|
||||
@@ -736,9 +735,8 @@ func TestSessionSRegisterAndUnregisterPSessions(t *testing.T) {
|
||||
|
||||
func TestSessionSNewV1AuthorizeArgs(t *testing.T) {
|
||||
cgrEv := utils.CGREvent{
|
||||
Tenant: "cgrates.org",
|
||||
ID: "Event",
|
||||
Context: utils.StringPointer(utils.MetaSessionS),
|
||||
Tenant: "cgrates.org",
|
||||
ID: "Event",
|
||||
Event: map[string]interface{}{
|
||||
utils.Account: "1001",
|
||||
utils.Destination: "1002",
|
||||
@@ -772,9 +770,8 @@ func TestSessionSNewV1AuthorizeArgs(t *testing.T) {
|
||||
|
||||
func TestSessionSNewV1UpdateSessionArgs(t *testing.T) {
|
||||
cgrEv := utils.CGREvent{
|
||||
Tenant: "cgrates.org",
|
||||
ID: "Event",
|
||||
Context: utils.StringPointer(utils.MetaSessionS),
|
||||
Tenant: "cgrates.org",
|
||||
ID: "Event",
|
||||
Event: map[string]interface{}{
|
||||
utils.Account: "1001",
|
||||
utils.Destination: "1002",
|
||||
@@ -802,9 +799,8 @@ func TestSessionSNewV1UpdateSessionArgs(t *testing.T) {
|
||||
|
||||
func TestSessionSNewV1TerminateSessionArgs(t *testing.T) {
|
||||
cgrEv := utils.CGREvent{
|
||||
Tenant: "cgrates.org",
|
||||
ID: "Event",
|
||||
Context: utils.StringPointer(utils.MetaSessionS),
|
||||
Tenant: "cgrates.org",
|
||||
ID: "Event",
|
||||
Event: map[string]interface{}{
|
||||
utils.Account: "1001",
|
||||
utils.Destination: "1002",
|
||||
@@ -830,9 +826,8 @@ func TestSessionSNewV1TerminateSessionArgs(t *testing.T) {
|
||||
|
||||
func TestSessionSNewV1ProcessEventArgs(t *testing.T) {
|
||||
cgrEv := utils.CGREvent{
|
||||
Tenant: "cgrates.org",
|
||||
ID: "Event",
|
||||
Context: utils.StringPointer(utils.MetaSessionS),
|
||||
Tenant: "cgrates.org",
|
||||
ID: "Event",
|
||||
Event: map[string]interface{}{
|
||||
utils.Account: "1001",
|
||||
utils.Destination: "1002",
|
||||
@@ -861,9 +856,8 @@ func TestSessionSNewV1ProcessEventArgs(t *testing.T) {
|
||||
|
||||
func TestSessionSNewV1InitSessionArgs(t *testing.T) {
|
||||
cgrEv := utils.CGREvent{
|
||||
Tenant: "cgrates.org",
|
||||
ID: "Event",
|
||||
Context: utils.StringPointer(utils.MetaSessionS),
|
||||
Tenant: "cgrates.org",
|
||||
ID: "Event",
|
||||
Event: map[string]interface{}{
|
||||
utils.Account: "1001",
|
||||
utils.Destination: "1002",
|
||||
|
||||
@@ -27,11 +27,10 @@ import (
|
||||
|
||||
// CGREvent is a generic event processed by CGR services
|
||||
type CGREvent struct {
|
||||
Tenant string
|
||||
ID string
|
||||
Context *string // attach the event to a context
|
||||
Time *time.Time // event time
|
||||
Event map[string]interface{}
|
||||
Tenant string
|
||||
ID string
|
||||
Time *time.Time // event time
|
||||
Event map[string]interface{}
|
||||
}
|
||||
|
||||
func (ev *CGREvent) HasField(fldName string) (has bool) {
|
||||
@@ -154,9 +153,6 @@ func (ev *CGREvent) Clone() (clned *CGREvent) {
|
||||
ID: ev.ID,
|
||||
Event: make(map[string]interface{}), // a bit forced but safe
|
||||
}
|
||||
if ev.Context != nil {
|
||||
clned.Context = StringPointer(*ev.Context)
|
||||
}
|
||||
if ev.Time != nil {
|
||||
clned.Time = TimePointer(*ev.Time)
|
||||
}
|
||||
|
||||
@@ -163,13 +163,11 @@ func TestCGREventFieldAsFloat64(t *testing.T) {
|
||||
}
|
||||
}
|
||||
func TestCGREventClone(t *testing.T) {
|
||||
contest := "cntxt"
|
||||
now := time.Now()
|
||||
ev := &CGREvent{
|
||||
Tenant: "cgrates.org",
|
||||
ID: "supplierEvent1",
|
||||
Context: &contest,
|
||||
Time: &now,
|
||||
Tenant: "cgrates.org",
|
||||
ID: "supplierEvent1",
|
||||
Time: &now,
|
||||
Event: map[string]interface{}{
|
||||
AnswerTime: time.Now(),
|
||||
"supplierprofile1": "Supplier",
|
||||
@@ -182,9 +180,6 @@ func TestCGREventClone(t *testing.T) {
|
||||
if !reflect.DeepEqual(ev, cloned) {
|
||||
t.Errorf("Expecting: %+v, received: %+v", ev, cloned)
|
||||
}
|
||||
if cloned.Context == ev.Context {
|
||||
t.Errorf("Expecting: different pointer but received: %+v", cloned.Context)
|
||||
}
|
||||
if cloned.Time == ev.Time {
|
||||
t.Errorf("Expecting: different pointer but received: %+v", cloned.Time)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user