summaryrefslogtreecommitdiffstats
path: root/modules/notification
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2019-10-30 16:36:25 +0800
committerLauris BH <lauris@nix.lv>2019-10-30 10:36:25 +0200
commitf694bb45d79dcc093bc6332eabb3af063bc6b088 (patch)
tree8a9d2551d52a9a4ff13a087df30ed613d748d814 /modules/notification
parent56ebc0c003349cea1c919c9dd408fc83ee79274e (diff)
downloadgitea-f694bb45d79dcc093bc6332eabb3af063bc6b088.tar.gz
gitea-f694bb45d79dcc093bc6332eabb3af063bc6b088.zip
Move issue change content from models to service (#8711)
* Move issue change content from models to service * fix lint
Diffstat (limited to 'modules/notification')
-rw-r--r--modules/notification/webhook/webhook.go38
1 files changed, 38 insertions, 0 deletions
diff --git a/modules/notification/webhook/webhook.go b/modules/notification/webhook/webhook.go
index bd7c8b29d3..a2af152edd 100644
--- a/modules/notification/webhook/webhook.go
+++ b/modules/notification/webhook/webhook.go
@@ -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)
+ }
+}