@@ -241,38 +241,26 @@ func UpdateCommentContent(ctx *context.Context) {
241
241
242
242
newContent := ctx .FormString ("content" )
243
243
contentVersion := ctx .FormInt ("content_version" )
244
- if newContent == comment .Content {
245
- if contentVersion != comment .ContentVersion {
246
- ctx .JSONError (ctx .Tr ("repo.comments.edit.already_changed" ))
247
- return
248
- }
249
-
250
- if err := comment .LoadAttachments (ctx ); err != nil {
251
- ctx .ServerError ("LoadAttachments" , err )
252
- return
253
- }
254
-
255
- ctx .JSON (http .StatusOK , map [string ]any {
256
- "content" : comment .Content ,
257
- "contentVersion" : comment .ContentVersion ,
258
- "attachments" : attachmentsHTML (ctx , comment .Attachments , comment .Content ),
259
- })
244
+ if contentVersion != comment .ContentVersion {
245
+ ctx .JSONError (ctx .Tr ("repo.comments.edit.already_changed" ))
260
246
return
261
247
}
262
248
263
- // allow to save empty content
264
- comment .Content = newContent
265
- oldContent := comment .Content
249
+ if newContent != comment .Content {
250
+ // allow to save empty content
251
+ oldContent := comment .Content
252
+ comment .Content = newContent
266
253
267
- if err = issue_service .UpdateComment (ctx , comment , contentVersion , ctx .Doer , oldContent ); err != nil {
268
- if errors .Is (err , user_model .ErrBlockedUser ) {
269
- ctx .JSONError (ctx .Tr ("repo.issues.comment.blocked_user" ))
270
- } else if errors .Is (err , issues_model .ErrCommentAlreadyChanged ) {
271
- ctx .JSONError (ctx .Tr ("repo.comments.edit.already_changed" ))
272
- } else {
273
- ctx .ServerError ("UpdateComment" , err )
254
+ if err = issue_service .UpdateComment (ctx , comment , contentVersion , ctx .Doer , oldContent ); err != nil {
255
+ if errors .Is (err , user_model .ErrBlockedUser ) {
256
+ ctx .JSONError (ctx .Tr ("repo.issues.comment.blocked_user" ))
257
+ } else if errors .Is (err , issues_model .ErrCommentAlreadyChanged ) {
258
+ ctx .JSONError (ctx .Tr ("repo.comments.edit.already_changed" ))
259
+ } else {
260
+ ctx .ServerError ("UpdateComment" , err )
261
+ }
262
+ return
274
263
}
275
- return
276
264
}
277
265
278
266
if err := comment .LoadAttachments (ctx ); err != nil {
0 commit comments