@@ -495,7 +495,7 @@ func (c *Comment) CodeCommentURL() string {
495
495
return fmt .Sprintf ("%s/files#%s" , c .Issue .HTMLURL (), c .HashTag ())
496
496
}
497
497
498
- func createComment (e * xorm.Session , opts * CreateCommentOptions ) (_ * Comment , err error ) {
498
+ func createCommentWithNoAction (e * xorm.Session , opts * CreateCommentOptions ) (_ * Comment , err error ) {
499
499
var LabelID int64
500
500
if opts .Label != nil {
501
501
LabelID = opts .Label .ID
@@ -539,12 +539,6 @@ func createComment(e *xorm.Session, opts *CreateCommentOptions) (_ *Comment, err
539
539
return nil , err
540
540
}
541
541
542
- if ! opts .NoAction {
543
- if err = sendCreateCommentAction (e , opts , comment ); err != nil {
544
- return nil , err
545
- }
546
- }
547
-
548
542
if err = comment .addCrossReferences (e , opts .Doer , false ); err != nil {
549
543
return nil , err
550
544
}
@@ -651,19 +645,7 @@ func sendCreateCommentAction(e *xorm.Session, opts *CreateCommentOptions, commen
651
645
return nil
652
646
}
653
647
654
- func createMilestoneComment (e * xorm.Session , doer * User , repo * Repository , issue * Issue , oldMilestoneID , milestoneID int64 ) (* Comment , error ) {
655
- return createComment (e , & CreateCommentOptions {
656
- Type : CommentTypeMilestone ,
657
- Doer : doer ,
658
- Repo : repo ,
659
- Issue : issue ,
660
- OldMilestoneID : oldMilestoneID ,
661
- MilestoneID : milestoneID ,
662
- })
663
- }
664
-
665
648
func createDeadlineComment (e * xorm.Session , doer * User , issue * Issue , newDeadlineUnix timeutil.TimeStamp ) (* Comment , error ) {
666
-
667
649
var content string
668
650
var commentType CommentType
669
651
@@ -685,13 +667,18 @@ func createDeadlineComment(e *xorm.Session, doer *User, issue *Issue, newDeadlin
685
667
return nil , err
686
668
}
687
669
688
- return createComment ( e , & CreateCommentOptions {
670
+ var opts = & CreateCommentOptions {
689
671
Type : commentType ,
690
672
Doer : doer ,
691
673
Repo : issue .Repo ,
692
674
Issue : issue ,
693
675
Content : content ,
694
- })
676
+ }
677
+ comment , err := createCommentWithNoAction (e , opts )
678
+ if err != nil {
679
+ return nil , err
680
+ }
681
+ return comment , sendCreateCommentAction (e , opts , comment )
695
682
}
696
683
697
684
// Creates issue dependency comment
@@ -705,27 +692,35 @@ func createIssueDependencyComment(e *xorm.Session, doer *User, issue *Issue, dep
705
692
}
706
693
707
694
// Make two comments, one in each issue
708
- _ , err = createComment ( e , & CreateCommentOptions {
695
+ var opts = & CreateCommentOptions {
709
696
Type : cType ,
710
697
Doer : doer ,
711
698
Repo : issue .Repo ,
712
699
Issue : issue ,
713
700
DependentIssueID : dependentIssue .ID ,
714
- })
701
+ }
702
+ comment , err := createCommentWithNoAction (e , opts )
715
703
if err != nil {
716
704
return
717
705
}
706
+ if err = sendCreateCommentAction (e , opts , comment ); err != nil {
707
+ return err
708
+ }
718
709
719
- _ , err = createComment ( e , & CreateCommentOptions {
710
+ opts = & CreateCommentOptions {
720
711
Type : cType ,
721
712
Doer : doer ,
722
713
Repo : issue .Repo ,
723
714
Issue : dependentIssue ,
724
715
DependentIssueID : issue .ID ,
725
- })
716
+ }
717
+ comment , err = createCommentWithNoAction (e , opts )
726
718
if err != nil {
727
719
return
728
720
}
721
+ if err = sendCreateCommentAction (e , opts , comment ); err != nil {
722
+ return err
723
+ }
729
724
730
725
return
731
726
}
@@ -758,7 +753,6 @@ type CreateCommentOptions struct {
758
753
RefCommentID int64
759
754
RefAction references.XRefAction
760
755
RefIsPull bool
761
- NoAction bool
762
756
}
763
757
764
758
// CreateComment creates comment of issue or commit.
@@ -769,7 +763,31 @@ func CreateComment(opts *CreateCommentOptions) (comment *Comment, err error) {
769
763
return nil , err
770
764
}
771
765
772
- comment , err = createComment (sess , opts )
766
+ comment , err = createCommentWithNoAction (sess , opts )
767
+ if err != nil {
768
+ return nil , err
769
+ }
770
+
771
+ if err = sendCreateCommentAction (sess , opts , comment ); err != nil {
772
+ return nil , err
773
+ }
774
+
775
+ if err = sess .Commit (); err != nil {
776
+ return nil , err
777
+ }
778
+
779
+ return comment , nil
780
+ }
781
+
782
+ // CreateCommentWithNoAction creates comment of issue or commit with no action created
783
+ func CreateCommentWithNoAction (opts * CreateCommentOptions ) (comment * Comment , err error ) {
784
+ sess := x .NewSession ()
785
+ defer sess .Close ()
786
+ if err = sess .Begin (); err != nil {
787
+ return nil , err
788
+ }
789
+
790
+ comment , err = createCommentWithNoAction (sess , opts )
773
791
if err != nil {
774
792
return nil , err
775
793
}
0 commit comments