Skip to content

Commit

Permalink
Move feed notification service layer (#26908)
Browse files Browse the repository at this point in the history
Extract from #22266
  • Loading branch information
lunny committed Sep 5, 2023
1 parent 65588b7 commit f064d71
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 13 deletions.
6 changes: 0 additions & 6 deletions modules/notification/notification.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand All @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions routers/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
Expand Down Expand Up @@ -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)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright 2019 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT

package action
package feed

import (
"context"
Expand All @@ -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"
Expand All @@ -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{}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright 2019 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT

package action
package feed

import (
"path/filepath"
Expand All @@ -19,7 +19,7 @@ import (

func TestMain(m *testing.M) {
unittest.MainTest(m, &unittest.TestOptions{
GiteaRootPath: filepath.Join("..", "..", ".."),
GiteaRootPath: filepath.Join("..", ".."),
})
}

Expand Down
4 changes: 2 additions & 2 deletions services/repository/transfer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand All @@ -25,7 +25,7 @@ var notifySync sync.Once

func registerNotifier() {
notifySync.Do(func() {
notification.RegisterNotifier(action.NewNotifier())
notification.RegisterNotifier(feed.NewNotifier())
})
}

Expand Down

0 comments on commit f064d71

Please sign in to comment.