Skip to content

[API] Expose MAX_RESPONSE_ITEMS for API #12664

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

Closed
6543 opened this issue Aug 31, 2020 · 4 comments · Fixed by #12714
Closed

[API] Expose MAX_RESPONSE_ITEMS for API #12664

6543 opened this issue Aug 31, 2020 · 4 comments · Fixed by #12714

Comments

@6543
Copy link
Member

6543 commented Aug 31, 2020

settings -> api.MaxResponseItems could differ from instance to instance

this makes it hard to implement a proper client pagination

@zeripath
Copy link
Contributor

zeripath commented Sep 4, 2020

I guess something like this would do?

From 41bc6c6c92233d0b46aa2d0bdd5bf3c311cd1abf Mon Sep 17 00:00:00 2001
From: Andrew Thornton <[email protected]>
Date: Fri, 4 Sep 2020 11:44:53 +0100
Subject: [PATCH] Add API settings to GeneralUISettings

Fix #12664

Signed-off-by: Andrew Thornton <[email protected]>
---
 modules/structs/settings.go         | 6 +++++-
 routers/api/v1/settings/settings.go | 6 +++++-
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/modules/structs/settings.go b/modules/structs/settings.go
index 4a6e0ce5a..456cfb74f 100644
--- a/modules/structs/settings.go
+++ b/modules/structs/settings.go
@@ -12,5 +12,9 @@ type GeneralRepoSettings struct {
 
 // GeneralUISettings contains global ui settings exposed by API
 type GeneralUISettings struct {
-	AllowedReactions []string `json:"allowed_reactions"`
+	AllowedReactions       []string `json:"allowed_reactions"`
+	MaxResponseItems       int      `json:"max_response_items"`
+	DefaultPagingNum       int      `json:"default_paging_num`
+	DefaultGitTreesPerPage int      `json:"default_git_trees_per_page"`
+	DefaultMaxBlobSize     int64    `json:"default_max_blob_size"`
 }
diff --git a/routers/api/v1/settings/settings.go b/routers/api/v1/settings/settings.go
index 8403a51d3..4bf750e19 100644
--- a/routers/api/v1/settings/settings.go
+++ b/routers/api/v1/settings/settings.go
@@ -23,7 +23,11 @@ func GetGeneralUISettings(ctx *context.APIContext) {
 	//   "200":
 	//     "$ref": "#/responses/GeneralUISettings"
 	ctx.JSON(http.StatusOK, api.GeneralUISettings{
-		AllowedReactions: setting.UI.Reactions,
+		AllowedReactions:       setting.UI.Reactions,
+		MaxResponseItems:       setting.API.MaxResponseItems,
+		DefaultPagingNum:       setting.API.DefaultPagingNum,
+		DefaultGitTreesPerPage: setting.API.DefaultGitTreesPerPage,
+		DefaultMaxBlobSize:     setting.API.DefaultMaxBlobSize,
 	})
 }
 
-- 
2.25.1

@zeripath
Copy link
Contributor

zeripath commented Sep 4, 2020

probably would be safe to expose all of those settings as an enemy could easily work them out?

@6543
Copy link
Member Author

6543 commented Sep 4, 2020

@zeripath not all but most

@6543
Copy link
Member Author

6543 commented Sep 4, 2020

@zeripath -> #12714

@go-gitea go-gitea locked and limited conversation to collaborators Nov 24, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants