summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2019-12-02 22:43:39 +0800
committerLauris BH <lauris@nix.lv>2019-12-02 16:43:39 +0200
commit6e81eafdd6b5db756d4ea30d759bac944b80e2de (patch)
treec9aea9ae31880cff79bf4ef3de55ad5f810f5ff7
parent2fc3eb1d152830001ea5e8655b082adcb7adaab9 (diff)
downloadgitea-6e81eafdd6b5db756d4ea30d759bac944b80e2de.tar.gz
gitea-6e81eafdd6b5db756d4ea30d759bac944b80e2de.zip
Remove unused comment actions (#9222)
* Remove unused comment actions * improve code
-rw-r--r--models/issue.go19
-rw-r--r--models/issue_assignees.go3
-rw-r--r--models/issue_comment.go17
-rw-r--r--models/issue_label.go12
-rw-r--r--models/issue_lock.go7
-rw-r--r--models/issue_milestone.go7
6 files changed, 10 insertions, 55 deletions
diff --git a/models/issue.go b/models/issue.go
index a3597f1585..0a08a97fdd 100644
--- a/models/issue.go
+++ b/models/issue.go
@@ -721,13 +721,9 @@ func (issue *Issue) ChangeTitle(doer *User, oldTitle string) (err error) {
OldTitle: oldTitle,
NewTitle: issue.Title,
}
- comment, err := createCommentWithNoAction(sess, opts)
- if err != nil {
+ if _, err = createCommentWithNoAction(sess, opts); err != nil {
return fmt.Errorf("createComment: %v", err)
}
- if err = sendCreateCommentAction(sess, opts, comment); err != nil {
- return err
- }
if err = issue.addCrossReferences(sess, doer, true); err != nil {
return err
}
@@ -753,11 +749,7 @@ func AddDeletePRBranchComment(doer *User, repo *Repository, issueID int64, branc
Issue: issue,
CommitSHA: branchName,
}
- comment, err := createCommentWithNoAction(sess, opts)
- if err != nil {
- return err
- }
- if err = sendCreateCommentAction(sess, opts, comment); err != nil {
+ if _, err = createCommentWithNoAction(sess, opts); err != nil {
return err
}
@@ -899,12 +891,7 @@ func newIssue(e *xorm.Session, doer *User, opts NewIssueOptions) (err error) {
OldMilestoneID: 0,
MilestoneID: opts.Issue.MilestoneID,
}
- comment, err := createCommentWithNoAction(e, opts)
- if err != nil {
- return err
- }
-
- if err = sendCreateCommentAction(e, opts, comment); err != nil {
+ if _, err = createCommentWithNoAction(e, opts); err != nil {
return err
}
}
diff --git a/models/issue_assignees.go b/models/issue_assignees.go
index c78132db5d..1eee9d7769 100644
--- a/models/issue_assignees.go
+++ b/models/issue_assignees.go
@@ -144,9 +144,6 @@ func (issue *Issue) toggleAssignee(sess *xorm.Session, doer *User, assigneeID in
if err != nil {
return false, nil, fmt.Errorf("createComment: %v", err)
}
- if err = sendCreateCommentAction(sess, opts, comment); err != nil {
- return false, nil, err
- }
// if pull request is in the middle of creation - don't call webhook
if isCreate {
diff --git a/models/issue_comment.go b/models/issue_comment.go
index 1fad141d92..5843689f1b 100644
--- a/models/issue_comment.go
+++ b/models/issue_comment.go
@@ -678,7 +678,7 @@ func createDeadlineComment(e *xorm.Session, doer *User, issue *Issue, newDeadlin
if err != nil {
return nil, err
}
- return comment, sendCreateCommentAction(e, opts, comment)
+ return comment, nil
}
// Creates issue dependency comment
@@ -699,13 +699,9 @@ func createIssueDependencyComment(e *xorm.Session, doer *User, issue *Issue, dep
Issue: issue,
DependentIssueID: dependentIssue.ID,
}
- comment, err := createCommentWithNoAction(e, opts)
- if err != nil {
+ if _, err = createCommentWithNoAction(e, opts); err != nil {
return
}
- if err = sendCreateCommentAction(e, opts, comment); err != nil {
- return err
- }
opts = &CreateCommentOptions{
Type: cType,
@@ -714,14 +710,7 @@ func createIssueDependencyComment(e *xorm.Session, doer *User, issue *Issue, dep
Issue: dependentIssue,
DependentIssueID: issue.ID,
}
- comment, err = createCommentWithNoAction(e, opts)
- if err != nil {
- return
- }
- if err = sendCreateCommentAction(e, opts, comment); err != nil {
- return err
- }
-
+ _, err = createCommentWithNoAction(e, opts)
return
}
diff --git a/models/issue_label.go b/models/issue_label.go
index b2dd106176..4318406af7 100644
--- a/models/issue_label.go
+++ b/models/issue_label.go
@@ -414,11 +414,7 @@ func newIssueLabel(e *xorm.Session, issue *Issue, label *Label, doer *User) (err
Label: label,
Content: "1",
}
- comment, err := createCommentWithNoAction(e, opts)
- if err != nil {
- return err
- }
- if err = sendCreateCommentAction(e, opts, comment); err != nil {
+ if _, err = createCommentWithNoAction(e, opts); err != nil {
return err
}
@@ -494,11 +490,7 @@ func deleteIssueLabel(e *xorm.Session, issue *Issue, label *Label, doer *User) (
Issue: issue,
Label: label,
}
- comment, err := createCommentWithNoAction(e, opts)
- if err != nil {
- return err
- }
- if err = sendCreateCommentAction(e, opts, comment); err != nil {
+ if _, err = createCommentWithNoAction(e, opts); err != nil {
return err
}
diff --git a/models/issue_lock.go b/models/issue_lock.go
index 05eca27ad6..4a2055ce32 100644
--- a/models/issue_lock.go
+++ b/models/issue_lock.go
@@ -52,12 +52,7 @@ func updateIssueLock(opts *IssueLockOptions, lock bool) error {
Type: commentType,
Content: opts.Reason,
}
- comment, err := createCommentWithNoAction(sess, opt)
- if err != nil {
- return err
- }
-
- if err = sendCreateCommentAction(sess, opt, comment); err != nil {
+ if _, err := createCommentWithNoAction(sess, opt); err != nil {
return err
}
diff --git a/models/issue_milestone.go b/models/issue_milestone.go
index e3cbb90624..0b854a8671 100644
--- a/models/issue_milestone.go
+++ b/models/issue_milestone.go
@@ -394,12 +394,7 @@ func changeMilestoneAssign(e *xorm.Session, doer *User, issue *Issue, oldMilesto
OldMilestoneID: oldMilestoneID,
MilestoneID: issue.MilestoneID,
}
- comment, err := createCommentWithNoAction(e, opts)
- if err != nil {
- return err
- }
-
- if err := sendCreateCommentAction(e, opts, comment); err != nil {
+ if _, err := createCommentWithNoAction(e, opts); err != nil {
return err
}
}