Skip to content

Commit 6e81eaf

Browse files
lunnylafriks
authored andcommitted
Remove unused comment actions (#9222)
* Remove unused comment actions * improve code
1 parent 2fc3eb1 commit 6e81eaf

File tree

6 files changed

+10
-55
lines changed

6 files changed

+10
-55
lines changed

models/issue.go

+3-16
Original file line numberDiff line numberDiff line change
@@ -721,13 +721,9 @@ func (issue *Issue) ChangeTitle(doer *User, oldTitle string) (err error) {
721721
OldTitle: oldTitle,
722722
NewTitle: issue.Title,
723723
}
724-
comment, err := createCommentWithNoAction(sess, opts)
725-
if err != nil {
724+
if _, err = createCommentWithNoAction(sess, opts); err != nil {
726725
return fmt.Errorf("createComment: %v", err)
727726
}
728-
if err = sendCreateCommentAction(sess, opts, comment); err != nil {
729-
return err
730-
}
731727
if err = issue.addCrossReferences(sess, doer, true); err != nil {
732728
return err
733729
}
@@ -753,11 +749,7 @@ func AddDeletePRBranchComment(doer *User, repo *Repository, issueID int64, branc
753749
Issue: issue,
754750
CommitSHA: branchName,
755751
}
756-
comment, err := createCommentWithNoAction(sess, opts)
757-
if err != nil {
758-
return err
759-
}
760-
if err = sendCreateCommentAction(sess, opts, comment); err != nil {
752+
if _, err = createCommentWithNoAction(sess, opts); err != nil {
761753
return err
762754
}
763755

@@ -899,12 +891,7 @@ func newIssue(e *xorm.Session, doer *User, opts NewIssueOptions) (err error) {
899891
OldMilestoneID: 0,
900892
MilestoneID: opts.Issue.MilestoneID,
901893
}
902-
comment, err := createCommentWithNoAction(e, opts)
903-
if err != nil {
904-
return err
905-
}
906-
907-
if err = sendCreateCommentAction(e, opts, comment); err != nil {
894+
if _, err = createCommentWithNoAction(e, opts); err != nil {
908895
return err
909896
}
910897
}

models/issue_assignees.go

-3
Original file line numberDiff line numberDiff line change
@@ -144,9 +144,6 @@ func (issue *Issue) toggleAssignee(sess *xorm.Session, doer *User, assigneeID in
144144
if err != nil {
145145
return false, nil, fmt.Errorf("createComment: %v", err)
146146
}
147-
if err = sendCreateCommentAction(sess, opts, comment); err != nil {
148-
return false, nil, err
149-
}
150147

151148
// if pull request is in the middle of creation - don't call webhook
152149
if isCreate {

models/issue_comment.go

+3-14
Original file line numberDiff line numberDiff line change
@@ -678,7 +678,7 @@ func createDeadlineComment(e *xorm.Session, doer *User, issue *Issue, newDeadlin
678678
if err != nil {
679679
return nil, err
680680
}
681-
return comment, sendCreateCommentAction(e, opts, comment)
681+
return comment, nil
682682
}
683683

684684
// Creates issue dependency comment
@@ -699,13 +699,9 @@ func createIssueDependencyComment(e *xorm.Session, doer *User, issue *Issue, dep
699699
Issue: issue,
700700
DependentIssueID: dependentIssue.ID,
701701
}
702-
comment, err := createCommentWithNoAction(e, opts)
703-
if err != nil {
702+
if _, err = createCommentWithNoAction(e, opts); err != nil {
704703
return
705704
}
706-
if err = sendCreateCommentAction(e, opts, comment); err != nil {
707-
return err
708-
}
709705

710706
opts = &CreateCommentOptions{
711707
Type: cType,
@@ -714,14 +710,7 @@ func createIssueDependencyComment(e *xorm.Session, doer *User, issue *Issue, dep
714710
Issue: dependentIssue,
715711
DependentIssueID: issue.ID,
716712
}
717-
comment, err = createCommentWithNoAction(e, opts)
718-
if err != nil {
719-
return
720-
}
721-
if err = sendCreateCommentAction(e, opts, comment); err != nil {
722-
return err
723-
}
724-
713+
_, err = createCommentWithNoAction(e, opts)
725714
return
726715
}
727716

models/issue_label.go

+2-10
Original file line numberDiff line numberDiff line change
@@ -414,11 +414,7 @@ func newIssueLabel(e *xorm.Session, issue *Issue, label *Label, doer *User) (err
414414
Label: label,
415415
Content: "1",
416416
}
417-
comment, err := createCommentWithNoAction(e, opts)
418-
if err != nil {
419-
return err
420-
}
421-
if err = sendCreateCommentAction(e, opts, comment); err != nil {
417+
if _, err = createCommentWithNoAction(e, opts); err != nil {
422418
return err
423419
}
424420

@@ -494,11 +490,7 @@ func deleteIssueLabel(e *xorm.Session, issue *Issue, label *Label, doer *User) (
494490
Issue: issue,
495491
Label: label,
496492
}
497-
comment, err := createCommentWithNoAction(e, opts)
498-
if err != nil {
499-
return err
500-
}
501-
if err = sendCreateCommentAction(e, opts, comment); err != nil {
493+
if _, err = createCommentWithNoAction(e, opts); err != nil {
502494
return err
503495
}
504496

models/issue_lock.go

+1-6
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,7 @@ func updateIssueLock(opts *IssueLockOptions, lock bool) error {
5252
Type: commentType,
5353
Content: opts.Reason,
5454
}
55-
comment, err := createCommentWithNoAction(sess, opt)
56-
if err != nil {
57-
return err
58-
}
59-
60-
if err = sendCreateCommentAction(sess, opt, comment); err != nil {
55+
if _, err := createCommentWithNoAction(sess, opt); err != nil {
6156
return err
6257
}
6358

models/issue_milestone.go

+1-6
Original file line numberDiff line numberDiff line change
@@ -394,12 +394,7 @@ func changeMilestoneAssign(e *xorm.Session, doer *User, issue *Issue, oldMilesto
394394
OldMilestoneID: oldMilestoneID,
395395
MilestoneID: issue.MilestoneID,
396396
}
397-
comment, err := createCommentWithNoAction(e, opts)
398-
if err != nil {
399-
return err
400-
}
401-
402-
if err := sendCreateCommentAction(e, opts, comment); err != nil {
397+
if _, err := createCommentWithNoAction(e, opts); err != nil {
403398
return err
404399
}
405400
}

0 commit comments

Comments
 (0)