Annotate a note structure with optional location and tower info from a request
(xnote *note.Note, req notecard.Request)
| 596 | |
| 597 | // Annotate a note structure with optional location and tower info from a request |
| 598 | func annotateNoteWithWhereWhen(xnote *note.Note, req notecard.Request) { |
| 599 | if req.Time != 0 || req.Latitude != 0 || req.Longitude != 0 { |
| 600 | if req.Time == InvalidTime { |
| 601 | req.Time = 0 |
| 602 | } |
| 603 | newHistory := note.History{} |
| 604 | newHistory.When = req.Time |
| 605 | if req.LocationOLC != "" { |
| 606 | newHistory.Where = req.LocationOLC |
| 607 | } else if req.Latitude != 0 || req.Longitude != 0 { |
| 608 | newHistory.Where = golc.Encode(req.Latitude, req.Longitude, 12) |
| 609 | } |
| 610 | newHistory.WhereWhen = req.LocationTime |
| 611 | newHistories := []note.History{} |
| 612 | newHistories = append(newHistories, newHistory) |
| 613 | xnote.Histories = &newHistories |
| 614 | } |
| 615 | if req.Tower != nil { |
| 616 | xnote.Tower = req.Tower |
| 617 | } |
| 618 | } |
| 619 | |
| 620 | // ErrorResponse creates a simple JSON response given an error |
| 621 | func ErrorResponse(err error) (response []byte) { |