GetNotefiles gets the multi-notefile structure from within the a notehubMessage
()
| 561 | |
| 562 | // GetNotefiles gets the multi-notefile structure from within the a notehubMessage |
| 563 | func (msg *notehubMessage) GetNotefiles() (notefiles map[string]*Notefile, err error) { |
| 564 | notefiles = map[string]*Notefile{} |
| 565 | |
| 566 | // If native is available, return it, else decompress |
| 567 | if msg.nf != nil && msg.nf.Notefiles != nil { |
| 568 | notefiles = *msg.nf.Notefiles |
| 569 | } else { |
| 570 | if msg.cf == nil || len(msg.cf.Notefiles) == 0 { |
| 571 | return |
| 572 | } |
| 573 | jdata, err2 := jsonDecompress(msg.cf.Notefiles) |
| 574 | if err2 != nil { |
| 575 | err = err2 |
| 576 | return |
| 577 | } |
| 578 | err = note.JSONUnmarshal(jdata, notefiles) |
| 579 | if err != nil { |
| 580 | return |
| 581 | } |
| 582 | } |
| 583 | |
| 584 | // If there's an externalized payload, internalize it |
| 585 | if msg.nf.Payload != nil && len(*msg.nf.Payload) != 0 { |
| 586 | for _, notefile := range notefiles { |
| 587 | err = notefile.InternalizePayload(*msg.nf.Payload) |
| 588 | if err != nil { |
| 589 | return |
| 590 | } |
| 591 | } |
| 592 | } |
| 593 | |
| 594 | // Done |
| 595 | return |
| 596 | } |
| 597 | |
| 598 | // SetBody sets the body within the a notehubMessage data structure |
| 599 | func (msg *notehubMessage) SetBody(body map[string]interface{}) error { |
no test coverage detected