made the emoji store getByName method sync (#11324)
Этот коммит содержится в:
коммит произвёл
Hanzei
родитель
9ce1aa4455
Коммит
d300f4a6ad
@@ -100,26 +100,27 @@ func (es SqlEmojiStore) Get(id string, allowFromCache bool) (*model.Emoji, *mode
|
||||
return emoji, nil
|
||||
}
|
||||
|
||||
func (es SqlEmojiStore) GetByName(name string) store.StoreChannel {
|
||||
return store.Do(func(result *store.StoreResult) {
|
||||
var emoji *model.Emoji
|
||||
func (es SqlEmojiStore) GetByName(name string) (*model.Emoji, *model.AppError) {
|
||||
|
||||
if err := es.GetReplica().SelectOne(&emoji,
|
||||
`SELECT
|
||||
*
|
||||
FROM
|
||||
Emoji
|
||||
WHERE
|
||||
Name = :Name
|
||||
AND DeleteAt = 0`, map[string]interface{}{"Name": name}); err != nil {
|
||||
result.Err = model.NewAppError("SqlEmojiStore.GetByName", "store.sql_emoji.get_by_name.app_error", nil, "name="+name+", "+err.Error(), http.StatusInternalServerError)
|
||||
if err == sql.ErrNoRows {
|
||||
result.Err.StatusCode = http.StatusNotFound
|
||||
}
|
||||
} else {
|
||||
result.Data = emoji
|
||||
var emoji *model.Emoji
|
||||
|
||||
if err := es.GetReplica().SelectOne(&emoji,
|
||||
`SELECT
|
||||
*
|
||||
FROM
|
||||
Emoji
|
||||
WHERE
|
||||
Name = :Name
|
||||
AND DeleteAt = 0`, map[string]interface{}{"Name": name}); err != nil {
|
||||
|
||||
if err == sql.ErrNoRows {
|
||||
return nil, model.NewAppError("SqlEmojiStore.GetByName", "store.sql_emoji.get_by_name.app_error", nil, "name="+name+", "+err.Error(), http.StatusNotFound)
|
||||
}
|
||||
})
|
||||
|
||||
return nil, model.NewAppError("SqlEmojiStore.GetByName", "store.sql_emoji.get_by_name.app_error", nil, "name="+name+", "+err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
|
||||
return emoji, nil
|
||||
}
|
||||
|
||||
func (es SqlEmojiStore) GetMultipleByName(names []string) store.StoreChannel {
|
||||
|
||||
Ссылка в новой задаче
Block a user