mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-21 23:28:44 +05:00
New Action: *publish_account to force publishing account information to ThresholdS, fixes #1059
This commit is contained in:
@@ -81,6 +81,7 @@ const (
|
||||
CGR_RPC = "*cgr_rpc"
|
||||
TopUpZeroNegative = "*topup_zero_negative"
|
||||
SetExpiry = "*set_expiry"
|
||||
MetaPublishAccount = "*publish_account"
|
||||
)
|
||||
|
||||
func (a *Action) Clone() *Action {
|
||||
@@ -119,6 +120,7 @@ func getActionFunc(typ string) (actionTypeFunc, bool) {
|
||||
CGR_RPC: cgrRPCAction,
|
||||
TopUpZeroNegative: topupZeroNegativeAction,
|
||||
SetExpiry: setExpiryAction,
|
||||
MetaPublishAccount: publishAccount,
|
||||
}
|
||||
f, exists := actionFuncMap[typ]
|
||||
return f, exists
|
||||
@@ -773,6 +775,24 @@ func setExpiryAction(account *Account, sq *CDRStatsQueueTriggered, a *Action, ac
|
||||
return nil
|
||||
}
|
||||
|
||||
// publishAccount will publish the account as well as each balance received to ThresholdS
|
||||
func publishAccount(acnt *Account, sq *CDRStatsQueueTriggered,
|
||||
a *Action, acs Actions) error {
|
||||
if acnt == nil {
|
||||
return errors.New("nil account")
|
||||
}
|
||||
acnt.Publish()
|
||||
for bType := range acnt.BalanceMap {
|
||||
for _, b := range acnt.BalanceMap[bType] {
|
||||
if b.account == nil {
|
||||
b.account = acnt
|
||||
}
|
||||
b.Publish()
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Structure to store actions according to weight
|
||||
type Actions []*Action
|
||||
|
||||
|
||||
Reference in New Issue
Block a user