made the emoji store getByName method sync (#11324)
Этот коммит содержится в:
коммит произвёл
Hanzei
родитель
9ce1aa4455
Коммит
d300f4a6ad
@@ -53,7 +53,7 @@ func (a *App) CreateEmoji(sessionUserId string, emoji *model.Emoji, multiPartIma
|
||||
return nil, model.NewAppError("createEmoji", "api.emoji.create.other_user.app_error", nil, "", http.StatusForbidden)
|
||||
}
|
||||
|
||||
if result := <-a.Srv.Store.Emoji().GetByName(emoji.Name); result.Err == nil && result.Data != nil {
|
||||
if existingEmoji, err := a.Srv.Store.Emoji().GetByName(emoji.Name); err == nil && existingEmoji != nil {
|
||||
return nil, model.NewAppError("createEmoji", "api.emoji.create.duplicate.app_error", nil, "", http.StatusBadRequest)
|
||||
}
|
||||
|
||||
@@ -190,11 +190,7 @@ func (a *App) GetEmojiByName(emojiName string) (*model.Emoji, *model.AppError) {
|
||||
return nil, model.NewAppError("GetEmoji", "api.emoji.storage.app_error", nil, "", http.StatusNotImplemented)
|
||||
}
|
||||
|
||||
result := <-a.Srv.Store.Emoji().GetByName(emojiName)
|
||||
if result.Err != nil {
|
||||
return nil, result.Err
|
||||
}
|
||||
return result.Data.(*model.Emoji), nil
|
||||
return a.Srv.Store.Emoji().GetByName(emojiName)
|
||||
}
|
||||
|
||||
func (a *App) GetMultipleEmojiByName(names []string) ([]*model.Emoji, *model.AppError) {
|
||||
|
||||
@@ -1280,13 +1280,9 @@ func (a *App) ImportEmoji(data *EmojiImportData, dryRun bool) *model.AppError {
|
||||
|
||||
var emoji *model.Emoji
|
||||
|
||||
result := <-a.Srv.Store.Emoji().GetByName(*data.Name)
|
||||
if result.Err != nil && result.Err.StatusCode != http.StatusNotFound {
|
||||
return result.Err
|
||||
}
|
||||
|
||||
if result.Data != nil {
|
||||
emoji = result.Data.(*model.Emoji)
|
||||
emoji, appError := a.Srv.Store.Emoji().GetByName(*data.Name)
|
||||
if appError != nil && appError.StatusCode != http.StatusNotFound {
|
||||
return appError
|
||||
}
|
||||
|
||||
alreadyExists := emoji != nil
|
||||
|
||||
@@ -2681,8 +2681,9 @@ func TestImportImportEmoji(t *testing.T) {
|
||||
err := th.App.ImportEmoji(&data, true)
|
||||
assert.NotNil(t, err, "Invalid emoji should have failed dry run")
|
||||
|
||||
result := <-th.App.Srv.Store.Emoji().GetByName(*data.Name)
|
||||
assert.Nil(t, result.Data, "Emoji should not have been imported")
|
||||
emoji, err := th.App.Srv.Store.Emoji().GetByName(*data.Name)
|
||||
assert.Nil(t, emoji, "Emoji should not have been imported")
|
||||
assert.NotNil(t, err)
|
||||
|
||||
data.Image = ptrStr(testImage)
|
||||
err = th.App.ImportEmoji(&data, true)
|
||||
@@ -2700,8 +2701,9 @@ func TestImportImportEmoji(t *testing.T) {
|
||||
err = th.App.ImportEmoji(&data, false)
|
||||
assert.Nil(t, err, "Valid emoji should have succeeded apply mode")
|
||||
|
||||
result = <-th.App.Srv.Store.Emoji().GetByName(*data.Name)
|
||||
assert.NotNil(t, result.Data, "Emoji should have been imported")
|
||||
emoji, err = th.App.Srv.Store.Emoji().GetByName(*data.Name)
|
||||
assert.NotNil(t, emoji, "Emoji should have been imported")
|
||||
assert.Nil(t, err, "Emoji should have been imported without any error")
|
||||
|
||||
err = th.App.ImportEmoji(&data, false)
|
||||
assert.Nil(t, err, "Second run should have succeeded apply mode")
|
||||
|
||||
Ссылка в новой задаче
Block a user