diff --git a/accounts/accounts.go b/accounts/accounts.go index 2a6c9ebc8..071cd4632 100644 --- a/accounts/accounts.go +++ b/accounts/accounts.go @@ -110,14 +110,9 @@ func (aS *AccountS) matchingAccountForEvent(tnt string, cgrEv *utils.CGREvent, } return } - if _, isDisabled := qAcnt.Opts[utils.Disabled]; isDisabled { - if lked { - guardian.Guardian.UnguardIDs(refID) - } - continue - } - if qAcnt.ActivationInterval != nil && cgrEv.Time != nil && - !qAcnt.ActivationInterval.IsActiveAtTime(*cgrEv.Time) { // not active + if _, isDisabled := qAcnt.Opts[utils.Disabled]; isDisabled || + (qAcnt.ActivationInterval != nil && cgrEv.Time != nil && + !qAcnt.ActivationInterval.IsActiveAtTime(*cgrEv.Time)) { // not active if lked { guardian.Guardian.UnguardIDs(refID) } @@ -138,6 +133,9 @@ func (aS *AccountS) matchingAccountForEvent(tnt string, cgrEv *utils.CGREvent, if acnt == nil || acnt.Weight < qAcnt.Weight { acnt = qAcnt if lked { + if lkID != utils.EmptyString { + guardian.Guardian.UnguardIDs(lkID) + } lkID = refID } } else if lked { diff --git a/engine/storage_internal_datadb.go b/engine/storage_internal_datadb.go index 32e8b32b5..ceeb3d239 100644 --- a/engine/storage_internal_datadb.go +++ b/engine/storage_internal_datadb.go @@ -941,7 +941,7 @@ func (iDB *InternalDB) GetAccountProfileDrv(tenant, id string) (ap *utils.Accoun if !ok || x == nil { return nil, utils.ErrNotFound } - return x.(*utils.AccountProfile), nil + return x.(*utils.AccountProfile).Clone(), nil } func (iDB *InternalDB) SetAccountProfileDrv(ap *utils.AccountProfile) (err error) { diff --git a/utils/accountprofile.go b/utils/accountprofile.go index 19aa4e142..5088a78b7 100644 --- a/utils/accountprofile.go +++ b/utils/accountprofile.go @@ -139,6 +139,9 @@ func (aP *AccountProfile) Clone() (acnt *AccountProfile) { //Clone returns a clone of the ActivationInterval func (aI *ActivationInterval) Clone() *ActivationInterval { + if aI == nil { + return nil + } return &ActivationInterval{ ActivationTime: aI.ActivationTime, ExpiryTime: aI.ExpiryTime,