summaryrefslogtreecommitdiffstats
path: root/modules/notification
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2020-01-10 15:53:53 +0800
committerGitHub <noreply@github.com>2020-01-10 15:53:53 +0800
commit384c2b342ec01fadb520572666127cb5564e1050 (patch)
tree73357abe356721749e212b90049444cf279a97e4 /modules/notification
parent8878cfa4a125348d92f8163988ac9d3279f27e75 (diff)
downloadgitea-384c2b342ec01fadb520572666127cb5564e1050.tar.gz
gitea-384c2b342ec01fadb520572666127cb5564e1050.zip
Move pull request api convert to convert package (#9664)
* Move pull request api convert to convert package * Rename ToPullRequest to ToAPIPullRequest
Diffstat (limited to 'modules/notification')
-rw-r--r--modules/notification/webhook/webhook.go25
1 files changed, 13 insertions, 12 deletions
diff --git a/modules/notification/webhook/webhook.go b/modules/notification/webhook/webhook.go
index e0801445d8..cf4117666c 100644
--- a/modules/notification/webhook/webhook.go
+++ b/modules/notification/webhook/webhook.go
@@ -6,6 +6,7 @@ package webhook
import (
"code.gitea.io/gitea/models"
+ "code.gitea.io/gitea/modules/convert"
"code.gitea.io/gitea/modules/git"
"code.gitea.io/gitea/modules/log"
"code.gitea.io/gitea/modules/notification/base"
@@ -49,7 +50,7 @@ func (m *webhookNotifier) NotifyIssueClearLabels(doer *models.User, issue *model
err = webhook_module.PrepareWebhooks(issue.Repo, models.HookEventPullRequest, &api.PullRequestPayload{
Action: api.HookIssueLabelCleared,
Index: issue.Index,
- PullRequest: issue.PullRequest.APIFormat(),
+ PullRequest: convert.ToAPIPullRequest(issue.PullRequest),
Repository: issue.Repo.APIFormat(mode),
Sender: doer.APIFormat(),
})
@@ -135,7 +136,7 @@ func (m *webhookNotifier) NotifyIssueChangeAssignee(doer *models.User, issue *mo
issue.PullRequest.Issue = issue
apiPullRequest := &api.PullRequestPayload{
Index: issue.Index,
- PullRequest: issue.PullRequest.APIFormat(),
+ PullRequest: convert.ToAPIPullRequest(issue.PullRequest),
Repository: issue.Repo.APIFormat(mode),
Sender: doer.APIFormat(),
}
@@ -187,7 +188,7 @@ func (m *webhookNotifier) NotifyIssueChangeTitle(doer *models.User, issue *model
From: oldTitle,
},
},
- PullRequest: issue.PullRequest.APIFormat(),
+ PullRequest: convert.ToAPIPullRequest(issue.PullRequest),
Repository: issue.Repo.APIFormat(mode),
Sender: doer.APIFormat(),
})
@@ -222,7 +223,7 @@ func (m *webhookNotifier) NotifyIssueChangeStatus(doer *models.User, issue *mode
// Merge pull request calls issue.changeStatus so we need to handle separately.
apiPullRequest := &api.PullRequestPayload{
Index: issue.Index,
- PullRequest: issue.PullRequest.APIFormat(),
+ PullRequest: convert.ToAPIPullRequest(issue.PullRequest),
Repository: issue.Repo.APIFormat(mode),
Sender: doer.APIFormat(),
}
@@ -291,7 +292,7 @@ func (m *webhookNotifier) NotifyNewPullRequest(pull *models.PullRequest) {
if err := webhook_module.PrepareWebhooks(pull.Issue.Repo, models.HookEventPullRequest, &api.PullRequestPayload{
Action: api.HookIssueOpened,
Index: pull.Issue.Index,
- PullRequest: pull.APIFormat(),
+ PullRequest: convert.ToAPIPullRequest(pull),
Repository: pull.Issue.Repo.APIFormat(mode),
Sender: pull.Issue.Poster.APIFormat(),
}); err != nil {
@@ -312,7 +313,7 @@ func (m *webhookNotifier) NotifyIssueChangeContent(doer *models.User, issue *mod
From: oldContent,
},
},
- PullRequest: issue.PullRequest.APIFormat(),
+ PullRequest: convert.ToAPIPullRequest(issue.PullRequest),
Repository: issue.Repo.APIFormat(mode),
Sender: doer.APIFormat(),
})
@@ -439,7 +440,7 @@ func (m *webhookNotifier) NotifyIssueChangeLabels(doer *models.User, issue *mode
err = webhook_module.PrepareWebhooks(issue.Repo, models.HookEventPullRequest, &api.PullRequestPayload{
Action: api.HookIssueLabelUpdated,
Index: issue.Index,
- PullRequest: issue.PullRequest.APIFormat(),
+ PullRequest: convert.ToAPIPullRequest(issue.PullRequest),
Repository: issue.Repo.APIFormat(models.AccessModeNone),
Sender: doer.APIFormat(),
})
@@ -481,7 +482,7 @@ func (m *webhookNotifier) NotifyIssueChangeMilestone(doer *models.User, issue *m
err = webhook_module.PrepareWebhooks(issue.Repo, models.HookEventPullRequest, &api.PullRequestPayload{
Action: hookAction,
Index: issue.Index,
- PullRequest: issue.PullRequest.APIFormat(),
+ PullRequest: convert.ToAPIPullRequest(issue.PullRequest),
Repository: issue.Repo.APIFormat(mode),
Sender: doer.APIFormat(),
})
@@ -547,7 +548,7 @@ func (*webhookNotifier) NotifyMergePullRequest(pr *models.PullRequest, doer *mod
// Merge pull request calls issue.changeStatus so we need to handle separately.
apiPullRequest := &api.PullRequestPayload{
Index: pr.Issue.Index,
- PullRequest: pr.APIFormat(),
+ PullRequest: convert.ToAPIPullRequest(pr),
Repository: pr.Issue.Repo.APIFormat(mode),
Sender: doer.APIFormat(),
Action: api.HookIssueClosed,
@@ -580,7 +581,7 @@ func (m *webhookNotifier) NotifyPullRequestChangeTargetBranch(doer *models.User,
From: oldBranch,
},
},
- PullRequest: issue.PullRequest.APIFormat(),
+ PullRequest: convert.ToAPIPullRequest(issue.PullRequest),
Repository: issue.Repo.APIFormat(mode),
Sender: doer.APIFormat(),
})
@@ -619,7 +620,7 @@ func (m *webhookNotifier) NotifyPullRequestReview(pr *models.PullRequest, review
if err := webhook_module.PrepareWebhooks(review.Issue.Repo, reviewHookType, &api.PullRequestPayload{
Action: api.HookIssueSynchronized,
Index: review.Issue.Index,
- PullRequest: pr.APIFormat(),
+ PullRequest: convert.ToAPIPullRequest(pr),
Repository: review.Issue.Repo.APIFormat(mode),
Sender: review.Reviewer.APIFormat(),
Review: &api.ReviewPayload{
@@ -674,7 +675,7 @@ func (m *webhookNotifier) NotifyPullRequestSynchronized(doer *models.User, pr *m
if err := webhook_module.PrepareWebhooks(pr.Issue.Repo, models.HookEventPullRequest, &api.PullRequestPayload{
Action: api.HookIssueSynchronized,
Index: pr.Issue.Index,
- PullRequest: pr.Issue.PullRequest.APIFormat(),
+ PullRequest: convert.ToAPIPullRequest(pr),
Repository: pr.Issue.Repo.APIFormat(models.AccessModeNone),
Sender: doer.APIFormat(),
}); err != nil {