MM-54640 Add API to get multiple emojis by name at once (#24651)

* MM-54640 Add API to get multiple emojis by name at once

* Fix status code when too many names are requested

* Address feedback

* Update unit tests

* Fix styling

* Fix more styling

* Fix mismatched i18n id
Этот коммит содержится в:
Harrison Healey
2023-10-17 12:03:28 -04:00
коммит произвёл GitHub
родитель 77cc356d46
Коммит 3d0fd16666
8 изменённых файлов: 241 добавлений и 35 удалений

Просмотреть файл

@@ -6618,6 +6618,26 @@ func (c *Client4) GetSortedEmojiList(ctx context.Context, page, perPage int, sor
return list, BuildResponse(r), nil
}
// GetEmojisByNames takes an array of custom emoji names and returns an array of those emojis.
func (c *Client4) GetEmojisByNames(ctx context.Context, names []string) ([]*Emoji, *Response, error) {
buf, err := json.Marshal(names)
if err != nil {
return nil, nil, NewAppError("GetEmojisByNames", "api.marshal_error", nil, "", http.StatusInternalServerError).Wrap(err)
}
r, err := c.DoAPIPostBytes(ctx, c.emojisRoute()+"/names", buf)
if err != nil {
return nil, BuildResponse(r), err
}
defer closeBody(r)
var list []*Emoji
if err := json.NewDecoder(r.Body).Decode(&list); err != nil {
return nil, nil, NewAppError("GetEmojisByNames", "api.unmarshal_error", nil, "", http.StatusInternalServerError).Wrap(err)
}
return list, BuildResponse(r), nil
}
// DeleteEmoji delete an custom emoji on the provided emoji id string.
func (c *Client4) DeleteEmoji(ctx context.Context, emojiId string) (*Response, error) {
r, err := c.DoAPIDelete(ctx, c.emojiRoute(emojiId))