mirror of
https://github.com/go-gitea/gitea
synced 2025-07-22 18:28:37 +00:00
Move notification interface to services layer (#26915)
Extract from #22266
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
Reference in New Issue
Block a user