return ACCOUNT_DISABLED error from debit functions

This commit is contained in:
Radu Ioan Fericean
2016-03-17 10:17:42 +01:00
parent c39d114bd7
commit 148e283ad6
2 changed files with 10 additions and 0 deletions

View File

@@ -639,6 +639,9 @@ func (cd *CallDescriptor) GetMaxSessionDuration() (duration time.Duration, err e
utils.Logger.Err(fmt.Sprintf("Account: %s, not found", cd.GetAccountKey()))
return 0, utils.ErrAccountNotFound
} else {
if account.Disabled {
return 0, utils.ErrAccountDisabled
}
if memberIds, err := account.GetUniqueSharedGroupMembers(cd); err == nil {
if _, err := Guardian.Guard(func() (interface{}, error) {
duration, err = cd.getMaxSessionDuration(account)
@@ -706,6 +709,9 @@ func (cd *CallDescriptor) Debit() (cc *CallCost, err error) {
utils.Logger.Err(fmt.Sprintf("Account: %s, not found", cd.GetAccountKey()))
return nil, utils.ErrAccountNotFound
} else {
if account.Disabled {
return nil, utils.ErrAccountDisabled
}
if memberIds, sgerr := account.GetUniqueSharedGroupMembers(cd); sgerr == nil {
_, err = Guardian.Guard(func() (interface{}, error) {
cc, err = cd.debit(account, cd.DryRun, true)
@@ -728,6 +734,9 @@ func (cd *CallDescriptor) MaxDebit() (cc *CallCost, err error) {
utils.Logger.Err(fmt.Sprintf("Account: %s, not found", cd.GetAccountKey()))
return nil, utils.ErrAccountNotFound
} else {
if account.Disabled {
return nil, utils.ErrAccountDisabled
}
//log.Printf("ACC: %+v", account)
if memberIDs, err := account.GetUniqueSharedGroupMembers(cd); err == nil {
_, err = Guardian.Guard(func() (interface{}, error) {

View File

@@ -28,6 +28,7 @@ var (
ErrUnauthorizedDestination = errors.New("UNAUTHORIZED_DESTINATION")
ErrRatingPlanNotFound = errors.New("RATING_PLAN_NOT_FOUND")
ErrAccountNotFound = errors.New("ACCOUNT_NOT_FOUND")
ErrAccountDisabled = errors.New("ACCOUNT_DISABLED")
ErrUserNotFound = errors.New("USER_NOT_FOUND")
ErrInsufficientCredit = errors.New("INSUFFICENT_CREDIT")
)