remove unused method and rename createcommentWithNoAction (#9367)
This commit is contained in:
@ -495,7 +495,7 @@ func (c *Comment) CodeCommentURL() string {
|
||||
return fmt.Sprintf("%s/files#%s", c.Issue.HTMLURL(), c.HashTag())
|
||||
}
|
||||
|
||||
func createCommentWithNoAction(e *xorm.Session, opts *CreateCommentOptions) (_ *Comment, err error) {
|
||||
func createComment(e *xorm.Session, opts *CreateCommentOptions) (_ *Comment, err error) {
|
||||
var LabelID int64
|
||||
if opts.Label != nil {
|
||||
LabelID = opts.Label.ID
|
||||
@ -589,55 +589,6 @@ func updateCommentInfos(e *xorm.Session, opts *CreateCommentOptions, comment *Co
|
||||
return updateIssueCols(e, opts.Issue, "updated_unix")
|
||||
}
|
||||
|
||||
func sendCreateCommentAction(e *xorm.Session, opts *CreateCommentOptions, comment *Comment) (err error) {
|
||||
// Compose comment action, could be plain comment, close or reopen issue/pull request.
|
||||
// This object will be used to notify watchers in the end of function.
|
||||
act := &Action{
|
||||
ActUserID: opts.Doer.ID,
|
||||
ActUser: opts.Doer,
|
||||
Content: fmt.Sprintf("%d|%s", opts.Issue.Index, strings.Split(opts.Content, "\n")[0]),
|
||||
RepoID: opts.Repo.ID,
|
||||
Repo: opts.Repo,
|
||||
Comment: comment,
|
||||
CommentID: comment.ID,
|
||||
IsPrivate: opts.Repo.IsPrivate,
|
||||
}
|
||||
// Check comment type.
|
||||
switch opts.Type {
|
||||
case CommentTypeCode:
|
||||
if comment.ReviewID != 0 {
|
||||
if comment.Review == nil {
|
||||
if err := comment.loadReview(e); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
if comment.Review.Type <= ReviewTypePending {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
fallthrough
|
||||
case CommentTypeComment:
|
||||
act.OpType = ActionCommentIssue
|
||||
case CommentTypeReopen:
|
||||
act.OpType = ActionReopenIssue
|
||||
if opts.Issue.IsPull {
|
||||
act.OpType = ActionReopenPullRequest
|
||||
}
|
||||
case CommentTypeClose:
|
||||
act.OpType = ActionCloseIssue
|
||||
if opts.Issue.IsPull {
|
||||
act.OpType = ActionClosePullRequest
|
||||
}
|
||||
}
|
||||
// Notify watchers for whatever action comes in, ignore if no action type.
|
||||
if act.OpType > 0 {
|
||||
if err = notifyWatchers(e, act); err != nil {
|
||||
log.Error("notifyWatchers: %v", err)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func createDeadlineComment(e *xorm.Session, doer *User, issue *Issue, newDeadlineUnix timeutil.TimeStamp) (*Comment, error) {
|
||||
var content string
|
||||
var commentType CommentType
|
||||
@ -667,7 +618,7 @@ func createDeadlineComment(e *xorm.Session, doer *User, issue *Issue, newDeadlin
|
||||
Issue: issue,
|
||||
Content: content,
|
||||
}
|
||||
comment, err := createCommentWithNoAction(e, opts)
|
||||
comment, err := createComment(e, opts)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -692,7 +643,7 @@ func createIssueDependencyComment(e *xorm.Session, doer *User, issue *Issue, dep
|
||||
Issue: issue,
|
||||
DependentIssueID: dependentIssue.ID,
|
||||
}
|
||||
if _, err = createCommentWithNoAction(e, opts); err != nil {
|
||||
if _, err = createComment(e, opts); err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
@ -703,7 +654,7 @@ func createIssueDependencyComment(e *xorm.Session, doer *User, issue *Issue, dep
|
||||
Issue: dependentIssue,
|
||||
DependentIssueID: issue.ID,
|
||||
}
|
||||
_, err = createCommentWithNoAction(e, opts)
|
||||
_, err = createComment(e, opts)
|
||||
return
|
||||
}
|
||||
|
||||
@ -745,27 +696,7 @@ func CreateComment(opts *CreateCommentOptions) (comment *Comment, err error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
comment, err = createCommentWithNoAction(sess, opts)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if err = sess.Commit(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return comment, nil
|
||||
}
|
||||
|
||||
// CreateCommentWithNoAction creates comment of issue or commit with no action created
|
||||
func CreateCommentWithNoAction(opts *CreateCommentOptions) (comment *Comment, err error) {
|
||||
sess := x.NewSession()
|
||||
defer sess.Close()
|
||||
if err = sess.Begin(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
comment, err = createCommentWithNoAction(sess, opts)
|
||||
comment, err = createComment(sess, opts)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
Reference in New Issue
Block a user