Remove unused comment actions (#9222)

* Remove unused comment actions

* improve code
This commit is contained in:
Lunny Xiao 2019-12-02 22:43:39 +08:00 committed by Lauris BH
parent 2fc3eb1d15
commit 6e81eafdd6
6 changed files with 10 additions and 55 deletions

View file

@ -721,13 +721,9 @@ func (issue *Issue) ChangeTitle(doer *User, oldTitle string) (err error) {
OldTitle: oldTitle, OldTitle: oldTitle,
NewTitle: issue.Title, NewTitle: issue.Title,
} }
comment, err := createCommentWithNoAction(sess, opts) if _, err = createCommentWithNoAction(sess, opts); err != nil {
if err != nil {
return fmt.Errorf("createComment: %v", err) 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 { if err = issue.addCrossReferences(sess, doer, true); err != nil {
return err return err
} }
@ -753,11 +749,7 @@ func AddDeletePRBranchComment(doer *User, repo *Repository, issueID int64, branc
Issue: issue, Issue: issue,
CommitSHA: branchName, CommitSHA: branchName,
} }
comment, err := createCommentWithNoAction(sess, opts) if _, err = createCommentWithNoAction(sess, opts); err != nil {
if err != nil {
return err
}
if err = sendCreateCommentAction(sess, opts, comment); err != nil {
return err return err
} }
@ -899,12 +891,7 @@ func newIssue(e *xorm.Session, doer *User, opts NewIssueOptions) (err error) {
OldMilestoneID: 0, OldMilestoneID: 0,
MilestoneID: opts.Issue.MilestoneID, MilestoneID: opts.Issue.MilestoneID,
} }
comment, err := createCommentWithNoAction(e, opts) if _, err = createCommentWithNoAction(e, opts); err != nil {
if err != nil {
return err
}
if err = sendCreateCommentAction(e, opts, comment); err != nil {
return err return err
} }
} }

View file

@ -144,9 +144,6 @@ func (issue *Issue) toggleAssignee(sess *xorm.Session, doer *User, assigneeID in
if err != nil { if err != nil {
return false, nil, fmt.Errorf("createComment: %v", err) 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 pull request is in the middle of creation - don't call webhook
if isCreate { if isCreate {

View file

@ -678,7 +678,7 @@ func createDeadlineComment(e *xorm.Session, doer *User, issue *Issue, newDeadlin
if err != nil { if err != nil {
return nil, err return nil, err
} }
return comment, sendCreateCommentAction(e, opts, comment) return comment, nil
} }
// Creates issue dependency comment // Creates issue dependency comment
@ -699,13 +699,9 @@ func createIssueDependencyComment(e *xorm.Session, doer *User, issue *Issue, dep
Issue: issue, Issue: issue,
DependentIssueID: dependentIssue.ID, DependentIssueID: dependentIssue.ID,
} }
comment, err := createCommentWithNoAction(e, opts) if _, err = createCommentWithNoAction(e, opts); err != nil {
if err != nil {
return return
} }
if err = sendCreateCommentAction(e, opts, comment); err != nil {
return err
}
opts = &CreateCommentOptions{ opts = &CreateCommentOptions{
Type: cType, Type: cType,
@ -714,14 +710,7 @@ func createIssueDependencyComment(e *xorm.Session, doer *User, issue *Issue, dep
Issue: dependentIssue, Issue: dependentIssue,
DependentIssueID: issue.ID, DependentIssueID: issue.ID,
} }
comment, err = createCommentWithNoAction(e, opts) _, err = createCommentWithNoAction(e, opts)
if err != nil {
return
}
if err = sendCreateCommentAction(e, opts, comment); err != nil {
return err
}
return return
} }

View file

@ -414,11 +414,7 @@ func newIssueLabel(e *xorm.Session, issue *Issue, label *Label, doer *User) (err
Label: label, Label: label,
Content: "1", Content: "1",
} }
comment, err := createCommentWithNoAction(e, opts) if _, err = createCommentWithNoAction(e, opts); err != nil {
if err != nil {
return err
}
if err = sendCreateCommentAction(e, opts, comment); err != nil {
return err return err
} }
@ -494,11 +490,7 @@ func deleteIssueLabel(e *xorm.Session, issue *Issue, label *Label, doer *User) (
Issue: issue, Issue: issue,
Label: label, Label: label,
} }
comment, err := createCommentWithNoAction(e, opts) if _, err = createCommentWithNoAction(e, opts); err != nil {
if err != nil {
return err
}
if err = sendCreateCommentAction(e, opts, comment); err != nil {
return err return err
} }

View file

@ -52,12 +52,7 @@ func updateIssueLock(opts *IssueLockOptions, lock bool) error {
Type: commentType, Type: commentType,
Content: opts.Reason, Content: opts.Reason,
} }
comment, err := createCommentWithNoAction(sess, opt) if _, err := createCommentWithNoAction(sess, opt); err != nil {
if err != nil {
return err
}
if err = sendCreateCommentAction(sess, opt, comment); err != nil {
return err return err
} }

View file

@ -394,12 +394,7 @@ func changeMilestoneAssign(e *xorm.Session, doer *User, issue *Issue, oldMilesto
OldMilestoneID: oldMilestoneID, OldMilestoneID: oldMilestoneID,
MilestoneID: issue.MilestoneID, MilestoneID: issue.MilestoneID,
} }
comment, err := createCommentWithNoAction(e, opts) if _, err := createCommentWithNoAction(e, opts); err != nil {
if err != nil {
return err
}
if err := sendCreateCommentAction(e, opts, comment); err != nil {
return err return err
} }
} }