···
"github.com/Azure/go-autorest/autorest/to"
"github.com/bluesky-social/indigo/atproto/data"
+
"github.com/bluesky-social/indigo/atproto/syntax"
"github.com/haileyok/cocoon/internal/helpers"
"github.com/haileyok/cocoon/models"
"github.com/labstack/echo/v4"
+
type ComAtprotoRepoListRecordsRequest struct {
+
Repo string `query:"repo" validate:"required"`
+
Collection string `query:"collection" validate:"required,atproto-nsid"`
+
Limit int64 `query:"limit"`
+
Cursor string `query:"cursor"`
+
Reverse bool `query:"reverse"`
type ComAtprotoRepoListRecordsResponse struct {
Cursor *string `json:"cursor,omitempty"`
···
func (s *Server) handleListRecords(e echo.Context) error {
+
var req ComAtprotoRepoListRecordsRequest
+
if err := e.Bind(&req); err != nil {
+
s.logger.Error("could not bind list records request", "error", err)
+
return helpers.ServerError(e, nil)
+
if err := e.Validate(req); err != nil {
+
return helpers.InputError(e, nil)
+
} else if req.Limit > 100 {
limit, err := getLimitFromContext(e, 50)
return helpers.InputError(e, nil)
···
+
if _, err := syntax.ParseDID(did); err != nil {
+
actor, err := s.getActorByHandle(req.Repo)
+
return helpers.InputError(e, to.StringPtr("RepoNotFound"))
+
params := []any{did, req.Collection}
+
params = append(params, req.Cursor)
cursorquery = "AND created_at " + dir + " ?"
params = append(params, limit)