forked from forgejo/forgejo
Move issue change content from models to service (#8711)
* Move issue change content from models to service * fix lint
This commit is contained in:
parent
56ebc0c003
commit
f694bb45d7
4 changed files with 63 additions and 43 deletions
|
@ -277,3 +277,41 @@ func (m *webhookNotifier) NotifyNewIssue(issue *models.Issue) {
|
|||
go models.HookQueue.Add(issue.RepoID)
|
||||
}
|
||||
}
|
||||
|
||||
func (m *webhookNotifier) NotifyIssueChangeContent(doer *models.User, issue *models.Issue, oldContent string) {
|
||||
mode, _ := models.AccessLevel(issue.Poster, issue.Repo)
|
||||
var err error
|
||||
if issue.IsPull {
|
||||
issue.PullRequest.Issue = issue
|
||||
err = models.PrepareWebhooks(issue.Repo, models.HookEventPullRequest, &api.PullRequestPayload{
|
||||
Action: api.HookIssueEdited,
|
||||
Index: issue.Index,
|
||||
Changes: &api.ChangesPayload{
|
||||
Body: &api.ChangesFromPayload{
|
||||
From: oldContent,
|
||||
},
|
||||
},
|
||||
PullRequest: issue.PullRequest.APIFormat(),
|
||||
Repository: issue.Repo.APIFormat(mode),
|
||||
Sender: doer.APIFormat(),
|
||||
})
|
||||
} else {
|
||||
err = models.PrepareWebhooks(issue.Repo, models.HookEventIssues, &api.IssuePayload{
|
||||
Action: api.HookIssueEdited,
|
||||
Index: issue.Index,
|
||||
Changes: &api.ChangesPayload{
|
||||
Body: &api.ChangesFromPayload{
|
||||
From: oldContent,
|
||||
},
|
||||
},
|
||||
Issue: issue.APIFormat(),
|
||||
Repository: issue.Repo.APIFormat(mode),
|
||||
Sender: doer.APIFormat(),
|
||||
})
|
||||
}
|
||||
if err != nil {
|
||||
log.Error("PrepareWebhooks [is_pull: %v]: %v", issue.IsPull, err)
|
||||
} else {
|
||||
go models.HookQueue.Add(issue.RepoID)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue