1
0
Fork 0
forked from forgejo/forgejo

[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.

(cherry picked from commit 490646302e)
(cherry picked from commit d3d88667cb)
This commit is contained in:
Gusted 2023-08-22 12:22:03 +02:00 committed by Earl Warren
parent 856a2e0903
commit 6818de13a9
No known key found for this signature in database
GPG key ID: 0579CB2928A78A00
3 changed files with 63 additions and 1 deletions

View file

@ -3065,7 +3065,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
}