Skip to content

Commit f064d71

Browse files
authored
Move feed notification service layer (#26908)
Extract from #22266
1 parent 65588b7 commit f064d71

File tree

5 files changed

+14
-13
lines changed

5 files changed

+14
-13
lines changed

modules/notification/notification.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import (
1212
user_model "code.gitea.io/gitea/models/user"
1313
"code.gitea.io/gitea/modules/git"
1414
"code.gitea.io/gitea/modules/log"
15-
"code.gitea.io/gitea/modules/notification/action"
1615
"code.gitea.io/gitea/modules/notification/base"
1716
"code.gitea.io/gitea/modules/repository"
1817
)
@@ -25,11 +24,6 @@ func RegisterNotifier(notifier base.Notifier) {
2524
notifiers = append(notifiers, notifier)
2625
}
2726

28-
// NewContext registers notification handlers
29-
func NewContext() {
30-
RegisterNotifier(action.NewNotifier())
31-
}
32-
3327
// NotifyNewWikiPage notifies creating new wiki pages to notifiers
3428
func NotifyNewWikiPage(ctx context.Context, doer *user_model.User, repo *repo_model.Repository, page, comment string) {
3529
for _, notifier := range notifiers {

routers/init.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ import (
1818
"code.gitea.io/gitea/modules/log"
1919
"code.gitea.io/gitea/modules/markup"
2020
"code.gitea.io/gitea/modules/markup/external"
21-
"code.gitea.io/gitea/modules/notification"
2221
"code.gitea.io/gitea/modules/setting"
2322
"code.gitea.io/gitea/modules/ssh"
2423
"code.gitea.io/gitea/modules/storage"
@@ -38,6 +37,7 @@ import (
3837
"code.gitea.io/gitea/services/auth/source/oauth2"
3938
"code.gitea.io/gitea/services/automerge"
4039
"code.gitea.io/gitea/services/cron"
40+
feed_service "code.gitea.io/gitea/services/feed"
4141
indexer_service "code.gitea.io/gitea/services/indexer"
4242
"code.gitea.io/gitea/services/mailer"
4343
mailer_incoming "code.gitea.io/gitea/services/mailer/incoming"
@@ -119,7 +119,7 @@ func InitWebInstalled(ctx context.Context) {
119119

120120
mailer.NewContext(ctx)
121121
mustInit(cache.NewContext)
122-
notification.NewContext()
122+
mustInit(feed_service.Init)
123123
mustInit(uinotification.Init)
124124
mustInit(archiver.Init)
125125

modules/notification/action/action.go renamed to services/feed/action.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Copyright 2019 The Gitea Authors. All rights reserved.
22
// SPDX-License-Identifier: MIT
33

4-
package action
4+
package feed
55

66
import (
77
"context"
@@ -16,6 +16,7 @@ import (
1616
"code.gitea.io/gitea/modules/git"
1717
"code.gitea.io/gitea/modules/json"
1818
"code.gitea.io/gitea/modules/log"
19+
"code.gitea.io/gitea/modules/notification"
1920
"code.gitea.io/gitea/modules/notification/base"
2021
"code.gitea.io/gitea/modules/repository"
2122
"code.gitea.io/gitea/modules/util"
@@ -27,6 +28,12 @@ type actionNotifier struct {
2728

2829
var _ base.Notifier = &actionNotifier{}
2930

31+
func Init() error {
32+
notification.RegisterNotifier(NewNotifier())
33+
34+
return nil
35+
}
36+
3037
// NewNotifier create a new actionNotifier notifier
3138
func NewNotifier() base.Notifier {
3239
return &actionNotifier{}

modules/notification/action/action_test.go renamed to services/feed/action_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Copyright 2019 The Gitea Authors. All rights reserved.
22
// SPDX-License-Identifier: MIT
33

4-
package action
4+
package feed
55

66
import (
77
"path/filepath"
@@ -19,7 +19,7 @@ import (
1919

2020
func TestMain(m *testing.M) {
2121
unittest.MainTest(m, &unittest.TestOptions{
22-
GiteaRootPath: filepath.Join("..", "..", ".."),
22+
GiteaRootPath: filepath.Join("..", ".."),
2323
})
2424
}
2525

services/repository/transfer_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ import (
1515
"code.gitea.io/gitea/models/unittest"
1616
user_model "code.gitea.io/gitea/models/user"
1717
"code.gitea.io/gitea/modules/notification"
18-
"code.gitea.io/gitea/modules/notification/action"
1918
"code.gitea.io/gitea/modules/util"
19+
"code.gitea.io/gitea/services/feed"
2020

2121
"github.com/stretchr/testify/assert"
2222
)
@@ -25,7 +25,7 @@ var notifySync sync.Once
2525

2626
func registerNotifier() {
2727
notifySync.Do(func() {
28-
notification.RegisterNotifier(action.NewNotifier())
28+
notification.RegisterNotifier(feed.NewNotifier())
2929
})
3030
}
3131

0 commit comments

Comments
 (0)