Skip to content

Commit

Permalink
default values
Browse files Browse the repository at this point in the history
  • Loading branch information
haileyok committed Nov 19, 2024
1 parent 23deea7 commit 40a55ce
Showing 1 changed file with 21 additions and 4 deletions.
25 changes: 21 additions & 4 deletions automod/engine/persisthelpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,12 @@ func (eng *Engine) circuitBreakReports(ctx context.Context, reports []ModReport)
if err != nil {
return nil, fmt.Errorf("checking report action quota: %w", err)
}
if c >= eng.Config.QuotaModReportDay {

quotaModReportDay := eng.Config.QuotaModReportDay
if quotaModReportDay == 0 {
quotaModReportDay = 10000
}
if c >= quotaModReportDay {
eng.Logger.Warn("CIRCUIT BREAKER: automod reports")
return []ModReport{}, nil
}
Expand All @@ -117,7 +122,11 @@ func (eng *Engine) circuitBreakTakedown(ctx context.Context, takedown bool) (boo
if err != nil {
return false, fmt.Errorf("checking takedown action quota: %w", err)
}
if c >= eng.Config.QuotaModTakedownDay {
quotaModTakedownDay := eng.Config.QuotaModTakedownDay
if quotaModTakedownDay == 0 {
quotaModTakedownDay = 200
}
if c >= quotaModTakedownDay {
eng.Logger.Warn("CIRCUIT BREAKER: automod takedowns")
return false, nil
}
Expand All @@ -137,7 +146,11 @@ func (eng *Engine) circuitBreakModAction(ctx context.Context, action bool) (bool
if err != nil {
return false, fmt.Errorf("checking mod action quota: %w", err)
}
if c >= eng.Config.QuotaModActionDay {
quotaModActionDay := eng.Config.QuotaModActionDay
if quotaModActionDay == 0 {
quotaModActionDay = 2000
}
if c >= quotaModActionDay {
eng.Logger.Warn("CIRCUIT BREAKER: automod action")
return false, nil
}
Expand Down Expand Up @@ -191,7 +204,11 @@ func (eng *Engine) createReportIfFresh(ctx context.Context, xrpcc *xrpc.Client,
if err != nil {
return false, err
}
if time.Since(created.Time()) > eng.Config.ReportDupePeriod {
reportDupePeriod := eng.Config.ReportDupePeriod
if reportDupePeriod == 0 {
reportDupePeriod = 1 * 24 * time.Hour
}
if time.Since(created.Time()) > reportDupePeriod {
continue
}

Expand Down

0 comments on commit 40a55ce

Please sign in to comment.