[MODERATION] Show graceful error on comment creation

- When someone is blocked by the repository owner or issue poster and
try to comment on that issue, they get shown a graceful error.
- Adds integration test.
This commit is contained in:
Gusted 2023-08-22 12:22:03 +02:00
parent f911dc4025
commit 490646302e
No known key found for this signature in database
GPG key ID: FD821B732837125F
3 changed files with 63 additions and 1 deletions

View file

@ -3034,7 +3034,11 @@ func NewComment(ctx *context.Context) {
comment, err := issue_service.CreateIssueComment(ctx, ctx.Doer, ctx.Repo.Repository, issue, form.Content, attachments)
if err != nil {
ctx.ServerError("CreateIssueComment", err)
if errors.Is(err, user_model.ErrBlockedByUser) {
ctx.Flash.Error(ctx.Tr("repo.issues.comment.blocked_by_user"))
} else {
ctx.ServerError("CreateIssueComment", err)
}
return
}