diff options
author | Lunny Xiao <xiaolunwen@gmail.com> | 2023-06-26 14:59:15 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-06-26 06:59:15 +0000 |
commit | d44a415bf019393b85a33aa31244f52d43f55080 (patch) | |
tree | 1b301660bd5bf05c6842143021cd70367a833e24 /modules/notification | |
parent | 48e5a74f215d78813a816c57fc5a85a909a003d5 (diff) | |
download | gitea-d44a415bf019393b85a33aa31244f52d43f55080.tar.gz gitea-d44a415bf019393b85a33aa31244f52d43f55080.zip |
Add Adopt repository event and handler (#25497)
Fix #14304
---------
Co-authored-by: delvh <dev.lh@web.de>
Diffstat (limited to 'modules/notification')
-rw-r--r-- | modules/notification/base/notifier.go | 1 | ||||
-rw-r--r-- | modules/notification/base/null.go | 4 | ||||
-rw-r--r-- | modules/notification/indexer/indexer.go | 4 | ||||
-rw-r--r-- | modules/notification/notification.go | 7 |
4 files changed, 16 insertions, 0 deletions
diff --git a/modules/notification/base/notifier.go b/modules/notification/base/notifier.go index e1762bb1ee..be4d774a8b 100644 --- a/modules/notification/base/notifier.go +++ b/modules/notification/base/notifier.go @@ -17,6 +17,7 @@ import ( // Notifier defines an interface to notify receiver type Notifier interface { Run() + NotifyAdoptRepository(ctx context.Context, doer, u *user_model.User, repo *repo_model.Repository) NotifyCreateRepository(ctx context.Context, doer, u *user_model.User, repo *repo_model.Repository) NotifyMigrateRepository(ctx context.Context, doer, u *user_model.User, repo *repo_model.Repository) NotifyDeleteRepository(ctx context.Context, doer *user_model.User, repo *repo_model.Repository) diff --git a/modules/notification/base/null.go b/modules/notification/base/null.go index 338790b356..56a25394f9 100644 --- a/modules/notification/base/null.go +++ b/modules/notification/base/null.go @@ -145,6 +145,10 @@ func (*NullNotifier) NotifyIssueChangeLabels(ctx context.Context, doer *user_mod func (*NullNotifier) NotifyCreateRepository(ctx context.Context, doer, u *user_model.User, repo *repo_model.Repository) { } +// NotifyAdoptRepository places a place holder function +func (*NullNotifier) NotifyAdoptRepository(ctx context.Context, doer, u *user_model.User, repo *repo_model.Repository) { +} + // NotifyDeleteRepository places a place holder function func (*NullNotifier) NotifyDeleteRepository(ctx context.Context, doer *user_model.User, repo *repo_model.Repository) { } diff --git a/modules/notification/indexer/indexer.go b/modules/notification/indexer/indexer.go index 0661c2c1ab..bb652e3942 100644 --- a/modules/notification/indexer/indexer.go +++ b/modules/notification/indexer/indexer.go @@ -29,6 +29,10 @@ func NewNotifier() base.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) NotifyCreateIssueComment(ctx context.Context, doer *user_model.User, repo *repo_model.Repository, issue *issues_model.Issue, comment *issues_model.Comment, mentions []*user_model.User, ) { diff --git a/modules/notification/notification.go b/modules/notification/notification.go index 6153c9e3d6..99e1a06ebd 100644 --- a/modules/notification/notification.go +++ b/modules/notification/notification.go @@ -274,6 +274,13 @@ func NotifyCreateRepository(ctx context.Context, doer, u *user_model.User, repo } } +// NotifyAdoptRepository notifies the adoption of a repository to notifiers +func NotifyAdoptRepository(ctx context.Context, doer, u *user_model.User, repo *repo_model.Repository) { + for _, notifier := range notifiers { + notifier.NotifyAdoptRepository(ctx, doer, u, repo) + } +} + // NotifyMigrateRepository notifies create repository to notifiers func NotifyMigrateRepository(ctx context.Context, doer, u *user_model.User, repo *repo_model.Repository) { for _, notifier := range notifiers { |