Move feed notification service layer (#26908)

Extract from #22266
mj-develop
Lunny Xiao 8 months ago committed by GitHub
parent 65588b732c
commit f064d716c3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -12,7 +12,6 @@ import (
user_model "code.gitea.io/gitea/models/user"
"code.gitea.io/gitea/modules/git"
"code.gitea.io/gitea/modules/log"
"code.gitea.io/gitea/modules/notification/action"
"code.gitea.io/gitea/modules/notification/base"
"code.gitea.io/gitea/modules/repository"
)
@ -25,11 +24,6 @@ func RegisterNotifier(notifier base.Notifier) {
notifiers = append(notifiers, notifier)
}
// NewContext registers notification handlers
func NewContext() {
RegisterNotifier(action.NewNotifier())
}
// NotifyNewWikiPage notifies creating new wiki pages to notifiers
func NotifyNewWikiPage(ctx context.Context, doer *user_model.User, repo *repo_model.Repository, page, comment string) {
for _, notifier := range notifiers {

@ -18,7 +18,6 @@ import (
"code.gitea.io/gitea/modules/log"
"code.gitea.io/gitea/modules/markup"
"code.gitea.io/gitea/modules/markup/external"
"code.gitea.io/gitea/modules/notification"
"code.gitea.io/gitea/modules/setting"
"code.gitea.io/gitea/modules/ssh"
"code.gitea.io/gitea/modules/storage"
@ -38,6 +37,7 @@ import (
"code.gitea.io/gitea/services/auth/source/oauth2"
"code.gitea.io/gitea/services/automerge"
"code.gitea.io/gitea/services/cron"
feed_service "code.gitea.io/gitea/services/feed"
indexer_service "code.gitea.io/gitea/services/indexer"
"code.gitea.io/gitea/services/mailer"
mailer_incoming "code.gitea.io/gitea/services/mailer/incoming"
@ -119,7 +119,7 @@ func InitWebInstalled(ctx context.Context) {
mailer.NewContext(ctx)
mustInit(cache.NewContext)
notification.NewContext()
mustInit(feed_service.Init)
mustInit(uinotification.Init)
mustInit(archiver.Init)

@ -1,7 +1,7 @@
// Copyright 2019 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
package action
package feed
import (
"context"
@ -16,6 +16,7 @@ import (
"code.gitea.io/gitea/modules/git"
"code.gitea.io/gitea/modules/json"
"code.gitea.io/gitea/modules/log"
"code.gitea.io/gitea/modules/notification"
"code.gitea.io/gitea/modules/notification/base"
"code.gitea.io/gitea/modules/repository"
"code.gitea.io/gitea/modules/util"
@ -27,6 +28,12 @@ type actionNotifier struct {
var _ base.Notifier = &actionNotifier{}
func Init() error {
notification.RegisterNotifier(NewNotifier())
return nil
}
// NewNotifier create a new actionNotifier notifier
func NewNotifier() base.Notifier {
return &actionNotifier{}

@ -1,7 +1,7 @@
// Copyright 2019 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
package action
package feed
import (
"path/filepath"
@ -19,7 +19,7 @@ import (
func TestMain(m *testing.M) {
unittest.MainTest(m, &unittest.TestOptions{
GiteaRootPath: filepath.Join("..", "..", ".."),
GiteaRootPath: filepath.Join("..", ".."),
})
}

@ -15,8 +15,8 @@ import (
"code.gitea.io/gitea/models/unittest"
user_model "code.gitea.io/gitea/models/user"
"code.gitea.io/gitea/modules/notification"
"code.gitea.io/gitea/modules/notification/action"
"code.gitea.io/gitea/modules/util"
"code.gitea.io/gitea/services/feed"
"github.com/stretchr/testify/assert"
)
@ -25,7 +25,7 @@ var notifySync sync.Once
func registerNotifier() {
notifySync.Do(func() {
notification.RegisterNotifier(action.NewNotifier())
notification.RegisterNotifier(feed.NewNotifier())
})
}

Loading…
Cancel
Save