From 18b84b173ebfc995c319be57f399ca7f7c85de95 Mon Sep 17 00:00:00 2001 From: KN4CK3R Date: Fri, 20 Aug 2021 12:31:00 +0200 Subject: [PATCH 1/4] Send attachments too. --- web_src/js/markup/tasklist.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/web_src/js/markup/tasklist.js b/web_src/js/markup/tasklist.js index 24b29ddb7afc..23ebf4eca729 100644 --- a/web_src/js/markup/tasklist.js +++ b/web_src/js/markup/tasklist.js @@ -43,12 +43,20 @@ export function initMarkupTasklist() { try { const editContentZone = container.querySelector('.edit-content-zone'); - const {updateUrl, context} = editContentZone.dataset; + const {updateUrl, context, attachmentUrl} = editContentZone.dataset; + + const resp = await fetch(attachmentUrl); + const attachments = await resp.json(); + const files = []; + for (const attachment of attachments) { + files.push(attachment.uuid); + } await $.post(updateUrl, { _csrf: window.config.csrf, content: newContent, context, + files }); rawContent.textContent = newContent; From ebf5fa4f262a3ec062bcce6679d6977f08fb5a9e Mon Sep 17 00:00:00 2001 From: KN4CK3R Date: Fri, 20 Aug 2021 14:46:33 +0000 Subject: [PATCH 2/4] Use tasklist flag. --- routers/web/repo/issue.go | 18 +++++++++++------- web_src/js/markup/tasklist.js | 13 +++---------- 2 files changed, 14 insertions(+), 17 deletions(-) diff --git a/routers/web/repo/issue.go b/routers/web/repo/issue.go index ff83be441026..fb01936a5f20 100644 --- a/routers/web/repo/issue.go +++ b/routers/web/repo/issue.go @@ -2127,13 +2127,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 @@ -2155,6 +2148,17 @@ func UpdateCommentContent(ctx *context.Context) { return } + if ctx.FormString("action") == "tasklist" { + return + } + + if comment.Type == models.CommentTypeComment { + if err := comment.LoadAttachments(); err != nil { + ctx.ServerError("LoadAttachments", err) + return + } + } + if err := updateAttachments(comment, ctx.FormStrings("files[]")); err != nil { ctx.ServerError("UpdateAttachments", err) return diff --git a/web_src/js/markup/tasklist.js b/web_src/js/markup/tasklist.js index 23ebf4eca729..0686a6c660ed 100644 --- a/web_src/js/markup/tasklist.js +++ b/web_src/js/markup/tasklist.js @@ -43,20 +43,13 @@ export function initMarkupTasklist() { try { const editContentZone = container.querySelector('.edit-content-zone'); - const {updateUrl, context, attachmentUrl} = editContentZone.dataset; - - const resp = await fetch(attachmentUrl); - const attachments = await resp.json(); - const files = []; - for (const attachment of attachments) { - files.push(attachment.uuid); - } + const {updateUrl, context} = editContentZone.dataset; await $.post(updateUrl, { + action: 'tasklist', _csrf: window.config.csrf, content: newContent, - context, - files + context }); rawContent.textContent = newContent; From 43b6fae10313991136d1f28f93c0f0ec700203c9 Mon Sep 17 00:00:00 2001 From: zeripath Date: Fri, 20 Aug 2021 18:38:48 +0100 Subject: [PATCH 3/4] use action="ignoreAttachments" instead of "tasklist" --- routers/web/repo/issue.go | 2 +- web_src/js/markup/tasklist.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/routers/web/repo/issue.go b/routers/web/repo/issue.go index fb01936a5f20..1afbc26ea910 100644 --- a/routers/web/repo/issue.go +++ b/routers/web/repo/issue.go @@ -2148,7 +2148,7 @@ func UpdateCommentContent(ctx *context.Context) { return } - if ctx.FormString("action") == "tasklist" { + if ctx.FormString("action") == "ignoreAttachments" { return } diff --git a/web_src/js/markup/tasklist.js b/web_src/js/markup/tasklist.js index 0686a6c660ed..690595f60791 100644 --- a/web_src/js/markup/tasklist.js +++ b/web_src/js/markup/tasklist.js @@ -46,7 +46,7 @@ export function initMarkupTasklist() { const {updateUrl, context} = editContentZone.dataset; await $.post(updateUrl, { - action: 'tasklist', + action: 'ignoreAttachments', _csrf: window.config.csrf, content: newContent, context From 0905b33991e197e8a318b61d05731efa39f3e94e Mon Sep 17 00:00:00 2001 From: KN4CK3R Date: Fri, 20 Aug 2021 18:34:24 +0000 Subject: [PATCH 4/4] Use boolean parameter. --- routers/web/repo/issue.go | 2 +- web_src/js/markup/tasklist.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/routers/web/repo/issue.go b/routers/web/repo/issue.go index 1afbc26ea910..56561c6168d6 100644 --- a/routers/web/repo/issue.go +++ b/routers/web/repo/issue.go @@ -2148,7 +2148,7 @@ func UpdateCommentContent(ctx *context.Context) { return } - if ctx.FormString("action") == "ignoreAttachments" { + if ctx.FormBool("ignore_attachments") { return } diff --git a/web_src/js/markup/tasklist.js b/web_src/js/markup/tasklist.js index 690595f60791..ea1a1f824a13 100644 --- a/web_src/js/markup/tasklist.js +++ b/web_src/js/markup/tasklist.js @@ -46,7 +46,7 @@ export function initMarkupTasklist() { const {updateUrl, context} = editContentZone.dataset; await $.post(updateUrl, { - action: 'ignoreAttachments', + ignore_attachments: true, _csrf: window.config.csrf, content: newContent, context