* Send attachments too. * Use tasklist flag. * use action="ignoreAttachments" instead of "tasklist" * Use boolean parameter. * when the update request doesn't intend to update attachments (eg: change checkbox state), ignore attachment updates (#16762) Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
This commit is contained in:
		
							parent
							
								
									5ceff8fda2
								
							
						
					
					
						commit
						0840a508b4
					
				
					 2 changed files with 21 additions and 16 deletions
				
			
		|  | @ -1728,11 +1728,13 @@ func UpdateIssueContent(ctx *context.Context) { | |||
| 		return | ||||
| 	} | ||||
| 
 | ||||
| 	files := ctx.QueryStrings("files[]") | ||||
| 	if err := updateAttachments(issue, files); err != nil { | ||||
| 	// when update the request doesn't intend to update attachments (eg: change checkbox state), ignore attachment updates
 | ||||
| 	if !ctx.QueryBool("ignore_attachments") { | ||||
| 		if err := updateAttachments(issue, ctx.QueryStrings("files[]")); err != nil { | ||||
| 			ctx.ServerError("UpdateAttachments", err) | ||||
| 			return | ||||
| 		} | ||||
| 	} | ||||
| 
 | ||||
| 	content, err := markdown.RenderString(&markup.RenderContext{ | ||||
| 		URLPrefix: ctx.Query("context"), | ||||
|  | @ -2128,13 +2130,6 @@ func UpdateCommentContent(ctx *context.Context) { | |||
| 		return | ||||
| 	} | ||||
| 
 | ||||
| 	if comment.Type == models.CommentTypeComment { | ||||
| 		if err := comment.LoadAttachments(); err != nil { | ||||
| 			ctx.ServerError("LoadAttachments", err) | ||||
| 			return | ||||
| 		} | ||||
| 	} | ||||
| 
 | ||||
| 	if !ctx.IsSigned || (ctx.User.ID != comment.PosterID && !ctx.Repo.CanWriteIssuesOrPulls(comment.Issue.IsPull)) { | ||||
| 		ctx.Error(http.StatusForbidden) | ||||
| 		return | ||||
|  | @ -2156,11 +2151,20 @@ func UpdateCommentContent(ctx *context.Context) { | |||
| 		return | ||||
| 	} | ||||
| 
 | ||||
| 	files := ctx.QueryStrings("files[]") | ||||
| 	if err := updateAttachments(comment, files); err != nil { | ||||
| 	if comment.Type == models.CommentTypeComment { | ||||
| 		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
 | ||||
| 	if !ctx.QueryBool("ignore_attachments") { | ||||
| 		if err := updateAttachments(comment, ctx.QueryStrings("files[]")); err != nil { | ||||
| 			ctx.ServerError("UpdateAttachments", err) | ||||
| 			return | ||||
| 		} | ||||
| 	} | ||||
| 
 | ||||
| 	content, err := markdown.RenderString(&markup.RenderContext{ | ||||
| 		URLPrefix: ctx.Query("context"), | ||||
|  |  | |||
|  | @ -46,9 +46,10 @@ export function initMarkupTasklist() { | |||
|           const {updateUrl, context} = editContentZone.dataset; | ||||
| 
 | ||||
|           await $.post(updateUrl, { | ||||
|             ignore_attachments: true, | ||||
|             _csrf: window.config.csrf, | ||||
|             content: newContent, | ||||
|             context, | ||||
|             context | ||||
|           }); | ||||
| 
 | ||||
|           rawContent.textContent = newContent; | ||||
|  |  | |||
		Loading…
	
		Reference in a new issue