diff --git a/models/issue_comment.go b/models/issue_comment.go index 99c38bcf59cf2..f4a6b3ce13919 100644 --- a/models/issue_comment.go +++ b/models/issue_comment.go @@ -519,7 +519,7 @@ func (c *Comment) LoadPoster() error { return c.loadPoster(db.GetEngine(db.DefaultContext)) } -// LoadAttachments loads attachments +// LoadAttachments loads attachments (it never returns error, the error during `GetAttachmentsByCommentIDCtx` is ignored) func (c *Comment) LoadAttachments() error { if len(c.Attachments) > 0 { return nil diff --git a/routers/api/v1/repo/issue_comment.go b/routers/api/v1/repo/issue_comment.go index b929cec3737c4..f90028a0ab0e1 100644 --- a/routers/api/v1/repo/issue_comment.go +++ b/routers/api/v1/repo/issue_comment.go @@ -537,7 +537,9 @@ func editIssueComment(ctx *context.APIContext, form api.EditIssueCommentOption) if !ctx.IsSigned || (ctx.User.ID != comment.PosterID && !ctx.Repo.IsAdmin()) { ctx.Status(http.StatusForbidden) return - } else if comment.Type != models.CommentTypeComment { + } + + if comment.Type != models.CommentTypeComment && comment.Type != models.CommentTypeReview && comment.Type != models.CommentTypeCode { ctx.Status(http.StatusNoContent) return } diff --git a/routers/web/repo/issue.go b/routers/web/repo/issue.go index ee94e0e6d888d..9dee477537d87 100644 --- a/routers/web/repo/issue.go +++ b/routers/web/repo/issue.go @@ -1333,7 +1333,7 @@ func ViewIssue(ctx *context.Context) { return } - if comment.Type == models.CommentTypeComment { + if comment.Type == models.CommentTypeComment || comment.Type == models.CommentTypeReview { if err := comment.LoadAttachments(); err != nil { ctx.ServerError("LoadAttachments", err) return @@ -2194,7 +2194,9 @@ func UpdateCommentContent(ctx *context.Context) { if !ctx.IsSigned || (ctx.User.ID != comment.PosterID && !ctx.Repo.CanWriteIssuesOrPulls(comment.Issue.IsPull)) { ctx.Error(http.StatusForbidden) return - } else if comment.Type != models.CommentTypeComment && comment.Type != models.CommentTypeCode { + } + + if comment.Type != models.CommentTypeComment && comment.Type != models.CommentTypeReview && comment.Type != models.CommentTypeCode { ctx.Error(http.StatusNoContent) return } @@ -2212,11 +2214,9 @@ func UpdateCommentContent(ctx *context.Context) { return } - if comment.Type == models.CommentTypeComment { - if err := comment.LoadAttachments(); err != nil { - ctx.ServerError("LoadAttachments", err) - return - } + if err := comment.LoadAttachments(); err != nil { + ctx.ServerError("LoadAttachments", err) + return } // when the update request doesn't intend to update attachments (eg: change checkbox state), ignore attachment updates @@ -2404,7 +2404,9 @@ func ChangeCommentReaction(ctx *context.Context) { ctx.Error(http.StatusForbidden) return - } else if comment.Type != models.CommentTypeComment && comment.Type != models.CommentTypeCode { + } + + if comment.Type != models.CommentTypeComment && comment.Type != models.CommentTypeCode && comment.Type != models.CommentTypeReview { ctx.Error(http.StatusNoContent) return } diff --git a/templates/repo/issue/view_content/comments.tmpl b/templates/repo/issue/view_content/comments.tmpl index 3242a5b3e563a..73057248c7e20 100644 --- a/templates/repo/issue/view_content/comments.tmpl +++ b/templates/repo/issue/view_content/comments.tmpl @@ -399,7 +399,7 @@ {{else if eq .Type 22}}