summaryrefslogtreecommitdiffstats
path: root/app/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 /app/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 'app/emoji.go')
-rw-r--r--app/emoji.go16
1 files changed, 16 insertions, 0 deletions
diff --git a/app/emoji.go b/app/emoji.go
index 2271d650d..20d4bb44d 100644
--- a/app/emoji.go
+++ b/app/emoji.go
@@ -148,6 +148,22 @@ func (a *App) GetEmoji(emojiId string) (*model.Emoji, *model.AppError) {
}
}
+func (a *App) GetEmojiByName(emojiName string) (*model.Emoji, *model.AppError) {
+ if !*a.Config().ServiceSettings.EnableCustomEmoji {
+ return nil, model.NewAppError("GetEmoji", "api.emoji.disabled.app_error", nil, "", http.StatusNotImplemented)
+ }
+
+ if len(*a.Config().FileSettings.DriverName) == 0 {
+ return nil, model.NewAppError("GetEmoji", "api.emoji.storage.app_error", nil, "", http.StatusNotImplemented)
+ }
+
+ if result := <-a.Srv.Store.Emoji().GetByName(emojiName); result.Err != nil {
+ return nil, result.Err
+ } else {
+ return result.Data.(*model.Emoji), nil
+ }
+}
+
func (a *App) GetEmojiImage(emojiId string) (imageByte []byte, imageType string, err *model.AppError) {
if result := <-a.Srv.Store.Emoji().Get(emojiId, true); result.Err != nil {
return nil, "", result.Err