2025-05-18 08:05:16 +00:00
|
|
|
// Copyright 2025 The Forgejo Authors. All rights reserved.
|
|
|
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
|
|
|
|
package setting
|
|
|
|
|
2025-07-28 14:52:13 +02:00
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"time"
|
|
|
|
)
|
|
|
|
|
2025-05-18 08:05:16 +00:00
|
|
|
// Moderation settings
|
|
|
|
var Moderation = struct {
|
2025-07-28 14:52:13 +02:00
|
|
|
Enabled bool `ini:"ENABLED"`
|
|
|
|
KeepResolvedReportsFor time.Duration `ini:"KEEP_RESOLVED_REPORTS_FOR"`
|
2025-05-18 08:05:16 +00:00
|
|
|
}{
|
|
|
|
Enabled: false,
|
|
|
|
}
|
|
|
|
|
2025-07-28 14:52:13 +02:00
|
|
|
func loadModerationFrom(rootCfg ConfigProvider) error {
|
|
|
|
sec := rootCfg.Section("moderation")
|
|
|
|
err := sec.MapTo(&Moderation)
|
|
|
|
if err != nil {
|
|
|
|
return fmt.Errorf("failed to map Moderation settings: %v", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
// keep reports for one week by default. Since time.Duration stops at the unit of an hour
|
|
|
|
// we are using the value of 24 (hours) * 7 (days) which gives us the value of 168
|
|
|
|
Moderation.KeepResolvedReportsFor = sec.Key("KEEP_RESOLVED_REPORTS_FOR").MustDuration(168 * time.Hour)
|
|
|
|
return nil
|
2025-05-18 08:05:16 +00:00
|
|
|
}
|