2018-10-18 07:23:05 -04:00
|
|
|
// Copyright 2018 The Gitea Authors. All rights reserved.
|
2022-11-27 13:20:29 -05:00
|
|
|
// SPDX-License-Identifier: MIT
|
2016-12-30 11:44:54 -05:00
|
|
|
|
|
|
|
package notification
|
|
|
|
|
|
|
|
import (
|
2022-11-19 03:12:33 -05:00
|
|
|
"context"
|
|
|
|
|
2022-06-13 05:37:59 -04:00
|
|
|
issues_model "code.gitea.io/gitea/models/issues"
|
2022-03-30 04:42:47 -04:00
|
|
|
packages_model "code.gitea.io/gitea/models/packages"
|
2021-12-09 20:27:50 -05:00
|
|
|
repo_model "code.gitea.io/gitea/models/repo"
|
2021-11-24 04:49:20 -05:00
|
|
|
user_model "code.gitea.io/gitea/models/user"
|
2019-11-03 15:59:09 -05:00
|
|
|
"code.gitea.io/gitea/modules/notification/action"
|
2018-10-18 07:23:05 -04:00
|
|
|
"code.gitea.io/gitea/modules/notification/base"
|
2019-01-17 09:23:22 -05:00
|
|
|
"code.gitea.io/gitea/modules/notification/indexer"
|
2019-01-13 09:42:55 -05:00
|
|
|
"code.gitea.io/gitea/modules/notification/mail"
|
2022-07-08 15:45:12 -04:00
|
|
|
"code.gitea.io/gitea/modules/notification/mirror"
|
2018-10-18 07:23:05 -04:00
|
|
|
"code.gitea.io/gitea/modules/notification/ui"
|
2019-10-15 01:03:05 -04:00
|
|
|
"code.gitea.io/gitea/modules/notification/webhook"
|
2020-01-10 04:34:21 -05:00
|
|
|
"code.gitea.io/gitea/modules/repository"
|
2019-10-25 10:46:37 -04:00
|
|
|
"code.gitea.io/gitea/modules/setting"
|
2016-12-30 11:44:54 -05:00
|
|
|
)
|
|
|
|
|
2022-01-20 12:46:10 -05:00
|
|
|
var notifiers []base.Notifier
|
2018-10-18 07:23:05 -04:00
|
|
|
|
|
|
|
// RegisterNotifier providers method to receive notify messages
|
|
|
|
func RegisterNotifier(notifier base.Notifier) {
|
|
|
|
go notifier.Run()
|
|
|
|
notifiers = append(notifiers, notifier)
|
|
|
|
}
|
|
|
|
|
2019-10-25 10:46:37 -04:00
|
|
|
// NewContext registers notification handlers
|
|
|
|
func NewContext() {
|
2018-10-18 07:23:05 -04:00
|
|
|
RegisterNotifier(ui.NewNotifier())
|
2019-10-25 10:46:37 -04:00
|
|
|
if setting.Service.EnableNotifyMail {
|
|
|
|
RegisterNotifier(mail.NewNotifier())
|
|
|
|
}
|
2019-01-17 09:23:22 -05:00
|
|
|
RegisterNotifier(indexer.NewNotifier())
|
2019-10-15 01:03:05 -04:00
|
|
|
RegisterNotifier(webhook.NewNotifier())
|
2019-11-03 15:59:09 -05:00
|
|
|
RegisterNotifier(action.NewNotifier())
|
2022-07-08 15:45:12 -04:00
|
|
|
RegisterNotifier(mirror.NewNotifier())
|
2018-10-18 07:23:05 -04:00
|
|
|
}
|
|
|
|
|
2022-09-04 15:54:23 -04:00
|
|
|
// NotifyNewWikiPage notifies creating new wiki pages to notifiers
|
2022-11-19 03:12:33 -05:00
|
|
|
func NotifyNewWikiPage(ctx context.Context, doer *user_model.User, repo *repo_model.Repository, page, comment string) {
|
2022-09-04 15:54:23 -04:00
|
|
|
for _, notifier := range notifiers {
|
2022-11-19 03:12:33 -05:00
|
|
|
notifier.NotifyNewWikiPage(ctx, doer, repo, page, comment)
|
2022-09-04 15:54:23 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// NotifyEditWikiPage notifies editing or renaming wiki pages to notifiers
|
2022-11-19 03:12:33 -05:00
|
|
|
func NotifyEditWikiPage(ctx context.Context, doer *user_model.User, repo *repo_model.Repository, page, comment string) {
|
2022-09-04 15:54:23 -04:00
|
|
|
for _, notifier := range notifiers {
|
2022-11-19 03:12:33 -05:00
|
|
|
notifier.NotifyEditWikiPage(ctx, doer, repo, page, comment)
|
2022-09-04 15:54:23 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// NotifyDeleteWikiPage notifies deleting wiki pages to notifiers
|
2022-11-19 03:12:33 -05:00
|
|
|
func NotifyDeleteWikiPage(ctx context.Context, doer *user_model.User, repo *repo_model.Repository, page string) {
|
2022-09-04 15:54:23 -04:00
|
|
|
for _, notifier := range notifiers {
|
2022-11-19 03:12:33 -05:00
|
|
|
notifier.NotifyDeleteWikiPage(ctx, doer, repo, page)
|
2022-09-04 15:54:23 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-10-18 07:23:05 -04:00
|
|
|
// NotifyCreateIssueComment notifies issue comment related message to notifiers
|
2022-11-19 03:12:33 -05:00
|
|
|
func NotifyCreateIssueComment(ctx context.Context, doer *user_model.User, repo *repo_model.Repository,
|
2022-06-13 05:37:59 -04:00
|
|
|
issue *issues_model.Issue, comment *issues_model.Comment, mentions []*user_model.User,
|
2022-02-23 15:16:07 -05:00
|
|
|
) {
|
2018-10-18 07:23:05 -04:00
|
|
|
for _, notifier := range notifiers {
|
2022-11-19 03:12:33 -05:00
|
|
|
notifier.NotifyCreateIssueComment(ctx, doer, repo, issue, comment, mentions)
|
2016-12-30 11:44:54 -05:00
|
|
|
}
|
2018-10-18 07:23:05 -04:00
|
|
|
}
|
2016-12-30 11:44:54 -05:00
|
|
|
|
2018-10-18 07:23:05 -04:00
|
|
|
// NotifyNewIssue notifies new issue to notifiers
|
2022-11-19 03:12:33 -05:00
|
|
|
func NotifyNewIssue(ctx context.Context, issue *issues_model.Issue, mentions []*user_model.User) {
|
2018-10-18 07:23:05 -04:00
|
|
|
for _, notifier := range notifiers {
|
2022-11-19 03:12:33 -05:00
|
|
|
notifier.NotifyNewIssue(ctx, issue, mentions)
|
2016-12-30 11:44:54 -05:00
|
|
|
}
|
2018-10-18 07:23:05 -04:00
|
|
|
}
|
2016-12-30 11:44:54 -05:00
|
|
|
|
2018-10-18 07:23:05 -04:00
|
|
|
// NotifyIssueChangeStatus notifies close or reopen issue to notifiers
|
2022-11-19 03:12:33 -05:00
|
|
|
func NotifyIssueChangeStatus(ctx context.Context, doer *user_model.User, issue *issues_model.Issue, actionComment *issues_model.Comment, closeOrReopen bool) {
|
2018-10-18 07:23:05 -04:00
|
|
|
for _, notifier := range notifiers {
|
2022-11-19 03:12:33 -05:00
|
|
|
notifier.NotifyIssueChangeStatus(ctx, doer, issue, actionComment, closeOrReopen)
|
2016-12-30 11:44:54 -05:00
|
|
|
}
|
2018-10-18 07:23:05 -04:00
|
|
|
}
|
2016-12-30 11:44:54 -05:00
|
|
|
|
2022-02-28 19:20:15 -05:00
|
|
|
// NotifyDeleteIssue notify when some issue deleted
|
2022-11-19 03:12:33 -05:00
|
|
|
func NotifyDeleteIssue(ctx context.Context, doer *user_model.User, issue *issues_model.Issue) {
|
2022-02-28 19:20:15 -05:00
|
|
|
for _, notifier := range notifiers {
|
2022-11-19 03:12:33 -05:00
|
|
|
notifier.NotifyDeleteIssue(ctx, doer, issue)
|
2022-02-28 19:20:15 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-10-18 07:23:05 -04:00
|
|
|
// NotifyMergePullRequest notifies merge pull request to notifiers
|
2022-11-19 03:12:33 -05:00
|
|
|
func NotifyMergePullRequest(ctx context.Context, doer *user_model.User, pr *issues_model.PullRequest) {
|
2018-10-18 07:23:05 -04:00
|
|
|
for _, notifier := range notifiers {
|
2022-11-19 03:12:33 -05:00
|
|
|
notifier.NotifyMergePullRequest(ctx, doer, pr)
|
2018-10-18 07:23:05 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-11-03 11:49:00 -04:00
|
|
|
// NotifyAutoMergePullRequest notifies merge pull request to notifiers
|
2022-11-19 03:12:33 -05:00
|
|
|
func NotifyAutoMergePullRequest(ctx context.Context, doer *user_model.User, pr *issues_model.PullRequest) {
|
2022-11-03 11:49:00 -04:00
|
|
|
for _, notifier := range notifiers {
|
2022-11-19 03:12:33 -05:00
|
|
|
notifier.NotifyAutoMergePullRequest(ctx, doer, pr)
|
2022-11-03 11:49:00 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-10-18 07:23:05 -04:00
|
|
|
// NotifyNewPullRequest notifies new pull request to notifiers
|
2022-11-19 03:12:33 -05:00
|
|
|
func NotifyNewPullRequest(ctx context.Context, pr *issues_model.PullRequest, mentions []*user_model.User) {
|
2018-10-18 07:23:05 -04:00
|
|
|
for _, notifier := range notifiers {
|
2022-11-19 03:12:33 -05:00
|
|
|
notifier.NotifyNewPullRequest(ctx, pr, mentions)
|
2018-10-18 07:23:05 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-11-05 06:04:08 -05:00
|
|
|
// NotifyPullRequestSynchronized notifies Synchronized pull request
|
2022-11-19 03:12:33 -05:00
|
|
|
func NotifyPullRequestSynchronized(ctx context.Context, doer *user_model.User, pr *issues_model.PullRequest) {
|
2019-11-05 06:04:08 -05:00
|
|
|
for _, notifier := range notifiers {
|
2022-11-19 03:12:33 -05:00
|
|
|
notifier.NotifyPullRequestSynchronized(ctx, doer, pr)
|
2019-11-05 06:04:08 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-10-18 07:23:05 -04:00
|
|
|
// NotifyPullRequestReview notifies new pull request review
|
2022-11-19 03:12:33 -05:00
|
|
|
func NotifyPullRequestReview(ctx context.Context, pr *issues_model.PullRequest, review *issues_model.Review, comment *issues_model.Comment, mentions []*user_model.User) {
|
2018-10-18 07:23:05 -04:00
|
|
|
for _, notifier := range notifiers {
|
2022-11-19 03:12:33 -05:00
|
|
|
notifier.NotifyPullRequestReview(ctx, pr, review, comment, mentions)
|
2021-01-02 12:04:02 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// NotifyPullRequestCodeComment notifies new pull request code comment
|
2022-11-19 03:12:33 -05:00
|
|
|
func NotifyPullRequestCodeComment(ctx context.Context, pr *issues_model.PullRequest, comment *issues_model.Comment, mentions []*user_model.User) {
|
2021-01-02 12:04:02 -05:00
|
|
|
for _, notifier := range notifiers {
|
2022-11-19 03:12:33 -05:00
|
|
|
notifier.NotifyPullRequestCodeComment(ctx, pr, comment, mentions)
|
2018-10-18 07:23:05 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-12-16 01:20:25 -05:00
|
|
|
// NotifyPullRequestChangeTargetBranch notifies when a pull request's target branch was changed
|
2022-11-19 03:12:33 -05:00
|
|
|
func NotifyPullRequestChangeTargetBranch(ctx context.Context, doer *user_model.User, pr *issues_model.PullRequest, oldBranch string) {
|
2019-12-16 01:20:25 -05:00
|
|
|
for _, notifier := range notifiers {
|
2022-11-19 03:12:33 -05:00
|
|
|
notifier.NotifyPullRequestChangeTargetBranch(ctx, doer, pr, oldBranch)
|
2019-12-16 01:20:25 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-05-20 08:47:24 -04:00
|
|
|
// NotifyPullRequestPushCommits notifies when push commits to pull request's head branch
|
2022-11-19 03:12:33 -05:00
|
|
|
func NotifyPullRequestPushCommits(ctx context.Context, doer *user_model.User, pr *issues_model.PullRequest, comment *issues_model.Comment) {
|
2020-05-20 08:47:24 -04:00
|
|
|
for _, notifier := range notifiers {
|
2022-11-19 03:12:33 -05:00
|
|
|
notifier.NotifyPullRequestPushCommits(ctx, doer, pr, comment)
|
2020-05-20 08:47:24 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-11-19 03:12:33 -05:00
|
|
|
// NotifyPullReviewDismiss notifies when a review was dismissed by repo admin
|
|
|
|
func NotifyPullReviewDismiss(ctx context.Context, doer *user_model.User, review *issues_model.Review, comment *issues_model.Comment) {
|
2021-02-11 12:32:25 -05:00
|
|
|
for _, notifier := range notifiers {
|
2022-11-19 03:12:33 -05:00
|
|
|
notifier.NotifyPullReviewDismiss(ctx, doer, review, comment)
|
2021-02-11 12:32:25 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-10-18 07:23:05 -04:00
|
|
|
// NotifyUpdateComment notifies update comment to notifiers
|
2022-11-19 03:12:33 -05:00
|
|
|
func NotifyUpdateComment(ctx context.Context, doer *user_model.User, c *issues_model.Comment, oldContent string) {
|
2018-10-18 07:23:05 -04:00
|
|
|
for _, notifier := range notifiers {
|
2022-11-19 03:12:33 -05:00
|
|
|
notifier.NotifyUpdateComment(ctx, doer, c, oldContent)
|
2018-10-18 07:23:05 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// NotifyDeleteComment notifies delete comment to notifiers
|
2022-11-19 03:12:33 -05:00
|
|
|
func NotifyDeleteComment(ctx context.Context, doer *user_model.User, c *issues_model.Comment) {
|
2018-10-18 07:23:05 -04:00
|
|
|
for _, notifier := range notifiers {
|
2022-11-19 03:12:33 -05:00
|
|
|
notifier.NotifyDeleteComment(ctx, doer, c)
|
2018-10-18 07:23:05 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// NotifyNewRelease notifies new release to notifiers
|
2022-11-19 03:12:33 -05:00
|
|
|
func NotifyNewRelease(ctx context.Context, rel *repo_model.Release) {
|
2018-10-18 07:23:05 -04:00
|
|
|
for _, notifier := range notifiers {
|
2022-11-19 03:12:33 -05:00
|
|
|
notifier.NotifyNewRelease(ctx, rel)
|
2018-10-18 07:23:05 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// NotifyUpdateRelease notifies update release to notifiers
|
2022-11-19 03:12:33 -05:00
|
|
|
func NotifyUpdateRelease(ctx context.Context, doer *user_model.User, rel *repo_model.Release) {
|
2018-10-18 07:23:05 -04:00
|
|
|
for _, notifier := range notifiers {
|
2022-11-19 03:12:33 -05:00
|
|
|
notifier.NotifyUpdateRelease(ctx, doer, rel)
|
2018-10-18 07:23:05 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// NotifyDeleteRelease notifies delete release to notifiers
|
2022-11-19 03:12:33 -05:00
|
|
|
func NotifyDeleteRelease(ctx context.Context, doer *user_model.User, rel *repo_model.Release) {
|
2018-10-18 07:23:05 -04:00
|
|
|
for _, notifier := range notifiers {
|
2022-11-19 03:12:33 -05:00
|
|
|
notifier.NotifyDeleteRelease(ctx, doer, rel)
|
2018-10-18 07:23:05 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// NotifyIssueChangeMilestone notifies change milestone to notifiers
|
2022-11-19 03:12:33 -05:00
|
|
|
func NotifyIssueChangeMilestone(ctx context.Context, doer *user_model.User, issue *issues_model.Issue, oldMilestoneID int64) {
|
2018-10-18 07:23:05 -04:00
|
|
|
for _, notifier := range notifiers {
|
2022-11-19 03:12:33 -05:00
|
|
|
notifier.NotifyIssueChangeMilestone(ctx, doer, issue, oldMilestoneID)
|
2018-10-18 07:23:05 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// NotifyIssueChangeContent notifies change content to notifiers
|
2022-11-19 03:12:33 -05:00
|
|
|
func NotifyIssueChangeContent(ctx context.Context, doer *user_model.User, issue *issues_model.Issue, oldContent string) {
|
2018-10-18 07:23:05 -04:00
|
|
|
for _, notifier := range notifiers {
|
2022-11-19 03:12:33 -05:00
|
|
|
notifier.NotifyIssueChangeContent(ctx, doer, issue, oldContent)
|
2018-10-18 07:23:05 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// NotifyIssueChangeAssignee notifies change content to notifiers
|
2022-11-19 03:12:33 -05:00
|
|
|
func NotifyIssueChangeAssignee(ctx context.Context, doer *user_model.User, issue *issues_model.Issue, assignee *user_model.User, removed bool, comment *issues_model.Comment) {
|
2018-10-18 07:23:05 -04:00
|
|
|
for _, notifier := range notifiers {
|
2022-11-19 03:12:33 -05:00
|
|
|
notifier.NotifyIssueChangeAssignee(ctx, doer, issue, assignee, removed, comment)
|
2018-10-18 07:23:05 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-04-30 16:24:08 -04:00
|
|
|
// NotifyPullReviewRequest notifies Request Review change
|
2022-11-19 03:12:33 -05:00
|
|
|
func NotifyPullReviewRequest(ctx context.Context, doer *user_model.User, issue *issues_model.Issue, reviewer *user_model.User, isRequest bool, comment *issues_model.Comment) {
|
2020-04-06 12:33:34 -04:00
|
|
|
for _, notifier := range notifiers {
|
2022-11-19 03:12:33 -05:00
|
|
|
notifier.NotifyPullReviewRequest(ctx, doer, issue, reviewer, isRequest, comment)
|
2020-04-06 12:33:34 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-10-18 07:23:05 -04:00
|
|
|
// NotifyIssueClearLabels notifies clear labels to notifiers
|
2022-11-19 03:12:33 -05:00
|
|
|
func NotifyIssueClearLabels(ctx context.Context, doer *user_model.User, issue *issues_model.Issue) {
|
2018-10-18 07:23:05 -04:00
|
|
|
for _, notifier := range notifiers {
|
2022-11-19 03:12:33 -05:00
|
|
|
notifier.NotifyIssueClearLabels(ctx, doer, issue)
|
2018-10-18 07:23:05 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// NotifyIssueChangeTitle notifies change title to notifiers
|
2022-11-19 03:12:33 -05:00
|
|
|
func NotifyIssueChangeTitle(ctx context.Context, doer *user_model.User, issue *issues_model.Issue, oldTitle string) {
|
2018-10-18 07:23:05 -04:00
|
|
|
for _, notifier := range notifiers {
|
2022-11-19 03:12:33 -05:00
|
|
|
notifier.NotifyIssueChangeTitle(ctx, doer, issue, oldTitle)
|
2018-10-18 07:23:05 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-09-08 12:29:51 -04:00
|
|
|
// NotifyIssueChangeRef notifies change reference to notifiers
|
2022-11-19 03:12:33 -05:00
|
|
|
func NotifyIssueChangeRef(ctx context.Context, doer *user_model.User, issue *issues_model.Issue, oldRef string) {
|
2020-09-08 12:29:51 -04:00
|
|
|
for _, notifier := range notifiers {
|
2022-11-19 03:12:33 -05:00
|
|
|
notifier.NotifyIssueChangeRef(ctx, doer, issue, oldRef)
|
2020-09-08 12:29:51 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-10-18 07:23:05 -04:00
|
|
|
// NotifyIssueChangeLabels notifies change labels to notifiers
|
2022-11-19 03:12:33 -05:00
|
|
|
func NotifyIssueChangeLabels(ctx context.Context, doer *user_model.User, issue *issues_model.Issue,
|
2022-06-13 05:37:59 -04:00
|
|
|
addedLabels, removedLabels []*issues_model.Label,
|
2022-02-23 15:16:07 -05:00
|
|
|
) {
|
2018-10-18 07:23:05 -04:00
|
|
|
for _, notifier := range notifiers {
|
2022-11-19 03:12:33 -05:00
|
|
|
notifier.NotifyIssueChangeLabels(ctx, doer, issue, addedLabels, removedLabels)
|
2018-10-18 07:23:05 -04:00
|
|
|
}
|
2016-12-30 11:44:54 -05:00
|
|
|
}
|
|
|
|
|
2018-10-18 07:23:05 -04:00
|
|
|
// NotifyCreateRepository notifies create repository to notifiers
|
2022-11-19 03:12:33 -05:00
|
|
|
func NotifyCreateRepository(ctx context.Context, doer, u *user_model.User, repo *repo_model.Repository) {
|
2018-10-18 07:23:05 -04:00
|
|
|
for _, notifier := range notifiers {
|
2022-11-19 03:12:33 -05:00
|
|
|
notifier.NotifyCreateRepository(ctx, doer, u, repo)
|
2016-12-30 11:44:54 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-10-18 07:23:05 -04:00
|
|
|
// NotifyMigrateRepository notifies create repository to notifiers
|
2022-11-19 03:12:33 -05:00
|
|
|
func NotifyMigrateRepository(ctx context.Context, doer, u *user_model.User, repo *repo_model.Repository) {
|
2018-10-18 07:23:05 -04:00
|
|
|
for _, notifier := range notifiers {
|
2022-11-19 03:12:33 -05:00
|
|
|
notifier.NotifyMigrateRepository(ctx, doer, u, repo)
|
2016-12-30 11:44:54 -05:00
|
|
|
}
|
|
|
|
}
|
2019-11-03 01:59:26 -05:00
|
|
|
|
2019-11-15 03:06:11 -05:00
|
|
|
// NotifyTransferRepository notifies create repository to notifiers
|
2022-11-19 03:12:33 -05:00
|
|
|
func NotifyTransferRepository(ctx context.Context, doer *user_model.User, repo *repo_model.Repository, newOwnerName string) {
|
2019-11-15 03:06:11 -05:00
|
|
|
for _, notifier := range notifiers {
|
2022-11-19 03:12:33 -05:00
|
|
|
notifier.NotifyTransferRepository(ctx, doer, repo, newOwnerName)
|
2019-11-15 03:06:11 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// NotifyDeleteRepository notifies delete repository to notifiers
|
2022-11-19 03:12:33 -05:00
|
|
|
func NotifyDeleteRepository(ctx context.Context, doer *user_model.User, repo *repo_model.Repository) {
|
2019-11-15 03:06:11 -05:00
|
|
|
for _, notifier := range notifiers {
|
2022-11-19 03:12:33 -05:00
|
|
|
notifier.NotifyDeleteRepository(ctx, doer, repo)
|
2019-11-15 03:06:11 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// NotifyForkRepository notifies fork repository to notifiers
|
2022-11-19 03:12:33 -05:00
|
|
|
func NotifyForkRepository(ctx context.Context, doer *user_model.User, oldRepo, repo *repo_model.Repository) {
|
2019-11-15 03:06:11 -05:00
|
|
|
for _, notifier := range notifiers {
|
2022-11-19 03:12:33 -05:00
|
|
|
notifier.NotifyForkRepository(ctx, doer, oldRepo, repo)
|
2019-11-15 03:06:11 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// NotifyRenameRepository notifies repository renamed
|
2022-11-19 03:12:33 -05:00
|
|
|
func NotifyRenameRepository(ctx context.Context, doer *user_model.User, repo *repo_model.Repository, oldName string) {
|
2019-11-15 03:06:11 -05:00
|
|
|
for _, notifier := range notifiers {
|
2022-11-19 03:12:33 -05:00
|
|
|
notifier.NotifyRenameRepository(ctx, doer, repo, oldName)
|
2019-11-15 03:06:11 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-11-03 01:59:26 -05:00
|
|
|
// NotifyPushCommits notifies commits pushed to notifiers
|
2022-11-19 03:12:33 -05:00
|
|
|
func NotifyPushCommits(ctx context.Context, pusher *user_model.User, repo *repo_model.Repository, opts *repository.PushUpdateOptions, commits *repository.PushCommits) {
|
2019-11-03 01:59:26 -05:00
|
|
|
for _, notifier := range notifiers {
|
2022-11-19 03:12:33 -05:00
|
|
|
notifier.NotifyPushCommits(ctx, pusher, repo, opts, commits)
|
2019-11-03 01:59:26 -05:00
|
|
|
}
|
|
|
|
}
|
2019-11-06 01:43:03 -05:00
|
|
|
|
|
|
|
// NotifyCreateRef notifies branch or tag creation to notifiers
|
2022-11-19 03:12:33 -05:00
|
|
|
func NotifyCreateRef(ctx context.Context, pusher *user_model.User, repo *repo_model.Repository, refType, refFullName, refID string) {
|
2019-11-06 01:43:03 -05:00
|
|
|
for _, notifier := range notifiers {
|
2022-11-19 03:12:33 -05:00
|
|
|
notifier.NotifyCreateRef(ctx, pusher, repo, refType, refFullName, refID)
|
2019-11-06 01:43:03 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// NotifyDeleteRef notifies branch or tag deletion to notifiers
|
2022-11-19 03:12:33 -05:00
|
|
|
func NotifyDeleteRef(ctx context.Context, pusher *user_model.User, repo *repo_model.Repository, refType, refFullName string) {
|
2019-11-06 01:43:03 -05:00
|
|
|
for _, notifier := range notifiers {
|
2022-11-19 03:12:33 -05:00
|
|
|
notifier.NotifyDeleteRef(ctx, pusher, repo, refType, refFullName)
|
2019-11-06 01:43:03 -05:00
|
|
|
}
|
|
|
|
}
|
2019-11-24 00:16:59 -05:00
|
|
|
|
|
|
|
// NotifySyncPushCommits notifies commits pushed to notifiers
|
2022-11-19 03:12:33 -05:00
|
|
|
func NotifySyncPushCommits(ctx context.Context, pusher *user_model.User, repo *repo_model.Repository, opts *repository.PushUpdateOptions, commits *repository.PushCommits) {
|
2019-11-24 00:16:59 -05:00
|
|
|
for _, notifier := range notifiers {
|
2022-11-19 03:12:33 -05:00
|
|
|
notifier.NotifySyncPushCommits(ctx, pusher, repo, opts, commits)
|
2019-11-24 00:16:59 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// NotifySyncCreateRef notifies branch or tag creation to notifiers
|
2022-11-19 03:12:33 -05:00
|
|
|
func NotifySyncCreateRef(ctx context.Context, pusher *user_model.User, repo *repo_model.Repository, refType, refFullName, refID string) {
|
2019-11-24 00:16:59 -05:00
|
|
|
for _, notifier := range notifiers {
|
2022-11-19 03:12:33 -05:00
|
|
|
notifier.NotifySyncCreateRef(ctx, pusher, repo, refType, refFullName, refID)
|
2019-11-24 00:16:59 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// NotifySyncDeleteRef notifies branch or tag deletion to notifiers
|
2022-11-19 03:12:33 -05:00
|
|
|
func NotifySyncDeleteRef(ctx context.Context, pusher *user_model.User, repo *repo_model.Repository, refType, refFullName string) {
|
2019-11-24 00:16:59 -05:00
|
|
|
for _, notifier := range notifiers {
|
2022-11-19 03:12:33 -05:00
|
|
|
notifier.NotifySyncDeleteRef(ctx, pusher, repo, refType, refFullName)
|
2019-11-24 00:16:59 -05:00
|
|
|
}
|
|
|
|
}
|
2021-02-28 19:47:30 -05:00
|
|
|
|
|
|
|
// NotifyRepoPendingTransfer notifies creation of pending transfer to notifiers
|
2022-11-19 03:12:33 -05:00
|
|
|
func NotifyRepoPendingTransfer(ctx context.Context, doer, newOwner *user_model.User, repo *repo_model.Repository) {
|
2021-02-28 19:47:30 -05:00
|
|
|
for _, notifier := range notifiers {
|
2022-11-19 03:12:33 -05:00
|
|
|
notifier.NotifyRepoPendingTransfer(ctx, doer, newOwner, repo)
|
2021-02-28 19:47:30 -05:00
|
|
|
}
|
|
|
|
}
|
2022-03-30 04:42:47 -04:00
|
|
|
|
|
|
|
// NotifyPackageCreate notifies creation of a package to notifiers
|
2022-11-19 03:12:33 -05:00
|
|
|
func NotifyPackageCreate(ctx context.Context, doer *user_model.User, pd *packages_model.PackageDescriptor) {
|
2022-03-30 04:42:47 -04:00
|
|
|
for _, notifier := range notifiers {
|
2022-11-19 03:12:33 -05:00
|
|
|
notifier.NotifyPackageCreate(ctx, doer, pd)
|
2022-03-30 04:42:47 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// NotifyPackageDelete notifies deletion of a package to notifiers
|
2022-11-19 03:12:33 -05:00
|
|
|
func NotifyPackageDelete(ctx context.Context, doer *user_model.User, pd *packages_model.PackageDescriptor) {
|
2022-03-30 04:42:47 -04:00
|
|
|
for _, notifier := range notifiers {
|
2022-11-19 03:12:33 -05:00
|
|
|
notifier.NotifyPackageDelete(ctx, doer, pd)
|
2022-03-30 04:42:47 -04:00
|
|
|
}
|
|
|
|
}
|