diff options
author | 6543 <6543@obermui.de> | 2020-10-17 06:23:08 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-10-17 00:23:08 -0400 |
commit | d453533beb197d25b25530dc5f0e3c3c0742d8d1 (patch) | |
tree | 6d66e1163333344d91af63e9ab50a82367470b8f /routers/api/v1/repo/release_attachment.go | |
parent | 131278ff222f1a8580f20e6bbdff405341403042 (diff) | |
download | gitea-d453533beb197d25b25530dc5f0e3c3c0742d8d1.tar.gz gitea-d453533beb197d25b25530dc5f0e3c3c0742d8d1.zip |
[Refactor] Move APIFormat functions into convert package (#12856)
* USER APIFormat -> ToUser
* Migrate more and mark APIFormat deprecated
* models.Comment APIFormat() -> convert.ToComment
* models.Release APIFormat() -> convert.ToRelease
* models.Attachments APIFormat() -> convert.ToReleaseAttachments
* models.CommitStatus APIFormat() -> convert.ToCommitStatus
* finish migration to convert.ToUser
* Move Test
* Imprufe Test
* fix test
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
Diffstat (limited to 'routers/api/v1/repo/release_attachment.go')
-rw-r--r-- | routers/api/v1/repo/release_attachment.go | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/routers/api/v1/repo/release_attachment.go b/routers/api/v1/repo/release_attachment.go index f352c10829..51e1b160da 100644 --- a/routers/api/v1/repo/release_attachment.go +++ b/routers/api/v1/repo/release_attachment.go @@ -9,6 +9,7 @@ import ( "code.gitea.io/gitea/models" "code.gitea.io/gitea/modules/context" + "code.gitea.io/gitea/modules/convert" "code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/setting" api "code.gitea.io/gitea/modules/structs" @@ -62,7 +63,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, attach.APIFormat()) + ctx.JSON(http.StatusOK, convert.ToReleaseAttachment(attach)) } // ListReleaseAttachments lists all attachments of the release @@ -107,7 +108,7 @@ func ListReleaseAttachments(ctx *context.APIContext) { ctx.Error(http.StatusInternalServerError, "LoadAttributes", err) return } - ctx.JSON(http.StatusOK, release.APIFormat().Attachments) + ctx.JSON(http.StatusOK, convert.ToRelease(release).Attachments) } // CreateReleaseAttachment creates an attachment and saves the given file @@ -203,7 +204,7 @@ func CreateReleaseAttachment(ctx *context.APIContext) { return } - ctx.JSON(http.StatusCreated, attach.APIFormat()) + ctx.JSON(http.StatusCreated, convert.ToReleaseAttachment(attach)) } // EditReleaseAttachment updates the given attachment @@ -267,7 +268,7 @@ func EditReleaseAttachment(ctx *context.APIContext, form api.EditAttachmentOptio if err := models.UpdateAttachment(attach); err != nil { ctx.Error(http.StatusInternalServerError, "UpdateAttachment", attach) } - ctx.JSON(http.StatusCreated, attach.APIFormat()) + ctx.JSON(http.StatusCreated, convert.ToReleaseAttachment(attach)) } // DeleteReleaseAttachment delete a given attachment |