warning graphic for limit email (#279); only run relax actions when reverting a limit not a warning (#276)

This commit is contained in:
Michael Quigley 2023-03-29 16:24:52 -04:00
parent d3be3195bf
commit 69990447c9
No known key found for this signature in database
GPG Key ID: 9B60314A9DD20A62
2 changed files with 19 additions and 13 deletions

View File

@ -132,7 +132,7 @@
<div class="container"> <div class="container">
<div class="banner" style="margin: auto;"> <div class="banner" style="margin: auto;">
<img src="https://zrok.io/wp-content/uploads/2023/01/reset.jpg" width="363px" height="500px" style="padding-bottom: 10px;"/> <img src="https://zrok.io/wp-content/uploads/2023/03/warning.jpg" width="363px" height="500px" style="padding-bottom: 10px;"/>
</div> </div>
<div class="cta" style="text-align: center;"> <div class="cta" style="text-align: center;">
<p style="text-align: center;">Your account is reaching a transfer limit, {{ .EmailAddress }}.</p> <p style="text-align: center;">Your account is reaching a transfer limit, {{ .EmailAddress }}.</p>

View File

@ -437,12 +437,14 @@ func (a *Agent) relax() error {
if slj.Action == store.WarningAction || slj.Action == store.LimitAction { if slj.Action == store.WarningAction || slj.Action == store.LimitAction {
if enforce, warning, rxBytes, txBytes, err := a.checkShareLimit(shr.Token); err == nil { if enforce, warning, rxBytes, txBytes, err := a.checkShareLimit(shr.Token); err == nil {
if !enforce && !warning { if !enforce && !warning {
if slj.Action == store.LimitAction {
// run relax actions for share // run relax actions for share
for _, action := range a.shrRelaxActions { for _, action := range a.shrRelaxActions {
if err := action.HandleShare(shr, rxBytes, txBytes, a.cfg.Bandwidth.PerShare, trx); err != nil { if err := action.HandleShare(shr, rxBytes, txBytes, a.cfg.Bandwidth.PerShare, trx); err != nil {
return errors.Wrapf(err, "%v", reflect.TypeOf(action).String()) return errors.Wrapf(err, "%v", reflect.TypeOf(action).String())
} }
} }
}
if err := a.str.DeleteShareLimitJournalForShare(shr.Id, trx); err == nil { if err := a.str.DeleteShareLimitJournalForShare(shr.Id, trx); err == nil {
commit = true commit = true
} else { } else {
@ -469,12 +471,14 @@ func (a *Agent) relax() error {
if elj.Action == store.WarningAction || elj.Action == store.LimitAction { if elj.Action == store.WarningAction || elj.Action == store.LimitAction {
if enforce, warning, rxBytes, txBytes, err := a.checkEnvironmentLimit(int64(elj.EnvironmentId)); err == nil { if enforce, warning, rxBytes, txBytes, err := a.checkEnvironmentLimit(int64(elj.EnvironmentId)); err == nil {
if !enforce && !warning { if !enforce && !warning {
if elj.Action == store.LimitAction {
// run relax actions for environment // run relax actions for environment
for _, action := range a.envRelaxActions { for _, action := range a.envRelaxActions {
if err := action.HandleEnvironment(env, rxBytes, txBytes, a.cfg.Bandwidth.PerEnvironment, trx); err != nil { if err := action.HandleEnvironment(env, rxBytes, txBytes, a.cfg.Bandwidth.PerEnvironment, trx); err != nil {
return errors.Wrapf(err, "%v", reflect.TypeOf(action).String()) return errors.Wrapf(err, "%v", reflect.TypeOf(action).String())
} }
} }
}
if err := a.str.DeleteEnvironmentLimitJournalForEnvironment(env.Id, trx); err == nil { if err := a.str.DeleteEnvironmentLimitJournalForEnvironment(env.Id, trx); err == nil {
commit = true commit = true
} else { } else {
@ -501,12 +505,14 @@ func (a *Agent) relax() error {
if alj.Action == store.WarningAction || alj.Action == store.LimitAction { if alj.Action == store.WarningAction || alj.Action == store.LimitAction {
if enforce, warning, rxBytes, txBytes, err := a.checkAccountLimit(int64(alj.AccountId)); err == nil { if enforce, warning, rxBytes, txBytes, err := a.checkAccountLimit(int64(alj.AccountId)); err == nil {
if !enforce && !warning { if !enforce && !warning {
if alj.Action == store.LimitAction {
// run relax actions for account // run relax actions for account
for _, action := range a.acctRelaxActions { for _, action := range a.acctRelaxActions {
if err := action.HandleAccount(acct, rxBytes, txBytes, a.cfg.Bandwidth.PerAccount, trx); err != nil { if err := action.HandleAccount(acct, rxBytes, txBytes, a.cfg.Bandwidth.PerAccount, trx); err != nil {
return errors.Wrapf(err, "%v", reflect.TypeOf(action).String()) return errors.Wrapf(err, "%v", reflect.TypeOf(action).String())
} }
} }
}
if err := a.str.DeleteAccountLimitJournalForAccount(acct.Id, trx); err == nil { if err := a.str.DeleteAccountLimitJournalForAccount(acct.Id, trx); err == nil {
commit = true commit = true
} else { } else {