This commit is contained in:
DanB
2015-11-26 12:28:53 +01:00
3 changed files with 11 additions and 10 deletions

View File

@@ -196,7 +196,7 @@ func (cd *CallDescriptor) LoadRatingPlans() (err error) {
}
//load the rating plans
if err != nil || !cd.continousRatingInfos() {
//log.Print("ERR: ", cd.GetKey(cd.Subject), err)
utils.Logger.Err(fmt.Sprintf("Destination %s not authorized for account: %s, subject: %s", cd.Destination, cd.GetAccountKey(), cd.GetKey(cd.Subject)))
err = utils.ErrUnauthorizedDestination
}
return
@@ -496,7 +496,7 @@ func (cd *CallDescriptor) getCost() (*CallCost, error) {
}
err := cd.LoadRatingPlans()
if err != nil {
utils.Logger.Err(fmt.Sprintf("error getting cost for key <%s>: %s", cd.GetKey(cd.Subject), err.Error()))
//utils.Logger.Err(fmt.Sprintf("error getting cost for key <%s>: %s", cd.GetKey(cd.Subject), err.Error()))
return &CallCost{Cost: -1}, err
}
timespans := cd.splitInTimeSpans()
@@ -616,8 +616,8 @@ func (origCD *CallDescriptor) getMaxSessionDuration(origAcc *Account) (time.Dura
func (cd *CallDescriptor) GetMaxSessionDuration() (duration time.Duration, err error) {
cd.account = nil // make sure it's not cached
if account, err := cd.getAccount(); err != nil || account == nil {
utils.Logger.Err(fmt.Sprintf("Could not get account for <%s>: %s.", cd.GetAccountKey(), err.Error()))
return 0, err
utils.Logger.Err(fmt.Sprintf("Account: %s, not found", cd.GetAccountKey()))
return 0, utils.ErrAccountNotFound
} else {
if memberIds, err := account.GetUniqueSharedGroupMembers(cd); err == nil {
if _, err := Guardian.Guard(func() (interface{}, error) {
@@ -673,11 +673,11 @@ func (cd *CallDescriptor) Debit() (cc *CallCost, err error) {
cd.account = nil // make sure it's not cached
// lock all group members
if account, err := cd.getAccount(); err != nil || account == nil {
utils.Logger.Err(fmt.Sprintf("Could not get user balance for <%s>: %s.", cd.GetAccountKey(), err.Error()))
return nil, err
utils.Logger.Err(fmt.Sprintf("Account: %s, not found", cd.GetAccountKey()))
return nil, utils.ErrAccountNotFound
} else {
if memberIds, err := account.GetUniqueSharedGroupMembers(cd); err == nil {
Guardian.Guard(func() (interface{}, error) {
_, err = Guardian.Guard(func() (interface{}, error) {
cc, err = cd.debit(account, false, true)
return 0, err
}, 0, memberIds...)
@@ -695,8 +695,8 @@ func (cd *CallDescriptor) Debit() (cc *CallCost, err error) {
func (cd *CallDescriptor) MaxDebit() (cc *CallCost, err error) {
cd.account = nil // make sure it's not cached
if account, err := cd.getAccount(); err != nil || account == nil {
utils.Logger.Err(fmt.Sprintf("Could not get user balance for <%s>: %s.", cd.GetAccountKey(), err.Error()))
return nil, utils.ErrUnauthorizedDestination
utils.Logger.Err(fmt.Sprintf("Account: %s, not found", cd.GetAccountKey()))
return nil, utils.ErrAccountNotFound
} else {
//log.Printf("ACC: %+v", account)
if memberIds, err := account.GetUniqueSharedGroupMembers(cd); err == nil {

View File

@@ -97,7 +97,7 @@ func TestAuthPostpaidNoAcnt(t *testing.T) {
Category: "call", Account: "nonexistent", Subject: "testauthpostpaid1",
Destination: "4986517174963", SetupTime: time.Date(2015, 8, 27, 11, 26, 0, 0, time.UTC)}
var maxSessionTime float64
if err := rsponder.GetDerivedMaxSessionTime(cdr, &maxSessionTime); err == nil || err != utils.ErrNotFound {
if err := rsponder.GetDerivedMaxSessionTime(cdr, &maxSessionTime); err == nil || err != utils.ErrAccountNotFound {
t.Error(err)
}
}

View File

@@ -26,6 +26,7 @@ var (
ErrInvalidPath = errors.New("INVALID_PATH")
ErrInvalidKey = errors.New("INVALID_KEY")
ErrUnauthorizedDestination = errors.New("UNAUTHORIZED_DESTINATION")
ErrAccountNotFound = errors.New("AccountNotFound")
)
const (