aboutsummaryrefslogtreecommitdiffstats
path: root/services
diff options
context:
space:
mode:
Diffstat (limited to 'services')
-rw-r--r--services/issue/milestone.go21
-rw-r--r--services/milestone/milestone.go58
2 files changed, 21 insertions, 58 deletions
diff --git a/services/issue/milestone.go b/services/issue/milestone.go
new file mode 100644
index 0000000000..6fe527f58c
--- /dev/null
+++ b/services/issue/milestone.go
@@ -0,0 +1,21 @@
+// Copyright 2019 The Gitea Authors. All rights reserved.
+// Use of this source code is governed by a MIT-style
+// license that can be found in the LICENSE file.
+
+package issue
+
+import (
+ "code.gitea.io/gitea/models"
+ "code.gitea.io/gitea/modules/notification"
+)
+
+// ChangeMilestoneAssign changes assignment of milestone for issue.
+func ChangeMilestoneAssign(issue *models.Issue, doer *models.User, oldMilestoneID int64) (err error) {
+ if err = models.ChangeMilestoneAssign(issue, doer, oldMilestoneID); err != nil {
+ return
+ }
+
+ notification.NotifyIssueChangeMilestone(doer, issue, oldMilestoneID)
+
+ return nil
+}
diff --git a/services/milestone/milestone.go b/services/milestone/milestone.go
deleted file mode 100644
index 84e7fb30e2..0000000000
--- a/services/milestone/milestone.go
+++ /dev/null
@@ -1,58 +0,0 @@
-// Copyright 2019 The Gitea Authors. All rights reserved.
-// Use of this source code is governed by a MIT-style
-// license that can be found in the LICENSE file.
-
-package models
-
-import (
- "code.gitea.io/gitea/models"
- "code.gitea.io/gitea/modules/log"
- api "code.gitea.io/gitea/modules/structs"
- "code.gitea.io/gitea/modules/webhook"
-)
-
-// ChangeMilestoneAssign changes assignment of milestone for issue.
-func ChangeMilestoneAssign(issue *models.Issue, doer *models.User, oldMilestoneID int64) (err error) {
- if err = models.ChangeMilestoneAssign(issue, doer, oldMilestoneID); err != nil {
- return
- }
-
- var hookAction api.HookIssueAction
- if issue.MilestoneID > 0 {
- hookAction = api.HookIssueMilestoned
- } else {
- hookAction = api.HookIssueDemilestoned
- }
-
- if err = issue.LoadAttributes(); err != nil {
- return err
- }
-
- mode, _ := models.AccessLevel(doer, issue.Repo)
- if issue.IsPull {
- err = issue.PullRequest.LoadIssue()
- if err != nil {
- log.Error("LoadIssue: %v", err)
- return
- }
- err = webhook.PrepareWebhooks(issue.Repo, models.HookEventPullRequest, &api.PullRequestPayload{
- Action: hookAction,
- Index: issue.Index,
- PullRequest: issue.PullRequest.APIFormat(),
- Repository: issue.Repo.APIFormat(mode),
- Sender: doer.APIFormat(),
- })
- } else {
- err = webhook.PrepareWebhooks(issue.Repo, models.HookEventIssues, &api.IssuePayload{
- Action: hookAction,
- Index: issue.Index,
- Issue: issue.APIFormat(),
- Repository: issue.Repo.APIFormat(mode),
- Sender: doer.APIFormat(),
- })
- }
- if err != nil {
- log.Error("PrepareWebhooks [is_pull: %v]: %v", issue.IsPull, err)
- }
- return nil
-}