From e864bcb0988c42f41993417bb7fae460b4749f97 Mon Sep 17 00:00:00 2001 From: Derrick Hammer Date: Sun, 17 Mar 2024 11:10:12 -0400 Subject: [PATCH] feat: add upload limit endpoint --- api/account/account.go | 7 +++++++ api/account/messages.go | 4 ++++ api/account/swagger.yaml | 17 +++++++++++++++++ 3 files changed, 28 insertions(+) diff --git a/api/account/account.go b/api/account/account.go index 2d8290f..6fa86e7 100644 --- a/api/account/account.go +++ b/api/account/account.go @@ -308,6 +308,12 @@ func (a AccountAPI) logout(c jape.Context) { account.ClearAuthCookie(c, "") } +func (a AccountAPI) uploadLimit(c jape.Context) { + c.Encode(&UploadLimitResponse{ + Limit: a.config.Config().Core.PostUploadLimit, + }) +} + func (a *AccountAPI) Routes() (*httprouter.Router, error) { loginAuthMw2fa := authMiddleware(middleware.AuthMiddlewareOptions{ Identity: a.identity, @@ -350,6 +356,7 @@ func (a *AccountAPI) Routes() (*httprouter.Router, error) { getApiJape := jape.Mux(map[string]jape.Handler{ "GET /api/auth/otp/generate": middleware.ApplyMiddlewares(a.otpGenerate, authMw, middleware.ProxyMiddleware), "GET /api/account": middleware.ApplyMiddlewares(a.accountInfo, authMw, middleware.ProxyMiddleware), + "GET /api/upload-limit": middleware.ApplyMiddlewares(a.uploadLimit, middleware.ProxyMiddleware), }) getHandler := func(c jape.Context) { diff --git a/api/account/messages.go b/api/account/messages.go index 8bfdfc4..31a83e7 100644 --- a/api/account/messages.go +++ b/api/account/messages.go @@ -53,3 +53,7 @@ type AccountInfoResponse struct { FirstName string `json:"first_name"` LastName string `json:"last_name"` } + +type UploadLimitResponse struct { + Limit uint64 `json:"limit"` +} diff --git a/api/account/swagger.yaml b/api/account/swagger.yaml index 92270cf..0a62a8d 100644 --- a/api/account/swagger.yaml +++ b/api/account/swagger.yaml @@ -148,6 +148,16 @@ paths: $ref: '#/components/schemas/AccountInfoResponse' '401': description: Unauthorized + /api/upload-limit: + get: + summary: Get the basic file upload (POST) upload limit set by the portal + responses: + '200': + description: Upload limit retrieved successfully + content: + application/json: + schema: + $ref: '#/components/schemas/UploadLimitResponse' components: schemas: @@ -254,3 +264,10 @@ components: type: string email: type: string + UploadLimitResponse: + type: object + properties: + limit: + type: number + required: + - limit