tiny 88x31 lexicon for atproto
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

improve lex endpoint

+21 -2
+21 -2
handler/button.go
··· 54 54 55 55 func (h *Handler) getLikedButtons(w http.ResponseWriter, r *http.Request) { 56 56 did := r.URL.Query().Get("did") 57 + limita := r.URL.Query().Get("limit") 58 + limit, err := strconv.Atoi(limita) 59 + if err != nil { 60 + limit = 50 61 + } 62 + if limit < 1 { 63 + limit = 1 64 + } 65 + if limit > 100 { 66 + limit = 100 67 + } 57 68 cursor := r.URL.Query().Get("cursor") 58 69 var crsr *string 59 70 if cursor != "" { 60 71 crsr = &cursor 61 72 } 62 - btns, _, err := h.db.GetUserLikes(did, 50, crsr, r.Context()) 73 + btns, ncursor, err := h.db.GetUserLikes(did, limit, crsr, r.Context()) 63 74 if err != nil { 64 75 log.Println(err) 65 76 http.Error(w, "error", http.StatusInternalServerError) 66 77 return 67 78 } 79 + type glbResp struct { 80 + Cursor *time.Time `json:"cursor,omitempty"` 81 + Buttons []types.ButtonView `json:"buttons"` 82 + } 83 + glbr := glbResp{ 84 + ncursor, 85 + btns, 86 + } 68 87 w.Header().Set("Content-Type", "application/json") 69 88 encoder := json.NewEncoder(w) 70 - err = encoder.Encode(btns) 89 + err = encoder.Encode(glbr) 71 90 if err != nil { 72 91 log.Println(err) 73 92 http.Error(w, "encoding error", http.StatusInternalServerError)