-
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
[API] Add issue and comment attachments #14601
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[API] Add issue and comment attachments #14601
Conversation
Please run |
} | ||
|
||
if attach.IssueID == 0 { | ||
log.Info("User requested attachment is not in issue, attachment_id: %v", attachID) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm not sure about this logging level. I suspect it's too high but I can see you don't want people to crawl it...
The swagger spec is already there. |
Currently the linter is mad because it's detecting duplicate code. |
The code is quite similar, but not the same. |
@@ -5,6 +5,7 @@ | |||
package repo | |||
|
|||
import ( | |||
issue_service "code.gitea.io/gitea/services/issue" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
import order.
routers/repo/issue.go
Outdated
@@ -1673,17 +1673,17 @@ func UpdateIssueContent(ctx *context.Context) { | |||
return | |||
} | |||
|
|||
files := ctx.QueryStrings("files[]") | |||
if err := updateAttachments(issue, files); err != nil { | |||
ctx.ServerError("UpdateAttachments", err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return missed
29e9315
to
240fea8
Compare
It looks like a new line in the The |
The following test fails: I just run the tests locally on a MSSQL database and there were no problems. |
@andrebruch would be nice if you could resolve conflicts and adopt related changes :) |
Checking in-- how's this looking for inclusion with a 1.17.0 or a 1.16.x release? |
1.17.0 ... |
... I can have a look at finishing it - next week?!? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please follow my comments.
87fd2df
to
5bd533c
Compare
} | ||
|
||
func canUserWriteIssueCommentAttachment(ctx *context.APIContext, c *models.Comment) (success bool) { | ||
canEditComment := ctx.Doer.ID == c.PosterID || ctx.IsUserRepoAdmin() || ctx.IsUserSiteAdmin() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should check if user has a write permission to the issue.
Friendly comment to bubble up. Thanks all! |
The review comments should be followed and conflict files should be resolved. |
original contributor is not responding so everybody looking at this pull and want it ... if you have time, checkout to the pull-head and create a new branch on you own fork and submit a pull ... then fix all open mentioned issues and we will merge that one :) |
Hi @6543 @lunny @andrebruch - Thanks for the follow-ups. I'm not a Go programmer, so I don't think anyone wants to see me tackle the patch at this point ;-). Is there a tip jar or other option to financially back this feature? I have committed to writing a JIRA-to-Gitea migration tool and publish blog for others to benefit-- and we are happy to kick in money for a Gitea/Go programmer to finish out this PR. Also, this feature will be needed by any organization that wants to use Gitea and maintain automated security compliance (SOC2, ISO27001, etc). Thanks! |
Thank you very much! You can contribute in bountysource for #3690 but even that I cannot guarantee this could be resolved in a short days. |
@lunny This looks like the Bountysource link for #3690 and I contributed $100 (USD). How much $ do you think to have it completed by December 31st? |
Let's continue in #21783 |
Close #14601 Fix #3690 Revive of #14601. Updated to current code, cleanup and added more read/write checks. Signed-off-by: Andrew Thornton <art27@cantab.net> Signed-off-by: Andre Bruch <ab@andrebruch.com> Co-authored-by: zeripath <art27@cantab.net> Co-authored-by: 6543 <6543@obermui.de> Co-authored-by: Norwin <git@nroo.de> Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
The following API routes have been added:
Issues
GET /repos/{owner}/{repo}/issues/assets/{attachment_id}
GET /repos/{owner}/{repo}/issues/{index}/assets
POST /repos/{owner}/{repo}/issues/{index}/assets
PATCH /repos/{owner}/{repo}/issues/assets/{attachment_id}
DELETE /repos/{owner}/{repo}/issues/assets/{attachment_id}
Comments
GET /repos/{owner}/{repo}/issues/comments/assets/{attachment_id}
GET /repos/{owner}/{repo}/issues/comments/{id}/assets
POST /repos/{owner}/{repo}/issues/comments/{id}/assets
PATCH /repos/{owner}/{repo}/issues/comments/assets/{attachment_id}
DELETE /repos/{owner}/{repo}/issues/comments/assets/{attachment_id}
close #3690