|
|
@ -855,6 +855,9 @@ func updateCommentInfos(ctx context.Context, opts *CreateCommentOptions, comment |
|
|
|
// Check comment type.
|
|
|
|
// Check comment type.
|
|
|
|
switch opts.Type { |
|
|
|
switch opts.Type { |
|
|
|
case CommentTypeCode: |
|
|
|
case CommentTypeCode: |
|
|
|
|
|
|
|
if err = updateAttachments(ctx, opts, comment); err != nil { |
|
|
|
|
|
|
|
return err |
|
|
|
|
|
|
|
} |
|
|
|
if comment.ReviewID != 0 { |
|
|
|
if comment.ReviewID != 0 { |
|
|
|
if comment.Review == nil { |
|
|
|
if comment.Review == nil { |
|
|
|
if err := comment.loadReview(ctx); err != nil { |
|
|
|
if err := comment.loadReview(ctx); err != nil { |
|
|
@ -872,12 +875,23 @@ func updateCommentInfos(ctx context.Context, opts *CreateCommentOptions, comment |
|
|
|
} |
|
|
|
} |
|
|
|
fallthrough |
|
|
|
fallthrough |
|
|
|
case CommentTypeReview: |
|
|
|
case CommentTypeReview: |
|
|
|
// Check attachments
|
|
|
|
if err = updateAttachments(ctx, opts, comment); err != nil { |
|
|
|
|
|
|
|
return err |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
case CommentTypeReopen, CommentTypeClose: |
|
|
|
|
|
|
|
if err = repo_model.UpdateRepoIssueNumbers(ctx, opts.Issue.RepoID, opts.Issue.IsPull, true); err != nil { |
|
|
|
|
|
|
|
return err |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// update the issue's updated_unix column
|
|
|
|
|
|
|
|
return UpdateIssueCols(ctx, opts.Issue, "updated_unix") |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func updateAttachments(ctx context.Context, opts *CreateCommentOptions, comment *Comment) error { |
|
|
|
attachments, err := repo_model.GetAttachmentsByUUIDs(ctx, opts.Attachments) |
|
|
|
attachments, err := repo_model.GetAttachmentsByUUIDs(ctx, opts.Attachments) |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
return fmt.Errorf("getAttachmentsByUUIDs [uuids: %v]: %w", opts.Attachments, err) |
|
|
|
return fmt.Errorf("getAttachmentsByUUIDs [uuids: %v]: %w", opts.Attachments, err) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
for i := range attachments { |
|
|
|
for i := range attachments { |
|
|
|
attachments[i].IssueID = opts.Issue.ID |
|
|
|
attachments[i].IssueID = opts.Issue.ID |
|
|
|
attachments[i].CommentID = comment.ID |
|
|
|
attachments[i].CommentID = comment.ID |
|
|
@ -886,15 +900,8 @@ func updateCommentInfos(ctx context.Context, opts *CreateCommentOptions, comment |
|
|
|
return fmt.Errorf("update attachment [%d]: %w", attachments[i].ID, err) |
|
|
|
return fmt.Errorf("update attachment [%d]: %w", attachments[i].ID, err) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
comment.Attachments = attachments |
|
|
|
comment.Attachments = attachments |
|
|
|
case CommentTypeReopen, CommentTypeClose: |
|
|
|
return nil |
|
|
|
if err = repo_model.UpdateRepoIssueNumbers(ctx, opts.Issue.RepoID, opts.Issue.IsPull, true); err != nil { |
|
|
|
|
|
|
|
return err |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// update the issue's updated_unix column
|
|
|
|
|
|
|
|
return UpdateIssueCols(ctx, opts.Issue, "updated_unix") |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func createDeadlineComment(ctx context.Context, doer *user_model.User, issue *Issue, newDeadlineUnix timeutil.TimeStamp) (*Comment, error) { |
|
|
|
func createDeadlineComment(ctx context.Context, doer *user_model.User, issue *Issue, newDeadlineUnix timeutil.TimeStamp) (*Comment, error) { |
|
|
|