diff --git a/cmd/astrolabe/handlers.go b/cmd/astrolabe/handlers.go index f7732fe4e..f974fcf4c 100644 --- a/cmd/astrolabe/handlers.go +++ b/cmd/astrolabe/handlers.go @@ -6,6 +6,7 @@ import ( "net/http" "strings" + "github.com/bluesky-social/indigo/api/agnostic" comatproto "github.com/bluesky-social/indigo/api/atproto" _ "github.com/bluesky-social/indigo/api/bsky" "github.com/bluesky-social/indigo/atproto/data" @@ -161,7 +162,7 @@ func (srv *Server) WebRepoCollection(c echo.Context) error { cursor := c.QueryParam("cursor") // collection string, cursor string, limit int64, repo string, reverse bool, rkeyEnd string, rkeyStart string - resp, err := RepoListRecords(ctx, &xrpcc, collection.String(), cursor, 100, ident.DID.String(), false, "", "") + resp, err := agnostic.RepoListRecords(ctx, &xrpcc, collection.String(), cursor, 100, ident.DID.String(), false, "", "") if err != nil { return err } @@ -218,7 +219,7 @@ func (srv *Server) WebRepoRecord(c echo.Context) error { xrpcc := xrpc.Client{ Host: ident.PDSEndpoint(), } - resp, err := RepoGetRecord(ctx, &xrpcc, "", collection.String(), ident.DID.String(), rkey.String()) + resp, err := agnostic.RepoGetRecord(ctx, &xrpcc, "", collection.String(), ident.DID.String(), rkey.String()) if err != nil { return echo.NewHTTPError(400, fmt.Sprintf("failed to load record: %s", err)) } diff --git a/cmd/astrolabe/repogetRecord.go b/cmd/astrolabe/repogetRecord.go deleted file mode 100644 index e3b857cd5..000000000 --- a/cmd/astrolabe/repogetRecord.go +++ /dev/null @@ -1,42 +0,0 @@ -// Copied from indigo:api/atproto/repolistRecords.go - -package main - -// schema: com.atproto.repo.getRecord - -import ( - "context" - "encoding/json" - - "github.com/bluesky-social/indigo/xrpc" -) - -// RepoGetRecord_Output is the output of a com.atproto.repo.getRecord call. -type RepoGetRecord_Output struct { - Cid *string `json:"cid,omitempty" cborgen:"cid,omitempty"` - Uri string `json:"uri" cborgen:"uri"` - // NOTE: changed from lex decoder to json.RawMessage - Value *json.RawMessage `json:"value" cborgen:"value"` -} - -// RepoGetRecord calls the XRPC method "com.atproto.repo.getRecord". -// -// cid: The CID of the version of the record. If not specified, then return the most recent version. -// collection: The NSID of the record collection. -// repo: The handle or DID of the repo. -// rkey: The Record Key. -func RepoGetRecord(ctx context.Context, c *xrpc.Client, cid string, collection string, repo string, rkey string) (*RepoGetRecord_Output, error) { - var out RepoGetRecord_Output - - params := map[string]interface{}{ - "cid": cid, - "collection": collection, - "repo": repo, - "rkey": rkey, - } - if err := c.Do(ctx, xrpc.Query, "", "com.atproto.repo.getRecord", params, nil, &out); err != nil { - return nil, err - } - - return &out, nil -} diff --git a/cmd/astrolabe/repolistRecords.go b/cmd/astrolabe/repolistRecords.go deleted file mode 100644 index 3cfdd9b24..000000000 --- a/cmd/astrolabe/repolistRecords.go +++ /dev/null @@ -1,53 +0,0 @@ -// Copied from indigo:api/atproto/repolistRecords.go - -package main - -// schema: com.atproto.repo.listRecords - -import ( - "context" - "encoding/json" - - "github.com/bluesky-social/indigo/xrpc" -) - -// RepoListRecords_Output is the output of a com.atproto.repo.listRecords call. -type RepoListRecords_Output struct { - Cursor *string `json:"cursor,omitempty" cborgen:"cursor,omitempty"` - Records []*RepoListRecords_Record `json:"records" cborgen:"records"` -} - -// RepoListRecords_Record is a "record" in the com.atproto.repo.listRecords schema. -type RepoListRecords_Record struct { - Cid string `json:"cid" cborgen:"cid"` - Uri string `json:"uri" cborgen:"uri"` - // NOTE: changed from lex decoder to json.RawMessage - Value *json.RawMessage `json:"value" cborgen:"value"` -} - -// RepoListRecords calls the XRPC method "com.atproto.repo.listRecords". -// -// collection: The NSID of the record type. -// limit: The number of records to return. -// repo: The handle or DID of the repo. -// reverse: Flag to reverse the order of the returned records. -// rkeyEnd: DEPRECATED: The highest sort-ordered rkey to stop at (exclusive) -// rkeyStart: DEPRECATED: The lowest sort-ordered rkey to start from (exclusive) -func RepoListRecords(ctx context.Context, c *xrpc.Client, collection string, cursor string, limit int64, repo string, reverse bool, rkeyEnd string, rkeyStart string) (*RepoListRecords_Output, error) { - var out RepoListRecords_Output - - params := map[string]interface{}{ - "collection": collection, - "cursor": cursor, - "limit": limit, - "repo": repo, - "reverse": reverse, - "rkeyEnd": rkeyEnd, - "rkeyStart": rkeyStart, - } - if err := c.Do(ctx, xrpc.Query, "", "com.atproto.repo.listRecords", params, nil, &out); err != nil { - return nil, err - } - - return &out, nil -}