ABC-90 Add POST /emoji/search and GET /emoji/autocomplete API endpoints (#8125)
* Add POST /emoji/search and GET /emoji/autocomplete API endpoints * Add constant to be clearer
Этот коммит содержится в:
коммит произвёл
Christopher Speller
родитель
599991ea73
Коммит
4f4a765e7d
34
model/emoji_search.go
Обычный файл
34
model/emoji_search.go
Обычный файл
@@ -0,0 +1,34 @@
|
||||
// Copyright (c) 2018-present Mattermost, Inc. All Rights Reserved.
|
||||
// See License.txt for license information.
|
||||
|
||||
package model
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"io"
|
||||
)
|
||||
|
||||
type EmojiSearch struct {
|
||||
Term string `json:"term"`
|
||||
PrefixOnly bool `json:"prefix_only"`
|
||||
}
|
||||
|
||||
func (es *EmojiSearch) ToJson() string {
|
||||
b, err := json.Marshal(es)
|
||||
if err != nil {
|
||||
return ""
|
||||
} else {
|
||||
return string(b)
|
||||
}
|
||||
}
|
||||
|
||||
func EmojiSearchFromJson(data io.Reader) *EmojiSearch {
|
||||
decoder := json.NewDecoder(data)
|
||||
var es EmojiSearch
|
||||
err := decoder.Decode(&es)
|
||||
if err == nil {
|
||||
return &es
|
||||
} else {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
Ссылка в новой задаче
Block a user