From 15f3f0adf840d8b33e3f43a791d9c2ad047d94c5 Mon Sep 17 00:00:00 2001 From: Max Date: Mon, 12 May 2025 14:38:37 +0800 Subject: [PATCH] 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. --- neo/message/message.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/neo/message/message.go b/neo/message/message.go index 772544a0..1bb5e3f6 100644 --- a/neo/message/message.go +++ b/neo/message/message.go @@ -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 }