An atproto PDS written in Go
at v0.5.1 1.2 kB view raw
1package server 2 3import ( 4 "github.com/Azure/go-autorest/autorest/to" 5 "github.com/bluesky-social/indigo/api/atproto" 6 "github.com/bluesky-social/indigo/api/bsky" 7 "github.com/bluesky-social/indigo/atproto/syntax" 8 "github.com/bluesky-social/indigo/xrpc" 9 "github.com/haileyok/cocoon/internal/helpers" 10 "github.com/labstack/echo/v4" 11) 12 13func (s *Server) handleProxyBskyFeedGetFeed(e echo.Context) error { 14 feedUri, err := syntax.ParseATURI(e.QueryParam("feed")) 15 if err != nil { 16 return helpers.InputError(e, to.StringPtr("invalid feed uri")) 17 } 18 19 appViewEndpoint, _, err := s.getAtprotoProxyEndpointFromRequest(e) 20 if err != nil { 21 e.Logger().Error("could not get atproto proxy", "error", err) 22 return helpers.ServerError(e, nil) 23 } 24 25 appViewClient := xrpc.Client{ 26 Host: appViewEndpoint, 27 } 28 feedRecord, err := atproto.RepoGetRecord(e.Request().Context(), &appViewClient, "", feedUri.Collection().String(), feedUri.Authority().String(), feedUri.RecordKey().String()) 29 feedGeneratorDid := feedRecord.Value.Val.(*bsky.FeedGenerator).Did 30 31 e.Set("proxyTokenLxm", "app.bsky.feed.getFeedSkeleton") 32 e.Set("proxyTokenAud", feedGeneratorDid) 33 34 return s.handleProxy(e) 35}