mirror of
https://github.com/go-gitea/gitea.git
synced 2025-05-12 00:01:32 -04:00
Improvements
This commit is contained in:
parent
11f43139f5
commit
fb83abe39c
@ -239,20 +239,31 @@ func UpdateCommentContent(ctx *context.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
oldContent := comment.Content
|
||||
newContent := ctx.FormString("content")
|
||||
contentVersion := ctx.FormInt("content_version")
|
||||
if newContent == oldContent {
|
||||
if newContent == comment.Content {
|
||||
if contentVersion != comment.ContentVersion {
|
||||
ctx.JSONError(ctx.Tr("repo.comments.edit.already_changed"))
|
||||
return
|
||||
}
|
||||
|
||||
if err := comment.LoadAttachments(ctx); err != nil {
|
||||
ctx.ServerError("LoadAttachments", err)
|
||||
return
|
||||
}
|
||||
|
||||
ctx.JSON(http.StatusOK, map[string]any{
|
||||
"content": oldContent,
|
||||
"content": comment.Content,
|
||||
"contentVersion": comment.ContentVersion,
|
||||
"attachments": attachmentsHTML(ctx, comment.Attachments, oldContent),
|
||||
"attachments": attachmentsHTML(ctx, comment.Attachments, comment.Content),
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
// allow to save empty content
|
||||
comment.Content = newContent
|
||||
oldContent := comment.Content
|
||||
|
||||
if err = issue_service.UpdateComment(ctx, comment, contentVersion, ctx.Doer, oldContent); err != nil {
|
||||
if errors.Is(err, user_model.ErrBlockedUser) {
|
||||
ctx.JSONError(ctx.Tr("repo.issues.comment.blocked_user"))
|
||||
|
@ -300,8 +300,8 @@ func Test_WebhookIssueComment(t *testing.T) {
|
||||
session.MakeRequest(t, req, http.StatusOK)
|
||||
|
||||
// 3. validate the webhook is not triggered because no content change
|
||||
assert.Equal(t, "", triggeredEvent)
|
||||
assert.Len(t, payloads, 0)
|
||||
assert.Empty(t, triggeredEvent)
|
||||
assert.Zero(t, payloads)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user