GetNotefile gets the notefile from within the a notehubMessage data structure
()
| 506 | |
| 507 | // GetNotefile gets the notefile from within the a notehubMessage data structure |
| 508 | func (msg *notehubMessage) GetNotefile() (notefile *Notefile, err error) { |
| 509 | notefile = &Notefile{} |
| 510 | |
| 511 | // If native is available, return it, else decompress |
| 512 | if msg.nf != nil && msg.nf.Notefile != nil { |
| 513 | notefile = msg.nf.Notefile |
| 514 | } else { |
| 515 | if msg.cf == nil || len(msg.cf.Notefile) == 0 { |
| 516 | return |
| 517 | } |
| 518 | jdata, err2 := jsonDecompress(msg.cf.Notefile) |
| 519 | if err2 != nil { |
| 520 | err = err2 |
| 521 | return |
| 522 | } |
| 523 | err = note.JSONUnmarshal(jdata, notefile) |
| 524 | if err != nil { |
| 525 | return |
| 526 | } |
| 527 | } |
| 528 | |
| 529 | // If there's an externalized payload, internalize it |
| 530 | if msg.nf.Payload != nil && len(*msg.nf.Payload) != 0 { |
| 531 | err = notefile.InternalizePayload(*msg.nf.Payload) |
| 532 | if err != nil { |
| 533 | return |
| 534 | } |
| 535 | } |
| 536 | |
| 537 | // Done |
| 538 | return |
| 539 | } |
| 540 | |
| 541 | // SetNotefiles sets the notefile list within the a notehubMessage data structure |
| 542 | func (msg *notehubMessage) SetNotefiles(notefiles map[string]*Notefile) error { |
no test coverage detected