Merge pull request #951 from trheyi/main
fix: Add support for attachments in message mapping
This commit is contained in:
commit
c3b30a018e
1 changed files with 10 additions and 0 deletions
|
|
@ -497,6 +497,16 @@ func (m *Message) Map(msg map[string]interface{}) *Message {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// attachments
|
||||||
|
if attachments, has := msg["attachments"]; has {
|
||||||
|
raw, _ := jsoniter.Marshal(attachments)
|
||||||
|
m.Attachments = []Attachment{}
|
||||||
|
if err := jsoniter.Unmarshal(raw, &m.Attachments); err != nil {
|
||||||
|
color.Red("JSON parse error: %s", err.Error())
|
||||||
|
color.White(string(raw))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if role, ok := msg["role"].(string); ok {
|
if role, ok := msg["role"].(string); ok {
|
||||||
m.Role = role
|
m.Role = role
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue