diff options
author | Lunny Xiao <xiaolunwen@gmail.com> | 2023-09-06 02:37:47 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-09-05 18:37:47 +0000 |
commit | 540bf9fa6d0d86297c9d575640798b718767bd9f (patch) | |
tree | 4b4a782b71e6f066af6c7807337745dc5ee6899a /services/indexer | |
parent | 084eacb5d42f1ed2520442a4bbc91bb70c9759e1 (diff) | |
download | gitea-540bf9fa6d0d86297c9d575640798b718767bd9f.tar.gz gitea-540bf9fa6d0d86297c9d575640798b718767bd9f.zip |
Move notification interface to services layer (#26915)
Extract from #22266
Diffstat (limited to 'services/indexer')
-rw-r--r-- | services/indexer/indexer.go | 4 | ||||
-rw-r--r-- | services/indexer/notify.go | 36 |
2 files changed, 20 insertions, 20 deletions
diff --git a/services/indexer/indexer.go b/services/indexer/indexer.go index d5f31d99ea..38dd012a51 100644 --- a/services/indexer/indexer.go +++ b/services/indexer/indexer.go @@ -7,12 +7,12 @@ import ( code_indexer "code.gitea.io/gitea/modules/indexer/code" issue_indexer "code.gitea.io/gitea/modules/indexer/issues" stats_indexer "code.gitea.io/gitea/modules/indexer/stats" - "code.gitea.io/gitea/modules/notification" + notify_service "code.gitea.io/gitea/services/notify" ) // Init initialize the repo indexer func Init() error { - notification.RegisterNotifier(NewNotifier()) + notify_service.RegisterNotifier(NewNotifier()) issue_indexer.InitIssueIndexer(false) code_indexer.Init() diff --git a/services/indexer/notify.go b/services/indexer/notify.go index a18c66edb5..22306c691b 100644 --- a/services/indexer/notify.go +++ b/services/indexer/notify.go @@ -13,37 +13,37 @@ import ( issue_indexer "code.gitea.io/gitea/modules/indexer/issues" stats_indexer "code.gitea.io/gitea/modules/indexer/stats" "code.gitea.io/gitea/modules/log" - "code.gitea.io/gitea/modules/notification/base" "code.gitea.io/gitea/modules/repository" "code.gitea.io/gitea/modules/setting" + notify_service "code.gitea.io/gitea/services/notify" ) type indexerNotifier struct { - base.NullNotifier + notify_service.NullNotifier } -var _ base.Notifier = &indexerNotifier{} +var _ notify_service.Notifier = &indexerNotifier{} // NewNotifier create a new indexerNotifier notifier -func NewNotifier() base.Notifier { +func NewNotifier() notify_service.Notifier { return &indexerNotifier{} } -func (r *indexerNotifier) NotifyAdoptRepository(ctx context.Context, doer, u *user_model.User, repo *repo_model.Repository) { - r.NotifyMigrateRepository(ctx, doer, u, repo) +func (r *indexerNotifier) AdoptRepository(ctx context.Context, doer, u *user_model.User, repo *repo_model.Repository) { + r.MigrateRepository(ctx, doer, u, repo) } -func (r *indexerNotifier) NotifyCreateIssueComment(ctx context.Context, doer *user_model.User, repo *repo_model.Repository, +func (r *indexerNotifier) CreateIssueComment(ctx context.Context, doer *user_model.User, repo *repo_model.Repository, issue *issues_model.Issue, comment *issues_model.Comment, mentions []*user_model.User, ) { issue_indexer.UpdateIssueIndexer(issue.ID) } -func (r *indexerNotifier) NotifyNewIssue(ctx context.Context, issue *issues_model.Issue, mentions []*user_model.User) { +func (r *indexerNotifier) NewIssue(ctx context.Context, issue *issues_model.Issue, mentions []*user_model.User) { issue_indexer.UpdateIssueIndexer(issue.ID) } -func (r *indexerNotifier) NotifyNewPullRequest(ctx context.Context, pr *issues_model.PullRequest, mentions []*user_model.User) { +func (r *indexerNotifier) NewPullRequest(ctx context.Context, pr *issues_model.PullRequest, mentions []*user_model.User) { if err := pr.LoadIssue(ctx); err != nil { log.Error("LoadIssue: %v", err) return @@ -51,7 +51,7 @@ func (r *indexerNotifier) NotifyNewPullRequest(ctx context.Context, pr *issues_m issue_indexer.UpdateIssueIndexer(pr.Issue.ID) } -func (r *indexerNotifier) NotifyUpdateComment(ctx context.Context, doer *user_model.User, c *issues_model.Comment, oldContent string) { +func (r *indexerNotifier) UpdateComment(ctx context.Context, doer *user_model.User, c *issues_model.Comment, oldContent string) { if err := c.LoadIssue(ctx); err != nil { log.Error("LoadIssue: %v", err) return @@ -59,7 +59,7 @@ func (r *indexerNotifier) NotifyUpdateComment(ctx context.Context, doer *user_mo issue_indexer.UpdateIssueIndexer(c.Issue.ID) } -func (r *indexerNotifier) NotifyDeleteComment(ctx context.Context, doer *user_model.User, comment *issues_model.Comment) { +func (r *indexerNotifier) DeleteComment(ctx context.Context, doer *user_model.User, comment *issues_model.Comment) { if err := comment.LoadIssue(ctx); err != nil { log.Error("LoadIssue: %v", err) return @@ -67,14 +67,14 @@ func (r *indexerNotifier) NotifyDeleteComment(ctx context.Context, doer *user_mo issue_indexer.UpdateIssueIndexer(comment.Issue.ID) } -func (r *indexerNotifier) NotifyDeleteRepository(ctx context.Context, doer *user_model.User, repo *repo_model.Repository) { +func (r *indexerNotifier) DeleteRepository(ctx context.Context, doer *user_model.User, repo *repo_model.Repository) { issue_indexer.DeleteRepoIssueIndexer(ctx, repo.ID) if setting.Indexer.RepoIndexerEnabled { code_indexer.UpdateRepoIndexer(repo) } } -func (r *indexerNotifier) NotifyMigrateRepository(ctx context.Context, doer, u *user_model.User, repo *repo_model.Repository) { +func (r *indexerNotifier) MigrateRepository(ctx context.Context, doer, u *user_model.User, repo *repo_model.Repository) { issue_indexer.UpdateRepoIndexer(ctx, repo.ID) if setting.Indexer.RepoIndexerEnabled && !repo.IsEmpty { code_indexer.UpdateRepoIndexer(repo) @@ -84,7 +84,7 @@ func (r *indexerNotifier) NotifyMigrateRepository(ctx context.Context, doer, u * } } -func (r *indexerNotifier) NotifyPushCommits(ctx context.Context, pusher *user_model.User, repo *repo_model.Repository, opts *repository.PushUpdateOptions, commits *repository.PushCommits) { +func (r *indexerNotifier) PushCommits(ctx context.Context, pusher *user_model.User, repo *repo_model.Repository, opts *repository.PushUpdateOptions, commits *repository.PushCommits) { if !opts.RefFullName.IsBranch() { return } @@ -97,7 +97,7 @@ func (r *indexerNotifier) NotifyPushCommits(ctx context.Context, pusher *user_mo } } -func (r *indexerNotifier) NotifySyncPushCommits(ctx context.Context, pusher *user_model.User, repo *repo_model.Repository, opts *repository.PushUpdateOptions, commits *repository.PushCommits) { +func (r *indexerNotifier) SyncPushCommits(ctx context.Context, pusher *user_model.User, repo *repo_model.Repository, opts *repository.PushUpdateOptions, commits *repository.PushCommits) { if !opts.RefFullName.IsBranch() { return } @@ -110,14 +110,14 @@ func (r *indexerNotifier) NotifySyncPushCommits(ctx context.Context, pusher *use } } -func (r *indexerNotifier) NotifyIssueChangeContent(ctx context.Context, doer *user_model.User, issue *issues_model.Issue, oldContent string) { +func (r *indexerNotifier) IssueChangeContent(ctx context.Context, doer *user_model.User, issue *issues_model.Issue, oldContent string) { issue_indexer.UpdateIssueIndexer(issue.ID) } -func (r *indexerNotifier) NotifyIssueChangeTitle(ctx context.Context, doer *user_model.User, issue *issues_model.Issue, oldTitle string) { +func (r *indexerNotifier) IssueChangeTitle(ctx context.Context, doer *user_model.User, issue *issues_model.Issue, oldTitle string) { issue_indexer.UpdateIssueIndexer(issue.ID) } -func (r *indexerNotifier) NotifyIssueChangeRef(ctx context.Context, doer *user_model.User, issue *issues_model.Issue, oldRef string) { +func (r *indexerNotifier) IssueChangeRef(ctx context.Context, doer *user_model.User, issue *issues_model.Issue, oldRef string) { issue_indexer.UpdateIssueIndexer(issue.ID) } |