fix: Add support for attachments in message mapping
- Implemented functionality to handle attachments in the Map method of the Message struct. - Added JSON parsing for attachments, ensuring proper error handling and feedback during the process.
This commit is contained in:
parent
8b7d56a83d
commit
15f3f0adf8
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 {
|
||||
m.Role = role
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue