this repo has no description
0
fork

Configure Feed

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

lexiconize

authored by

Brian Olson and committed by
Brian Olson
fa14a2fa 6a3ec135

+47 -10
+38
api/atproto/synclistReposByCollection.go
··· 1 + // Code generated by cmd/lexgen (see Makefile's lexgen); DO NOT EDIT. 2 + 3 + package atproto 4 + 5 + // schema: com.atproto.sync.listReposByCollection 6 + 7 + import ( 8 + "context" 9 + 10 + "github.com/bluesky-social/indigo/xrpc" 11 + ) 12 + 13 + // SyncListReposByCollection_Output is the output of a com.atproto.sync.listReposByCollection call. 14 + type SyncListReposByCollection_Output struct { 15 + Cursor *string `json:"cursor,omitempty" cborgen:"cursor,omitempty"` 16 + Repos []*SyncListReposByCollection_Repo `json:"repos" cborgen:"repos"` 17 + } 18 + 19 + // SyncListReposByCollection_Repo is a "repo" in the com.atproto.sync.listReposByCollection schema. 20 + type SyncListReposByCollection_Repo struct { 21 + Did string `json:"did" cborgen:"did"` 22 + } 23 + 24 + // SyncListReposByCollection calls the XRPC method "com.atproto.sync.listReposByCollection". 25 + func SyncListReposByCollection(ctx context.Context, c *xrpc.Client, collection string, cursor string, limit int64) (*SyncListReposByCollection_Output, error) { 26 + var out SyncListReposByCollection_Output 27 + 28 + params := map[string]interface{}{ 29 + "collection": collection, 30 + "cursor": cursor, 31 + "limit": limit, 32 + } 33 + if err := c.Do(ctx, xrpc.Query, "", "com.atproto.sync.listReposByCollection", params, nil, &out); err != nil { 34 + return nil, err 35 + } 36 + 37 + return &out, nil 38 + }
+9 -10
cmd/collectiondir/serve.go
··· 413 413 414 414 e.GET("/_health", cs.healthz) 415 415 416 + e.GET("/xrpc/com.atproto.sync.listReposByCollection", cs.getDidsForCollection) 416 417 e.GET("/v1/getDidsForCollection", cs.getDidsForCollection) 417 418 e.GET("/v1/listCollections", cs.listCollections) 418 419 ··· 434 435 435 436 const statsCacheDuration = time.Second * 300 436 437 437 - type GetDidsForCollectionResponse struct { 438 - Dids []string `json:"dids"` 439 - Cursor string `json:"cursor"` 440 - } 441 - 442 438 func getLimit(c echo.Context, min, defaultLim, max int) int { 443 439 limstr := c.QueryParam("limit") 444 440 if limstr == "" { ··· 458 454 return lv 459 455 } 460 456 457 + // /xrpc/com.atproto.sync.listReposByCollection?collection={}&cursor={}&limit={50<=N<=1000} 461 458 // /v1/getDidsForCollection?collection={}&cursor={}&limit={50<=N<=1000} 462 459 // 463 460 // returns ··· 470 467 return c.String(http.StatusBadRequest, fmt.Sprintf("bad collection nsid, %s", err.Error())) 471 468 } 472 469 cursor := c.QueryParam("cursor") 473 - limit := getLimit(c, 50, 500, 1000) 470 + limit := getLimit(c, 1, 500, 10_000) 474 471 they, nextCursor, err := cs.pcd.ReadCollection(ctx, collection, cursor, limit) 475 472 if err != nil { 476 473 slog.Error("ReadCollection", "collection", collection, "cursor", cursor, "limit", limit, "err", err) 477 474 return c.String(http.StatusInternalServerError, "oops") 478 475 } 479 476 cs.log.Info("getDidsForCollection", "collection", collection, "cursor", cursor, "limit", limit, "count", len(they), "nextCursor", nextCursor) 480 - var out GetDidsForCollectionResponse 481 - out.Dids = make([]string, len(they)) 477 + var out comatproto.SyncListReposByCollection_Output 478 + out.Repos = make([]*comatproto.SyncListReposByCollection_Repo, len(they)) 482 479 for i, rec := range they { 483 - out.Dids[i] = rec.Did 480 + out.Repos[i] = &comatproto.SyncListReposByCollection_Repo{Did: rec.Did} 481 + } 482 + if nextCursor != "" { 483 + out.Cursor = &nextCursor 484 484 } 485 - out.Cursor = nextCursor 486 485 return c.JSON(http.StatusOK, out) 487 486 } 488 487