summaryrefslogtreecommitdiffstats
path: root/routers/api/v1/repo/release_attachment.go
diff options
context:
space:
mode:
authorGiteabot <teabot@gitea.io>2023-07-10 08:56:16 -0400
committerGitHub <noreply@github.com>2023-07-10 12:56:16 +0000
commit2b79d3fd520c4f8f9d9e61894f3fcca6c2258efe (patch)
tree9ba8d52ed7a149a7ff51af9874a5850d2427a4c7 /routers/api/v1/repo/release_attachment.go
parentb4460cf54147e22c3f0657fbfdb680aec52a0210 (diff)
downloadgitea-2b79d3fd520c4f8f9d9e61894f3fcca6c2258efe.tar.gz
gitea-2b79d3fd520c4f8f9d9e61894f3fcca6c2258efe.zip
For API attachments, use API URL (#25639) (#25814)
Backport #25639 by @lunny Fix #25257 Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Diffstat (limited to 'routers/api/v1/repo/release_attachment.go')
-rw-r--r--routers/api/v1/repo/release_attachment.go14
1 files changed, 7 insertions, 7 deletions
diff --git a/routers/api/v1/repo/release_attachment.go b/routers/api/v1/repo/release_attachment.go
index 305b2808df..a7d73acceb 100644
--- a/routers/api/v1/repo/release_attachment.go
+++ b/routers/api/v1/repo/release_attachment.go
@@ -52,7 +52,7 @@ func GetReleaseAttachment(ctx *context.APIContext) {
// "$ref": "#/responses/Attachment"
releaseID := ctx.ParamsInt64(":id")
- attachID := ctx.ParamsInt64(":asset")
+ attachID := ctx.ParamsInt64(":attachment_id")
attach, err := repo_model.GetAttachmentByID(ctx, attachID)
if err != nil {
if repo_model.IsErrAttachmentNotExist(err) {
@@ -68,7 +68,7 @@ func GetReleaseAttachment(ctx *context.APIContext) {
return
}
// FIXME Should prove the existence of the given repo, but results in unnecessary database requests
- ctx.JSON(http.StatusOK, convert.ToAttachment(attach))
+ ctx.JSON(http.StatusOK, convert.ToAPIAttachment(ctx.Repo.Repository, attach))
}
// ListReleaseAttachments lists all attachments of the release
@@ -117,7 +117,7 @@ func ListReleaseAttachments(ctx *context.APIContext) {
ctx.Error(http.StatusInternalServerError, "LoadAttributes", err)
return
}
- ctx.JSON(http.StatusOK, convert.ToRelease(ctx, release).Attachments)
+ ctx.JSON(http.StatusOK, convert.ToAPIRelease(ctx, ctx.Repo.Repository, release).Attachments)
}
// CreateReleaseAttachment creates an attachment and saves the given file
@@ -209,7 +209,7 @@ func CreateReleaseAttachment(ctx *context.APIContext) {
return
}
- ctx.JSON(http.StatusCreated, convert.ToAttachment(attach))
+ ctx.JSON(http.StatusCreated, convert.ToAPIAttachment(ctx.Repo.Repository, attach))
}
// EditReleaseAttachment updates the given attachment
@@ -256,7 +256,7 @@ func EditReleaseAttachment(ctx *context.APIContext) {
// Check if release exists an load release
releaseID := ctx.ParamsInt64(":id")
- attachID := ctx.ParamsInt64(":asset")
+ attachID := ctx.ParamsInt64(":attachment_id")
attach, err := repo_model.GetAttachmentByID(ctx, attachID)
if err != nil {
if repo_model.IsErrAttachmentNotExist(err) {
@@ -279,7 +279,7 @@ func EditReleaseAttachment(ctx *context.APIContext) {
if err := repo_model.UpdateAttachment(ctx, attach); err != nil {
ctx.Error(http.StatusInternalServerError, "UpdateAttachment", attach)
}
- ctx.JSON(http.StatusCreated, convert.ToAttachment(attach))
+ ctx.JSON(http.StatusCreated, convert.ToAPIAttachment(ctx.Repo.Repository, attach))
}
// DeleteReleaseAttachment delete a given attachment
@@ -318,7 +318,7 @@ func DeleteReleaseAttachment(ctx *context.APIContext) {
// Check if release exists an load release
releaseID := ctx.ParamsInt64(":id")
- attachID := ctx.ParamsInt64(":asset")
+ attachID := ctx.ParamsInt64(":attachment_id")
attach, err := repo_model.GetAttachmentByID(ctx, attachID)
if err != nil {
if repo_model.IsErrAttachmentNotExist(err) {