this repo has no description
0
fork

Configure Feed

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

labelmaker: remove more unused endpoints

-112
-31
labeling/xrpc_endpoints.go
··· 65 65 return c.JSON(200, out) 66 66 } 67 67 68 - func (s *Server) HandleComAtprotoRepoDescribeRepo(c echo.Context) error { 69 - ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleComAtprotoRepoDescribeRepo") 70 - defer span.End() 71 - repo := c.QueryParam("repo") 72 - var out *atproto.RepoDescribeRepo_Output 73 - var handleErr error 74 - // func (s *Server) handleComAtprotoRepoDescribeRepo(ctx context.Context,repo string) (*atproto.RepoDescribeRepo_Output, error) 75 - out, handleErr = s.handleComAtprotoRepoDescribeRepo(ctx, repo) 76 - if handleErr != nil { 77 - return handleErr 78 - } 79 - return c.JSON(200, out) 80 - } 81 - 82 - func (s *Server) HandleComAtprotoRepoGetRecord(c echo.Context) error { 83 - ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleComAtprotoRepoGetRecord") 84 - defer span.End() 85 - cid := c.QueryParam("cid") 86 - collection := c.QueryParam("collection") 87 - repo := c.QueryParam("repo") 88 - rkey := c.QueryParam("rkey") 89 - var out *atproto.RepoGetRecord_Output 90 - var handleErr error 91 - // func (s *Server) handleComAtprotoRepoGetRecord(ctx context.Context,cid string,collection string,repo string,rkey string) (*atproto.RepoGetRecord_Output, error) 92 - out, handleErr = s.handleComAtprotoRepoGetRecord(ctx, cid, collection, repo, rkey) 93 - if handleErr != nil { 94 - return handleErr 95 - } 96 - return c.JSON(200, out) 97 - } 98 - 99 68 func (s *Server) HandleComAtprotoServerDescribeServer(c echo.Context) error { 100 69 ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleComAtprotoServerDescribeServer") 101 70 defer span.End()
-81
labeling/xrpc_handlers.go
··· 1 1 package labeling 2 2 3 3 import ( 4 - "bytes" 5 4 "context" 6 - "fmt" 7 - "io" 8 5 "strconv" 9 6 "strings" 10 7 "time" 11 8 12 9 atproto "github.com/bluesky-social/indigo/api/atproto" 13 10 label "github.com/bluesky-social/indigo/api/label" 14 - lexutil "github.com/bluesky-social/indigo/lex/util" 15 11 "github.com/bluesky-social/indigo/models" 16 12 "github.com/bluesky-social/indigo/util" 17 13 18 - "github.com/ipfs/go-cid" 19 14 "github.com/labstack/echo/v4" 20 15 ) 21 16 ··· 30 25 } 31 26 } 32 27 33 - func (s *Server) handleComAtprotoRepoDescribeRepo(ctx context.Context, repo string) (*atproto.RepoDescribeRepo_Output, error) { 34 - if repo == s.user.Did || repo == s.user.Handle { 35 - return &atproto.RepoDescribeRepo_Output{ 36 - Collections: []string{}, 37 - Did: s.user.Did, 38 - //DidDoc 39 - Handle: s.user.Handle, 40 - HandleIsCorrect: true, 41 - }, nil 42 - } 43 - if repo == "" { 44 - return nil, echo.NewHTTPError(400, "empty repo parameter") 45 - } else { 46 - return nil, echo.NewHTTPError(404, "repo not found") 47 - } 48 - } 49 - 50 28 func (s *Server) handleComAtprotoServerDescribeServer(ctx context.Context) (*atproto.ServerDescribeServer_Output, error) { 51 29 invcode := true 52 30 return &atproto.ServerDescribeServer_Output{ 53 31 InviteCodeRequired: &invcode, 54 32 AvailableUserDomains: []string{}, 55 33 Links: &atproto.ServerDescribeServer_Links{}, 56 - }, nil 57 - } 58 - 59 - func (s *Server) handleComAtprotoSyncGetRepo(ctx context.Context, did string, earliest, latest string) (io.Reader, error) { 60 - // TODO: verify the DID/handle 61 - var userId util.Uid = 1 62 - var earlyCid cid.Cid 63 - if earliest != "" { 64 - cc, err := cid.Decode(earliest) 65 - if err != nil { 66 - return nil, err 67 - } 68 - 69 - earlyCid = cc 70 - } 71 - 72 - var lateCid cid.Cid 73 - if latest != "" { 74 - cc, err := cid.Decode(latest) 75 - if err != nil { 76 - return nil, err 77 - } 78 - 79 - lateCid = cc 80 - } 81 - 82 - buf := new(bytes.Buffer) 83 - if err := s.repoman.ReadRepo(ctx, userId, earlyCid, lateCid, buf); err != nil { 84 - return nil, err 85 - } 86 - 87 - return buf, nil 88 - } 89 - 90 - func (s *Server) handleComAtprotoRepoGetRecord(ctx context.Context, c string, collection string, rkey string, user string) (*atproto.RepoGetRecord_Output, error) { 91 - if user != s.user.Did { 92 - return nil, echo.NewHTTPError(404, "unknown user: %s", user) 93 - } 94 - 95 - var maybeCid cid.Cid 96 - if c != "" { 97 - cc, err := cid.Decode(c) 98 - if err != nil { 99 - return nil, err 100 - } 101 - maybeCid = cc 102 - } 103 - 104 - reccid, rec, err := s.repoman.GetRecord(ctx, s.user.UserId, collection, rkey, maybeCid) 105 - if err != nil { 106 - // XXX: handle 404 107 - return nil, fmt.Errorf("repoman GetRecord: %w", err) 108 - } 109 - 110 - ccstr := reccid.String() 111 - return &atproto.RepoGetRecord_Output{ 112 - Cid: &ccstr, 113 - Uri: "at://" + s.user.Did + "/" + collection + "/" + rkey, 114 - Value: &lexutil.LexiconTypeDecoder{rec}, 115 34 }, nil 116 35 } 117 36