[MM-30978] avoid parsing nil PostAction in SlackAttachments (#16556)
* avoid parsing nil PostAction in SlackAttachments * reflect review comments * improve tests Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
c54b262351
Коммит
bd5616557d
@@ -557,6 +557,14 @@ func (o *Post) Attachments() []*SlackAttachment {
|
||||
if enc, err := json.Marshal(attachment); err == nil {
|
||||
var decoded SlackAttachment
|
||||
if json.Unmarshal(enc, &decoded) == nil {
|
||||
i := 0
|
||||
for _, action := range decoded.Actions {
|
||||
if action != nil {
|
||||
decoded.Actions[i] = action
|
||||
i++
|
||||
}
|
||||
}
|
||||
decoded.Actions = decoded.Actions[:i]
|
||||
ret = append(ret, &decoded)
|
||||
}
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user