(messages []map[string]any)
| 35 | } |
| 36 | |
| 37 | func ReorderAttachments(messages []map[string]any) []map[string]any { |
| 38 | out := make([]map[string]any, 0, len(messages)) |
| 39 | for _, msg := range messages { |
| 40 | blocks := contentBlocks(msg["content"]) |
| 41 | if blocks == nil { |
| 42 | out = append(out, msg) |
| 43 | continue |
| 44 | } |
| 45 | attachments := make([]map[string]any, 0, len(blocks)) |
| 46 | others := make([]map[string]any, 0, len(blocks)) |
| 47 | for _, block := range blocks { |
| 48 | if _, ok := attachmentBlockTypes[stringFromAny(block["type"])]; ok { |
| 49 | attachments = append(attachments, block) |
| 50 | } else { |
| 51 | others = append(others, block) |
| 52 | } |
| 53 | } |
| 54 | cp := copyMap(msg) |
| 55 | cp["content"] = append(attachments, others...) |
| 56 | out = append(out, cp) |
| 57 | } |
| 58 | return out |
| 59 | } |
| 60 | |
| 61 | func FilterVirtualMessages(messages []map[string]any) []map[string]any { |
| 62 | out := make([]map[string]any, 0, len(messages)) |
no test coverage detected