summaryrefslogtreecommitdiffstats
path: root/routers/api
diff options
context:
space:
mode:
author6543 <6543@obermui.de>2020-06-04 11:16:53 +0200
committerGitHub <noreply@github.com>2020-06-04 12:16:53 +0300
commitb534a5164fe13dc41aa2996239c2dff4f109dee0 (patch)
treed790711e74321cb0344eafa33f2eeb594e68cb07 /routers/api
parent2842f6cf42ab984a7f533a51a050425ebaa2313b (diff)
downloadgitea-b534a5164fe13dc41aa2996239c2dff4f109dee0.tar.gz
gitea-b534a5164fe13dc41aa2996239c2dff4f109dee0.zip
[API] Expose allowed Reactions (#11735)
* [API] Expose allowed Reactions * dont be in soutch a rush * add TEST * use ElementsMatch Co-authored-by: Lauris BH <lauris@nix.lv>
Diffstat (limited to 'routers/api')
-rw-r--r--routers/api/v1/api.go3
-rw-r--r--routers/api/v1/misc/settings.go23
-rw-r--r--routers/api/v1/swagger/misc.go7
3 files changed, 33 insertions, 0 deletions
diff --git a/routers/api/v1/api.go b/routers/api/v1/api.go
index 2eb39f6070..0f8a0326e9 100644
--- a/routers/api/v1/api.go
+++ b/routers/api/v1/api.go
@@ -512,6 +512,9 @@ func RegisterRoutes(m *macaron.Macaron) {
m.Get("/signing-key.gpg", misc.SigningKey)
m.Post("/markdown", bind(api.MarkdownOption{}), misc.Markdown)
m.Post("/markdown/raw", misc.MarkdownRaw)
+ m.Group("/settings", func() {
+ m.Get("/allowed_reactions", misc.SettingGetsAllowedReactions)
+ })
// Notifications
m.Group("/notifications", func() {
diff --git a/routers/api/v1/misc/settings.go b/routers/api/v1/misc/settings.go
new file mode 100644
index 0000000000..11c7eef726
--- /dev/null
+++ b/routers/api/v1/misc/settings.go
@@ -0,0 +1,23 @@
+// Copyright 2020 The Gitea Authors. All rights reserved.
+// Use of this source code is governed by a MIT-style
+// license that can be found in the LICENSE file.
+
+package misc
+
+import (
+ "code.gitea.io/gitea/modules/context"
+ "code.gitea.io/gitea/modules/setting"
+)
+
+// SettingGetsAllowedReactions return allowed reactions
+func SettingGetsAllowedReactions(ctx *context.APIContext) {
+ // swagger:operation GET /settings/allowed_reactions miscellaneous getAllowedReactions
+ // ---
+ // summary: Returns string array of allowed reactions
+ // produces:
+ // - application/json
+ // responses:
+ // "200":
+ // "$ref": "#/responses/StringSlice"
+ ctx.JSON(200, setting.UI.Reactions)
+}
diff --git a/routers/api/v1/swagger/misc.go b/routers/api/v1/swagger/misc.go
index 9fd0ab5b00..1d3c257efa 100644
--- a/routers/api/v1/swagger/misc.go
+++ b/routers/api/v1/swagger/misc.go
@@ -14,3 +14,10 @@ type swaggerResponseServerVersion struct {
// in:body
Body api.ServerVersion `json:"body"`
}
+
+// StringSlice
+// swagger:response StringSlice
+type swaggerResponseStringSlice struct {
+ // in:body
+ Body []string `json:"body"`
+}