MCPcopy Create free account
hub / github.com/blues/note / annotateNoteWithWhereWhen

Function annotateNoteWithWhereWhen

lib/req.go:598–618  ·  view source on GitHub ↗

Annotate a note structure with optional location and tower info from a request

(xnote *note.Note, req notecard.Request)

Source from the content-addressed store, hash-verified

596
597// Annotate a note structure with optional location and tower info from a request
598func 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
621func ErrorResponse(err error) (response []byte) {

Callers 1

RequestMethod · 0.85

Calls 1

EncodeMethod · 0.45

Tested by

no test coverage detected