mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 18:16:24 +05:00
SessionS to rewrite the tenant via AttributeS
This commit is contained in:
@@ -1592,6 +1592,11 @@ func (sS *SessionS) BiRPCv1AuthorizeEvent(clnt rpcclient.RpcClientConnection,
|
||||
if err := sS.attrS.Call(utils.AttributeSv1ProcessEvent,
|
||||
attrArgs, &rplyEv); err == nil {
|
||||
args.CGREvent = *rplyEv.CGREvent
|
||||
if tntIface, has := args.CGREvent.Event[utils.MetaTenant]; has {
|
||||
// special case when we want to overwrite the tenant
|
||||
args.CGREvent.Tenant = tntIface.(string)
|
||||
delete(args.CGREvent.Event, utils.MetaTenant)
|
||||
}
|
||||
authReply.Attributes = &rplyEv
|
||||
} else if err.Error() != utils.ErrNotFound.Error() {
|
||||
return utils.NewErrAttributeS(err)
|
||||
@@ -1822,6 +1827,11 @@ func (sS *SessionS) BiRPCv1InitiateSession(clnt rpcclient.RpcClientConnection,
|
||||
if err := sS.attrS.Call(utils.AttributeSv1ProcessEvent,
|
||||
attrArgs, &rplyEv); err == nil {
|
||||
args.CGREvent = *rplyEv.CGREvent
|
||||
if tntIface, has := args.CGREvent.Event[utils.MetaTenant]; has {
|
||||
// special case when we want to overwrite the tenant
|
||||
args.CGREvent.Tenant = tntIface.(string)
|
||||
delete(args.CGREvent.Event, utils.MetaTenant)
|
||||
}
|
||||
rply.Attributes = &rplyEv
|
||||
} else if err.Error() != utils.ErrNotFound.Error() {
|
||||
return utils.NewErrAttributeS(err)
|
||||
@@ -2022,6 +2032,11 @@ func (sS *SessionS) BiRPCv1UpdateSession(clnt rpcclient.RpcClientConnection,
|
||||
if err := sS.attrS.Call(utils.AttributeSv1ProcessEvent,
|
||||
attrArgs, &rplyEv); err == nil {
|
||||
args.CGREvent = *rplyEv.CGREvent
|
||||
if tntIface, has := args.CGREvent.Event[utils.MetaTenant]; has {
|
||||
// special case when we want to overwrite the tenant
|
||||
args.CGREvent.Tenant = tntIface.(string)
|
||||
delete(args.CGREvent.Event, utils.MetaTenant)
|
||||
}
|
||||
rply.Attributes = &rplyEv
|
||||
} else if err.Error() != utils.ErrNotFound.Error() {
|
||||
return utils.NewErrAttributeS(err)
|
||||
@@ -2292,6 +2307,11 @@ func (sS *SessionS) BiRPCv1ProcessEvent(clnt rpcclient.RpcClientConnection,
|
||||
if err := sS.attrS.Call(utils.AttributeSv1ProcessEvent,
|
||||
attrArgs, &rplyEv); err == nil {
|
||||
args.CGREvent = *rplyEv.CGREvent
|
||||
if tntIface, has := args.CGREvent.Event[utils.MetaTenant]; has {
|
||||
// special case when we want to overwrite the tenant
|
||||
args.CGREvent.Tenant = tntIface.(string)
|
||||
delete(args.CGREvent.Event, utils.MetaTenant)
|
||||
}
|
||||
rply.Attributes = &rplyEv
|
||||
} else if err.Error() != utils.ErrNotFound.Error() {
|
||||
return utils.NewErrAttributeS(err)
|
||||
|
||||
@@ -22,6 +22,7 @@ import (
|
||||
"fmt"
|
||||
"reflect"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
@@ -161,3 +162,12 @@ func (ev *CGREvent) Clone() (clned *CGREvent) {
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// RemFldsWithPrefix will remove fields starting with prefix from event
|
||||
func (ev *CGREvent) RemFldsWithPrefix(prfx string) {
|
||||
for fldName := range ev.Event {
|
||||
if strings.HasPrefix(fldName, prfx) {
|
||||
delete(ev.Event, fldName)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -550,6 +550,7 @@ const (
|
||||
CGRDebitInterval = "CGRDebitInterval"
|
||||
MetaAsr = "*asr"
|
||||
Version = "Version"
|
||||
MetaTenant = "*tenant"
|
||||
)
|
||||
|
||||
// Migrator Action
|
||||
|
||||
Reference in New Issue
Block a user