diff options
author | KN4CK3R <admin@oldschoolhack.me> | 2021-11-18 18:42:27 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-11-19 01:42:27 +0800 |
commit | f34151bdb22c8160b0a6eafef20725ebae1768da (patch) | |
tree | 2abcc5845e4a9cf3769deb27ba5a3ecccd2ad8c9 /services/cron | |
parent | 55be5fe3399d18b7d2477519707aecf5f99f1de5 (diff) | |
download | gitea-f34151bdb22c8160b0a6eafef20725ebae1768da.tar.gz gitea-f34151bdb22c8160b0a6eafef20725ebae1768da.zip |
Move user/org deletion to services (#17673)
Diffstat (limited to 'services/cron')
-rw-r--r-- | services/cron/tasks.go | 6 | ||||
-rw-r--r-- | services/cron/tasks_extended.go | 3 |
2 files changed, 5 insertions, 4 deletions
diff --git a/services/cron/tasks.go b/services/cron/tasks.go index d29bf6d6bd..732eead930 100644 --- a/services/cron/tasks.go +++ b/services/cron/tasks.go @@ -90,18 +90,18 @@ func (t *Task) RunWithUser(doer *models.User, config Config) { if err := t.fun(ctx, doer, config); err != nil { if db.IsErrCancelled(err) { message := err.(db.ErrCancelled).Message - if err := admin_model.CreateNotice(admin_model.NoticeTask, config.FormatMessage(t.Name, "aborted", doer, message)); err != nil { + if err := admin_model.CreateNotice(ctx, admin_model.NoticeTask, config.FormatMessage(t.Name, "aborted", doer, message)); err != nil { log.Error("CreateNotice: %v", err) } return } - if err := admin_model.CreateNotice(admin_model.NoticeTask, config.FormatMessage(t.Name, "error", doer, err)); err != nil { + if err := admin_model.CreateNotice(ctx, admin_model.NoticeTask, config.FormatMessage(t.Name, "error", doer, err)); err != nil { log.Error("CreateNotice: %v", err) } return } if config.DoNoticeOnSuccess() { - if err := admin_model.CreateNotice(admin_model.NoticeTask, config.FormatMessage(t.Name, "finished", doer)); err != nil { + if err := admin_model.CreateNotice(ctx, admin_model.NoticeTask, config.FormatMessage(t.Name, "finished", doer)); err != nil { log.Error("CreateNotice: %v", err) } } diff --git a/services/cron/tasks_extended.go b/services/cron/tasks_extended.go index 1f115de43a..b0cb5ee921 100644 --- a/services/cron/tasks_extended.go +++ b/services/cron/tasks_extended.go @@ -13,6 +13,7 @@ import ( "code.gitea.io/gitea/modules/setting" "code.gitea.io/gitea/modules/updatechecker" repo_service "code.gitea.io/gitea/services/repository" + user_service "code.gitea.io/gitea/services/user" ) func registerDeleteInactiveUsers() { @@ -25,7 +26,7 @@ func registerDeleteInactiveUsers() { OlderThan: 0 * time.Second, }, func(ctx context.Context, _ *models.User, config Config) error { olderThanConfig := config.(*OlderThanConfig) - return models.DeleteInactiveUsers(ctx, olderThanConfig.OlderThan) + return user_service.DeleteInactiveUsers(ctx, olderThanConfig.OlderThan) }) } |