mirror of
https://github.com/openziti/zrok.git
synced 2024-11-26 01:54:09 +01:00
fix for panic occurring with missing email configuration for account/environment/share warnings (#296)
This commit is contained in:
parent
c9d4c97de6
commit
148281cb48
@ -23,6 +23,7 @@ func newAccountWarningAction(cfg *emailUi.Config, str *store.Store, edge *rest_m
|
|||||||
func (a *accountWarningAction) HandleAccount(acct *store.Account, rxBytes, txBytes int64, limit *BandwidthPerPeriod, trx *sqlx.Tx) error {
|
func (a *accountWarningAction) HandleAccount(acct *store.Account, rxBytes, txBytes int64, limit *BandwidthPerPeriod, trx *sqlx.Tx) error {
|
||||||
logrus.Infof("warning '%v'", acct.Email)
|
logrus.Infof("warning '%v'", acct.Email)
|
||||||
|
|
||||||
|
if a.cfg != nil {
|
||||||
rxLimit := "(unlimited bytes)"
|
rxLimit := "(unlimited bytes)"
|
||||||
if limit.Limit.Rx != Unlimited {
|
if limit.Limit.Rx != Unlimited {
|
||||||
rxLimit = util.BytesToSize(limit.Limit.Rx)
|
rxLimit = util.BytesToSize(limit.Limit.Rx)
|
||||||
@ -44,6 +45,9 @@ func (a *accountWarningAction) HandleAccount(acct *store.Account, rxBytes, txByt
|
|||||||
if err := sendLimitWarningEmail(a.cfg, acct.Email, detail); err != nil {
|
if err := sendLimitWarningEmail(a.cfg, acct.Email, detail); err != nil {
|
||||||
return errors.Wrapf(err, "error sending limit warning email to '%v'", acct.Email)
|
return errors.Wrapf(err, "error sending limit warning email to '%v'", acct.Email)
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
logrus.Warnf("skipping warning email for account limit; no email configuration specified")
|
||||||
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -23,6 +23,7 @@ func newEnvironmentWarningAction(cfg *emailUi.Config, str *store.Store, edge *re
|
|||||||
func (a *environmentWarningAction) HandleEnvironment(env *store.Environment, rxBytes, txBytes int64, limit *BandwidthPerPeriod, trx *sqlx.Tx) error {
|
func (a *environmentWarningAction) HandleEnvironment(env *store.Environment, rxBytes, txBytes int64, limit *BandwidthPerPeriod, trx *sqlx.Tx) error {
|
||||||
logrus.Infof("warning '%v'", env.ZId)
|
logrus.Infof("warning '%v'", env.ZId)
|
||||||
|
|
||||||
|
if a.cfg != nil {
|
||||||
if env.AccountId != nil {
|
if env.AccountId != nil {
|
||||||
acct, err := a.str.GetAccount(*env.AccountId, trx)
|
acct, err := a.str.GetAccount(*env.AccountId, trx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -51,6 +52,9 @@ func (a *environmentWarningAction) HandleEnvironment(env *store.Environment, rxB
|
|||||||
return errors.Wrapf(err, "error sending limit warning email to '%v'", acct.Email)
|
return errors.Wrapf(err, "error sending limit warning email to '%v'", acct.Email)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
logrus.Warnf("skipping warning email for environment limit; no email configuration specified")
|
||||||
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -23,6 +23,7 @@ func newShareWarningAction(cfg *emailUi.Config, str *store.Store, edge *rest_man
|
|||||||
func (a *shareWarningAction) HandleShare(shr *store.Share, rxBytes, txBytes int64, limit *BandwidthPerPeriod, trx *sqlx.Tx) error {
|
func (a *shareWarningAction) HandleShare(shr *store.Share, rxBytes, txBytes int64, limit *BandwidthPerPeriod, trx *sqlx.Tx) error {
|
||||||
logrus.Infof("warning '%v'", shr.Token)
|
logrus.Infof("warning '%v'", shr.Token)
|
||||||
|
|
||||||
|
if a.cfg != nil {
|
||||||
env, err := a.str.GetEnvironment(shr.EnvironmentId, trx)
|
env, err := a.str.GetEnvironment(shr.EnvironmentId, trx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@ -56,6 +57,9 @@ func (a *shareWarningAction) HandleShare(shr *store.Share, rxBytes, txBytes int6
|
|||||||
return errors.Wrapf(err, "error sending limit warning email to '%v'", acct.Email)
|
return errors.Wrapf(err, "error sending limit warning email to '%v'", acct.Email)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
logrus.Warnf("skipping warning email for share limit; no email configuration specified")
|
||||||
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user