mirror of
https://codeberg.org/davrot/forgejo.git
synced 2025-05-22 20:00:03 +02:00
Move pull request api convert to convert package (#9664)
* Move pull request api convert to convert package * Rename ToPullRequest to ToAPIPullRequest
This commit is contained in:
parent
8878cfa4a1
commit
384c2b342e
7 changed files with 198 additions and 160 deletions
|
@ -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 {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue