aboutsummaryrefslogtreecommitdiffstats
path: root/services/issue
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2019-10-29 00:45:43 +0800
committerGitHub <noreply@github.com>2019-10-29 00:45:43 +0800
commitaf8957bc4ce78613fe03cb1abc6c961dd67ff344 (patch)
treeb17b15eddca01c46d53d38abf184a2450e557de4 /services/issue
parente3875ace913ca428804acc9a9ee1cd0b06cd8026 (diff)
downloadgitea-af8957bc4ce78613fe03cb1abc6c961dd67ff344.tar.gz
gitea-af8957bc4ce78613fe03cb1abc6c961dd67ff344.zip
Move issue notifications (#8713)
Diffstat (limited to 'services/issue')
-rw-r--r--services/issue/issue.go32
1 files changed, 8 insertions, 24 deletions
diff --git a/services/issue/issue.go b/services/issue/issue.go
index 06472d8650..ee2f176a43 100644
--- a/services/issue/issue.go
+++ b/services/issue/issue.go
@@ -10,15 +10,20 @@ import (
"code.gitea.io/gitea/models"
"code.gitea.io/gitea/modules/log"
"code.gitea.io/gitea/modules/notification"
- api "code.gitea.io/gitea/modules/structs"
)
// NewIssue creates new issue with labels for repository.
-func NewIssue(repo *models.Repository, issue *models.Issue, labelIDs []int64, uuids []string) error {
+func NewIssue(repo *models.Repository, issue *models.Issue, labelIDs []int64, uuids []string, assigneeIDs []int64) error {
if err := models.NewIssue(repo, issue, labelIDs, uuids); err != nil {
return err
}
+ for _, assigneeID := range assigneeIDs {
+ if err := AddAssigneeIfNotAssigned(issue, issue.Poster, assigneeID); err != nil {
+ return err
+ }
+ }
+
if err := models.NotifyWatchers(&models.Action{
ActUserID: issue.Poster.ID,
ActUser: issue.Poster,
@@ -31,18 +36,7 @@ func NewIssue(repo *models.Repository, issue *models.Issue, labelIDs []int64, uu
log.Error("NotifyWatchers: %v", err)
}
- mode, _ := models.AccessLevel(issue.Poster, issue.Repo)
- if err := models.PrepareWebhooks(repo, models.HookEventIssues, &api.IssuePayload{
- Action: api.HookIssueOpened,
- Index: issue.Index,
- Issue: issue.APIFormat(),
- Repository: repo.APIFormat(mode),
- Sender: issue.Poster.APIFormat(),
- }); err != nil {
- log.Error("PrepareWebhooks: %v", err)
- } else {
- go models.HookQueue.Add(issue.RepoID)
- }
+ notification.NotifyNewIssue(issue)
return nil
}
@@ -149,13 +143,3 @@ func AddAssigneeIfNotAssigned(issue *models.Issue, doer *models.User, assigneeID
return nil
}
-
-// AddAssignees adds a list of assignes (from IDs) to an issue
-func AddAssignees(issue *models.Issue, doer *models.User, assigneeIDs []int64) (err error) {
- for _, assigneeID := range assigneeIDs {
- if err = AddAssigneeIfNotAssigned(issue, doer, assigneeID); err != nil {
- return err
- }
- }
- return nil
-}