|
|
@ -495,7 +495,7 @@ func (c *Comment) CodeCommentURL() string { |
|
|
|
return fmt.Sprintf("%s/files#%s", c.Issue.HTMLURL(), c.HashTag()) |
|
|
|
return fmt.Sprintf("%s/files#%s", c.Issue.HTMLURL(), c.HashTag()) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func createComment(e *xorm.Session, opts *CreateCommentOptions) (_ *Comment, err error) { |
|
|
|
func createCommentWithNoAction(e *xorm.Session, opts *CreateCommentOptions) (_ *Comment, err error) { |
|
|
|
var LabelID int64 |
|
|
|
var LabelID int64 |
|
|
|
if opts.Label != nil { |
|
|
|
if opts.Label != nil { |
|
|
|
LabelID = opts.Label.ID |
|
|
|
LabelID = opts.Label.ID |
|
|
@ -539,12 +539,6 @@ func createComment(e *xorm.Session, opts *CreateCommentOptions) (_ *Comment, err |
|
|
|
return nil, err |
|
|
|
return nil, err |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if !opts.NoAction { |
|
|
|
|
|
|
|
if err = sendCreateCommentAction(e, opts, comment); err != nil { |
|
|
|
|
|
|
|
return nil, err |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if err = comment.addCrossReferences(e, opts.Doer, false); err != nil { |
|
|
|
if err = comment.addCrossReferences(e, opts.Doer, false); err != nil { |
|
|
|
return nil, err |
|
|
|
return nil, err |
|
|
|
} |
|
|
|
} |
|
|
@ -651,19 +645,7 @@ func sendCreateCommentAction(e *xorm.Session, opts *CreateCommentOptions, commen |
|
|
|
return nil |
|
|
|
return nil |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func createMilestoneComment(e *xorm.Session, doer *User, repo *Repository, issue *Issue, oldMilestoneID, milestoneID int64) (*Comment, error) { |
|
|
|
|
|
|
|
return createComment(e, &CreateCommentOptions{ |
|
|
|
|
|
|
|
Type: CommentTypeMilestone, |
|
|
|
|
|
|
|
Doer: doer, |
|
|
|
|
|
|
|
Repo: repo, |
|
|
|
|
|
|
|
Issue: issue, |
|
|
|
|
|
|
|
OldMilestoneID: oldMilestoneID, |
|
|
|
|
|
|
|
MilestoneID: milestoneID, |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func createDeadlineComment(e *xorm.Session, doer *User, issue *Issue, newDeadlineUnix timeutil.TimeStamp) (*Comment, error) { |
|
|
|
func createDeadlineComment(e *xorm.Session, doer *User, issue *Issue, newDeadlineUnix timeutil.TimeStamp) (*Comment, error) { |
|
|
|
|
|
|
|
|
|
|
|
var content string |
|
|
|
var content string |
|
|
|
var commentType CommentType |
|
|
|
var commentType CommentType |
|
|
|
|
|
|
|
|
|
|
@ -685,13 +667,18 @@ func createDeadlineComment(e *xorm.Session, doer *User, issue *Issue, newDeadlin |
|
|
|
return nil, err |
|
|
|
return nil, err |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return createComment(e, &CreateCommentOptions{ |
|
|
|
var opts = &CreateCommentOptions{ |
|
|
|
Type: commentType, |
|
|
|
Type: commentType, |
|
|
|
Doer: doer, |
|
|
|
Doer: doer, |
|
|
|
Repo: issue.Repo, |
|
|
|
Repo: issue.Repo, |
|
|
|
Issue: issue, |
|
|
|
Issue: issue, |
|
|
|
Content: content, |
|
|
|
Content: content, |
|
|
|
}) |
|
|
|
} |
|
|
|
|
|
|
|
comment, err := createCommentWithNoAction(e, opts) |
|
|
|
|
|
|
|
if err != nil { |
|
|
|
|
|
|
|
return nil, err |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return comment, sendCreateCommentAction(e, opts, comment) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Creates issue dependency comment
|
|
|
|
// Creates issue dependency comment
|
|
|
@ -705,27 +692,35 @@ func createIssueDependencyComment(e *xorm.Session, doer *User, issue *Issue, dep |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Make two comments, one in each issue
|
|
|
|
// Make two comments, one in each issue
|
|
|
|
_, err = createComment(e, &CreateCommentOptions{ |
|
|
|
var opts = &CreateCommentOptions{ |
|
|
|
Type: cType, |
|
|
|
Type: cType, |
|
|
|
Doer: doer, |
|
|
|
Doer: doer, |
|
|
|
Repo: issue.Repo, |
|
|
|
Repo: issue.Repo, |
|
|
|
Issue: issue, |
|
|
|
Issue: issue, |
|
|
|
DependentIssueID: dependentIssue.ID, |
|
|
|
DependentIssueID: dependentIssue.ID, |
|
|
|
}) |
|
|
|
} |
|
|
|
|
|
|
|
comment, err := createCommentWithNoAction(e, opts) |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if err = sendCreateCommentAction(e, opts, comment); err != nil { |
|
|
|
|
|
|
|
return err |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
_, err = createComment(e, &CreateCommentOptions{ |
|
|
|
opts = &CreateCommentOptions{ |
|
|
|
Type: cType, |
|
|
|
Type: cType, |
|
|
|
Doer: doer, |
|
|
|
Doer: doer, |
|
|
|
Repo: issue.Repo, |
|
|
|
Repo: issue.Repo, |
|
|
|
Issue: dependentIssue, |
|
|
|
Issue: dependentIssue, |
|
|
|
DependentIssueID: issue.ID, |
|
|
|
DependentIssueID: issue.ID, |
|
|
|
}) |
|
|
|
} |
|
|
|
|
|
|
|
comment, err = createCommentWithNoAction(e, opts) |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if err = sendCreateCommentAction(e, opts, comment); err != nil { |
|
|
|
|
|
|
|
return err |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
@ -758,7 +753,6 @@ type CreateCommentOptions struct { |
|
|
|
RefCommentID int64 |
|
|
|
RefCommentID int64 |
|
|
|
RefAction references.XRefAction |
|
|
|
RefAction references.XRefAction |
|
|
|
RefIsPull bool |
|
|
|
RefIsPull bool |
|
|
|
NoAction bool |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// CreateComment creates comment of issue or commit.
|
|
|
|
// CreateComment creates comment of issue or commit.
|
|
|
@ -769,7 +763,31 @@ func CreateComment(opts *CreateCommentOptions) (comment *Comment, err error) { |
|
|
|
return nil, err |
|
|
|
return nil, err |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
comment, err = createComment(sess, opts) |
|
|
|
comment, err = createCommentWithNoAction(sess, opts) |
|
|
|
|
|
|
|
if err != nil { |
|
|
|
|
|
|
|
return nil, err |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if err = sendCreateCommentAction(sess, opts, comment); 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) |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
return nil, err |
|
|
|
return nil, err |
|
|
|
} |
|
|
|
} |
|
|
|