summaryrefslogtreecommitdiffstats
path: root/services
diff options
context:
space:
mode:
authorPilou <pierre-louis@libregerbil.fr>2022-03-28 14:54:59 +0200
committerGitHub <noreply@github.com>2022-03-28 13:54:59 +0100
commit893c8938fc81166f386ff203f2129497ceddbc32 (patch)
treea4b0d79b4c4871932d344fa9c29a0aaa77139951 /services
parent6526733a58632086d51ce7211b3a4dc75dbbef90 (diff)
downloadgitea-893c8938fc81166f386ff203f2129497ceddbc32.tar.gz
gitea-893c8938fc81166f386ff203f2129497ceddbc32.zip
New cron task: delete old system notices (#19219)
Add a new cron task which deletes the old system notices.
Diffstat (limited to 'services')
-rw-r--r--services/cron/tasks_extended.go16
1 files changed, 16 insertions, 0 deletions
diff --git a/services/cron/tasks_extended.go b/services/cron/tasks_extended.go
index ded819a71e..2d1bf53234 100644
--- a/services/cron/tasks_extended.go
+++ b/services/cron/tasks_extended.go
@@ -9,6 +9,7 @@ import (
"time"
"code.gitea.io/gitea/models"
+ "code.gitea.io/gitea/models/admin"
asymkey_model "code.gitea.io/gitea/models/asymkey"
user_model "code.gitea.io/gitea/models/user"
"code.gitea.io/gitea/modules/setting"
@@ -154,6 +155,20 @@ func registerUpdateGiteaChecker() {
})
}
+func registerDeleteOldSystemNotices() {
+ RegisterTaskFatal("delete_old_system_notices", &OlderThanConfig{
+ BaseConfig: BaseConfig{
+ Enabled: false,
+ RunAtStart: false,
+ Schedule: "@every 168h",
+ },
+ OlderThan: 365 * 24 * time.Hour,
+ }, func(ctx context.Context, _ *user_model.User, config Config) error {
+ olderThanConfig := config.(*OlderThanConfig)
+ return admin.DeleteOldSystemNotices(olderThanConfig.OlderThan)
+ })
+}
+
func initExtendedTasks() {
registerDeleteInactiveUsers()
registerDeleteRepositoryArchives()
@@ -166,4 +181,5 @@ func initExtendedTasks() {
registerRemoveRandomAvatars()
registerDeleteOldActions()
registerUpdateGiteaChecker()
+ registerDeleteOldSystemNotices()
}