mirror of
https://github.com/mattermost/mattermost.git
synced 2025-02-25 18:55:24 -06:00
MM-13021 Fix warning logged when getting metadata for post without emojis (#9832)
This commit is contained in:
@@ -232,6 +232,10 @@ func (a *App) getCustomEmojisForPost(post *model.Post, reactions []*model.Reacti
|
||||
|
||||
names := getEmojiNamesForPost(post, reactions)
|
||||
|
||||
if len(names) == 0 {
|
||||
return []*model.Emoji{}, nil
|
||||
}
|
||||
|
||||
return a.GetMultipleEmojiByName(names)
|
||||
}
|
||||
|
||||
|
||||
@@ -663,6 +663,17 @@ func TestGetCustomEmojisForPost(t *testing.T) {
|
||||
assert.Nil(t, err, "failed to get emojis for post")
|
||||
assert.ElementsMatch(t, emojisForPost, []*model.Emoji{emojis[0]}, "received incorrect emojis")
|
||||
})
|
||||
|
||||
t.Run("with no emojis", func(t *testing.T) {
|
||||
post := &model.Post{
|
||||
Message: "this post is boring",
|
||||
Props: map[string]interface{}{},
|
||||
}
|
||||
|
||||
emojisForPost, err := th.App.getCustomEmojisForPost(post, nil)
|
||||
assert.Nil(t, err, "failed to get emojis for post")
|
||||
assert.ElementsMatch(t, emojisForPost, []*model.Emoji{}, "should have received no emojis")
|
||||
})
|
||||
}
|
||||
|
||||
func TestGetFirstLinkAndImages(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user