From ec020563ae6968b151769be13a02a63a46419c5f Mon Sep 17 00:00:00 2001 From: Jason Song Date: Thu, 29 Dec 2022 16:05:00 +0800 Subject: [PATCH] refactor: mv modules/notification/actions to services/actions --- modules/notification/notification.go | 4 ---- services/actions/actions.go | 6 ++++++ .../actions/actions.go => services/actions/notifier.go | 0 .../helper.go => services/actions/notifier_helper.go | 3 +-- 4 files changed, 7 insertions(+), 6 deletions(-) rename modules/notification/actions/actions.go => services/actions/notifier.go (100%) rename modules/notification/actions/helper.go => services/actions/notifier_helper.go (97%) diff --git a/modules/notification/notification.go b/modules/notification/notification.go index cc90caf8c3..7ffe223561 100644 --- a/modules/notification/notification.go +++ b/modules/notification/notification.go @@ -12,7 +12,6 @@ import ( user_model "code.gitea.io/gitea/models/user" "code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/notification/action" - "code.gitea.io/gitea/modules/notification/actions" "code.gitea.io/gitea/modules/notification/base" "code.gitea.io/gitea/modules/notification/indexer" "code.gitea.io/gitea/modules/notification/mail" @@ -41,9 +40,6 @@ func NewContext() { RegisterNotifier(webhook.NewNotifier()) RegisterNotifier(action.NewNotifier()) RegisterNotifier(mirror.NewNotifier()) - if setting.Actions.Enabled { - RegisterNotifier(actions.NewNotifier()) - } } // NotifyNewWikiPage notifies creating new wiki pages to notifiers diff --git a/services/actions/actions.go b/services/actions/actions.go index c62d8608ce..51c9ef5ca1 100644 --- a/services/actions/actions.go +++ b/services/actions/actions.go @@ -16,13 +16,19 @@ import ( actions_module "code.gitea.io/gitea/modules/actions" "code.gitea.io/gitea/modules/graceful" "code.gitea.io/gitea/modules/log" + "code.gitea.io/gitea/modules/notification" "code.gitea.io/gitea/modules/queue" + "code.gitea.io/gitea/modules/setting" api "code.gitea.io/gitea/modules/structs" ) func Init() { jobEmitterQueue = queue.CreateUniqueQueue("actions_ready_job", jobEmitterQueueHandle, new(jobUpdate)) go graceful.GetManager().RunWithShutdownFns(jobEmitterQueue.Run) + + if setting.Actions.Enabled { + notification.RegisterNotifier(NewNotifier()) + } } func DeleteResourceOfRepository(ctx context.Context, repo *repo_model.Repository) error { diff --git a/modules/notification/actions/actions.go b/services/actions/notifier.go similarity index 100% rename from modules/notification/actions/actions.go rename to services/actions/notifier.go diff --git a/modules/notification/actions/helper.go b/services/actions/notifier_helper.go similarity index 97% rename from modules/notification/actions/helper.go rename to services/actions/notifier_helper.go index 331216d38b..9caedbba33 100644 --- a/modules/notification/actions/helper.go +++ b/services/actions/notifier_helper.go @@ -23,7 +23,6 @@ import ( "code.gitea.io/gitea/modules/log" api "code.gitea.io/gitea/modules/structs" "code.gitea.io/gitea/modules/util" - actions_service "code.gitea.io/gitea/services/actions" "code.gitea.io/gitea/services/convert" "github.com/nektos/act/pkg/jobparser" @@ -161,7 +160,7 @@ func notify(ctx context.Context, input *notifyInput) error { log.Error("FindRunJobs: %v", err) } else { for _, job := range jobs { - if err := actions_service.CreateCommitStatus(ctx, job); err != nil { + if err := CreateCommitStatus(ctx, job); err != nil { log.Error("CreateCommitStatus: %v", err) } }