summaryrefslogtreecommitdiffstats
path: root/api4/emoji.go
diff options
context:
space:
mode:
authorJoram Wilander <jwawilander@gmail.com>2018-01-24 08:50:11 -0500
committerGitHub <noreply@github.com>2018-01-24 08:50:11 -0500
commit3918ed6c589a19bd385a6e566f07dc14d7484c49 (patch)
treef4a827a00e50eab1d47a70a6a85d369c44c84940 /api4/emoji.go
parentf2415b98f652bc695d3825e54ac832ee468c0a63 (diff)
downloadchat-3918ed6c589a19bd385a6e566f07dc14d7484c49.tar.gz
chat-3918ed6c589a19bd385a6e566f07dc14d7484c49.tar.bz2
chat-3918ed6c589a19bd385a6e566f07dc14d7484c49.zip
Add GET /emojis/name/{emoji_name} API endpoint (#8142)
Diffstat (limited to 'api4/emoji.go')
-rw-r--r--api4/emoji.go16
1 files changed, 16 insertions, 0 deletions
diff --git a/api4/emoji.go b/api4/emoji.go
index 30d59125b..ae4a35dd5 100644
--- a/api4/emoji.go
+++ b/api4/emoji.go
@@ -22,6 +22,7 @@ func (api *API) InitEmoji() {
api.BaseRoutes.Emojis.Handle("/autocomplete", api.ApiSessionRequired(autocompleteEmojis)).Methods("GET")
api.BaseRoutes.Emoji.Handle("", api.ApiSessionRequired(deleteEmoji)).Methods("DELETE")
api.BaseRoutes.Emoji.Handle("", api.ApiSessionRequired(getEmoji)).Methods("GET")
+ api.BaseRoutes.EmojiByName.Handle("", api.ApiSessionRequired(getEmojiByName)).Methods("GET")
api.BaseRoutes.Emoji.Handle("/image", api.ApiSessionRequiredTrustRequester(getEmojiImage)).Methods("GET")
}
@@ -142,6 +143,21 @@ func getEmoji(c *Context, w http.ResponseWriter, r *http.Request) {
}
}
+func getEmojiByName(c *Context, w http.ResponseWriter, r *http.Request) {
+ c.RequireEmojiName()
+ if c.Err != nil {
+ return
+ }
+
+ emoji, err := c.App.GetEmojiByName(c.Params.EmojiName)
+ if err != nil {
+ c.Err = err
+ return
+ } else {
+ w.Write([]byte(emoji.ToJson()))
+ }
+}
+
func getEmojiImage(c *Context, w http.ResponseWriter, r *http.Request) {
c.RequireEmojiId()
if c.Err != nil {