MM-37573: Ignore nil fields in attachments (#18052)
We extend the same logic done in https://github.com/mattermost/mattermost-server/pull/16556 to Field. Also handled the case elsewhere in the code with a light grep for extra safety. https://mattermost.atlassian.net/browse/MM-37573 ```release-note NONE ```
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
c281d5eac6
Коммит
32005b05d9
@@ -929,4 +929,20 @@ func TestPostAttachments(t *testing.T) {
|
||||
require.Equal(t, attachments[0].Actions[0].Id, "test1")
|
||||
require.Equal(t, attachments[0].Actions[1].Id, "test2")
|
||||
})
|
||||
|
||||
t.Run("nil fields", func(t *testing.T) {
|
||||
p.Props["attachments"] = []interface{}{
|
||||
map[string]interface{}{"fields": []interface{}{
|
||||
map[string]interface{}{"value": ":emoji1:"},
|
||||
nil,
|
||||
map[string]interface{}{"value": ":emoji2:"},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
attachments := p.Attachments()
|
||||
require.Len(t, attachments[0].Fields, 2)
|
||||
assert.Equal(t, attachments[0].Fields[0].Value, ":emoji1:")
|
||||
assert.Equal(t, attachments[0].Fields[1].Value, ":emoji2:")
|
||||
})
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user