aboutsummaryrefslogtreecommitdiffstats
path: root/services/mirror
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2019-11-03 14:59:26 +0800
committerGitHub <noreply@github.com>2019-11-03 14:59:26 +0800
commit022d2d8beb6297016ed26b0090c6a4a4ac404437 (patch)
treeaa6ca5fa9415661d02e97b66251166d456efa18e /services/mirror
parentfe7a6d9bfcbcf53bfe2d24f4d8e7463c897b9389 (diff)
downloadgitea-022d2d8beb6297016ed26b0090c6a4a4ac404437.tar.gz
gitea-022d2d8beb6297016ed26b0090c6a4a4ac404437.zip
Move push commits events to notification (#8783)
* Move push commits events to notification * Update modules/notification/base/null.go Co-Authored-By: guillep2k <18600385+guillep2k@users.noreply.github.com>
Diffstat (limited to 'services/mirror')
-rw-r--r--services/mirror/sync.go23
1 files changed, 3 insertions, 20 deletions
diff --git a/services/mirror/sync.go b/services/mirror/sync.go
index a9ce189c03..ba9e896dd5 100644
--- a/services/mirror/sync.go
+++ b/services/mirror/sync.go
@@ -9,9 +9,8 @@ import (
"fmt"
"code.gitea.io/gitea/models"
+ "code.gitea.io/gitea/modules/notification"
"code.gitea.io/gitea/modules/setting"
- api "code.gitea.io/gitea/modules/structs"
- "code.gitea.io/gitea/modules/webhook"
)
func syncAction(opType models.ActionType, repo *models.Repository, refName string, data []byte) error {
@@ -45,25 +44,9 @@ func SyncPushAction(repo *models.Repository, opts SyncPushActionOptions) error {
opts.Commits.Commits = opts.Commits.Commits[:setting.UI.FeedMaxCommitNum]
}
- apiCommits, err := opts.Commits.ToAPIPayloadCommits(repo.RepoPath(), repo.HTMLURL())
- if err != nil {
- return err
- }
-
opts.Commits.CompareURL = repo.ComposeCompareURL(opts.OldCommitID, opts.NewCommitID)
- apiPusher := repo.MustOwner().APIFormat()
- if err := webhook.PrepareWebhooks(repo, models.HookEventPush, &api.PushPayload{
- Ref: opts.RefName,
- Before: opts.OldCommitID,
- After: opts.NewCommitID,
- CompareURL: setting.AppURL + opts.Commits.CompareURL,
- Commits: apiCommits,
- Repo: repo.APIFormat(models.AccessModeOwner),
- Pusher: apiPusher,
- Sender: apiPusher,
- }); err != nil {
- return fmt.Errorf("PrepareWebhooks: %v", err)
- }
+
+ notification.NotifyPushCommits(repo.MustOwner(), repo, opts.RefName, opts.OldCommitID, opts.NewCommitID, opts.Commits)
data, err := json.Marshal(opts.Commits)
if err != nil {