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
@@ -605,6 +605,7 @@ func (o *Post) Attachments() []*SlackAttachment {
|
||||
if enc, err := json.Marshal(attachment); err == nil {
|
||||
var decoded SlackAttachment
|
||||
if json.Unmarshal(enc, &decoded) == nil {
|
||||
// Ignoring nil actions
|
||||
i := 0
|
||||
for _, action := range decoded.Actions {
|
||||
if action != nil {
|
||||
@@ -613,6 +614,16 @@ func (o *Post) Attachments() []*SlackAttachment {
|
||||
}
|
||||
}
|
||||
decoded.Actions = decoded.Actions[:i]
|
||||
|
||||
// Ignoring nil fields
|
||||
i = 0
|
||||
for _, field := range decoded.Fields {
|
||||
if field != nil {
|
||||
decoded.Fields[i] = field
|
||||
i++
|
||||
}
|
||||
}
|
||||
decoded.Fields = decoded.Fields[:i]
|
||||
ret = append(ret, &decoded)
|
||||
}
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user