Add GET /emojis/name/{emoji_name} API endpoint (#8142)
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
f2415b98f6
Коммит
3918ed6c58
@@ -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 {
|
||||
|
||||
Ссылка в новой задаче
Block a user