1
0
Fork 0
mirror of https://codeberg.org/forgejo/forgejo.git synced 2025-09-15 18:56:59 +00:00

Add timeout, rework moderation setting loading

Added a configurable timeout and reworked the way
we load moderation settings
This commit is contained in:
Leni Kadali 2025-05-03 17:28:36 +03:00
parent 1faab33da5
commit 7a124fb0ce
3 changed files with 23 additions and 4 deletions

View file

@ -1581,6 +1581,9 @@ LEVEL = Info
;; If enabled it will be possible for users to report abusive content (new actions are added in the UI and /report_abuse route will be enabled) and a new Moderation section will be added to Admin settings where the reports can be reviewed.
;ENABLED = false
;; Timeout for removing resolved reports
;REMOVE_RESOLVED_REPORTS_TIMEOUT = 0
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;[openid]

View file

@ -3,13 +3,26 @@
package setting
import (
"fmt"
"time"
)
// Moderation settings
var Moderation = struct {
Enabled bool `ini:"ENABLED"`
Enabled bool `ini:"ENABLED"`
RemoveResolvedReportsTimeout time.Duration `ini:"REMOVE_RESOLVED_REPORTS_TIMEOUT"`
}{
Enabled: false,
}
func loadModerationFrom(rootCfg ConfigProvider) {
mustMapSetting(rootCfg, "moderation", &Moderation)
func loadModerationFrom(rootCfg ConfigProvider) error {
sec := rootCfg.Section("actions")
err := sec.MapTo(&Moderation)
if err != nil {
return fmt.Errorf("failed to map Actions settings: %v", err)
}
Moderation.RemoveResolvedReportsTimeout = sec.Key("REMOVE_RESOLVED_REPORTS_TIMEOUT").MustDuration(10 * time.Minute)
return nil
}

View file

@ -140,6 +140,10 @@ func loadCommonSettingsFrom(cfg ConfigProvider) error {
if err := loadActionsFrom(cfg); err != nil {
return err
}
if err := loadModerationFrom(CfgProvider); err != nil {
return err
}
loadUIFrom(cfg)
loadAdminFrom(cfg)
loadAPIFrom(cfg)
@ -221,7 +225,6 @@ func LoadSettings() {
loadProjectFrom(CfgProvider)
loadMimeTypeMapFrom(CfgProvider)
loadF3From(CfgProvider)
loadModerationFrom(CfgProvider)
}
// LoadSettingsForInstall initializes the settings for install