this repo has no description
0
fork

Configure Feed

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

big update of XRPC stubs and handlers (lex refactor)

+51 -122
+23 -53
labeling/xrpc_endpoints.go
··· 1 1 package labeling 2 2 3 3 import ( 4 - "io" 5 4 "strconv" 6 5 7 6 atproto "github.com/bluesky-social/indigo/api/atproto" ··· 11 10 ) 12 11 13 12 func (s *Server) RegisterHandlersComAtproto(e *echo.Echo) error { 14 - e.GET("/xrpc/com.atproto.account.get", s.HandleComAtprotoAccountGet) 15 - e.GET("/xrpc/com.atproto.handle.resolve", s.HandleComAtprotoIdentityResolveHandle) 16 - e.GET("/xrpc/com.atproto.repo.describe", s.HandleComAtprotoRepoDescribe) 13 + e.GET("/xrpc/com.atproto.identity.resolveHandle", s.HandleComAtprotoIdentityResolveHandle) 14 + e.GET("/xrpc/com.atproto.repo.describeRepo", s.HandleComAtprotoRepoDescribeRepo) 17 15 e.GET("/xrpc/com.atproto.repo.getRecord", s.HandleComAtprotoRepoGetRecord) 18 16 e.GET("/xrpc/com.atproto.repo.listRecords", s.HandleComAtprotoRepoListRecords) 19 - e.GET("/xrpc/com.atproto.server.getAccountsConfig", s.HandleComAtprotoServerGetAccountsConfig) 17 + e.GET("/xrpc/com.atproto.server.describeServer", s.HandleComAtprotoServerDescribeServer) 20 18 e.GET("/xrpc/com.atproto.sync.getHead", s.HandleComAtprotoSyncGetHead) 21 19 return nil 22 20 } 23 21 24 - func (s *Server) HandleComAtprotoAccountGet(c echo.Context) error { 25 - ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleComAtprotoAccountGet") 26 - defer span.End() 27 - var handleErr error 28 - // func (s *Server) handleComAtprotoAccountGet(ctx context.Context) error 29 - handleErr = s.handleComAtprotoAccountGet(ctx) 30 - if handleErr != nil { 31 - return handleErr 32 - } 33 - return nil 34 - } 35 - 36 22 func (s *Server) HandleComAtprotoIdentityResolveHandle(c echo.Context) error { 37 23 ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleComAtprotoIdentityResolveHandle") 38 24 defer span.End() ··· 47 33 return c.JSON(200, out) 48 34 } 49 35 50 - func (s *Server) HandleComAtprotoRepoDescribe(c echo.Context) error { 51 - ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleComAtprotoRepoDescribe") 36 + func (s *Server) HandleComAtprotoRepoDescribeRepo(c echo.Context) error { 37 + ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleComAtprotoRepoDescribeRepo") 52 38 defer span.End() 53 - user := c.QueryParam("user") 54 - var out *atproto.RepoDescribe_Output 39 + repo := c.QueryParam("repo") 40 + var out *atproto.RepoDescribeRepo_Output 55 41 var handleErr error 56 - // func (s *Server) handleComAtprotoRepoDescribe(ctx context.Context,user string) (*atproto.RepoDescribe_Output, error) 57 - out, handleErr = s.handleComAtprotoRepoDescribe(ctx, user) 42 + // func (s *Server) handleComAtprotoRepoDescribeRepo(ctx context.Context,repo string) (*atproto.RepoDescribeRepo_Output, error) 43 + out, handleErr = s.handleComAtprotoRepoDescribeRepo(ctx, repo) 58 44 if handleErr != nil { 59 45 return handleErr 60 46 } ··· 66 52 defer span.End() 67 53 cid := c.QueryParam("cid") 68 54 collection := c.QueryParam("collection") 55 + repo := c.QueryParam("repo") 69 56 rkey := c.QueryParam("rkey") 70 - user := c.QueryParam("user") 71 57 var out *atproto.RepoGetRecord_Output 72 58 var handleErr error 73 - // func (s *Server) handleComAtprotoRepoGetRecord(ctx context.Context,cid string,collection string,rkey string,user string) (*atproto.RepoGetRecord_Output, error) 74 - out, handleErr = s.handleComAtprotoRepoGetRecord(ctx, cid, collection, rkey, user) 59 + // func (s *Server) handleComAtprotoRepoGetRecord(ctx context.Context,cid string,collection string,repo string,rkey string) (*atproto.RepoGetRecord_Output, error) 60 + out, handleErr = s.handleComAtprotoRepoGetRecord(ctx, cid, collection, repo, rkey) 75 61 if handleErr != nil { 76 62 return handleErr 77 63 } ··· 81 67 func (s *Server) HandleComAtprotoRepoListRecords(c echo.Context) error { 82 68 ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleComAtprotoRepoListRecords") 83 69 defer span.End() 84 - after := c.QueryParam("after") 85 - before := c.QueryParam("before") 86 70 collection := c.QueryParam("collection") 87 71 88 72 var limit int ··· 95 79 } else { 96 80 limit = 50 97 81 } 82 + repo := c.QueryParam("repo") 98 83 99 84 var reverse *bool 100 85 if p := c.QueryParam("reverse"); p != "" { ··· 104 89 } 105 90 reverse = &reverse_val 106 91 } 107 - user := c.QueryParam("user") 92 + rkeyEnd := c.QueryParam("rkeyEnd") 93 + rkeyStart := c.QueryParam("rkeyStart") 108 94 var out *atproto.RepoListRecords_Output 109 95 var handleErr error 110 - // func (s *Server) handleComAtprotoRepoListRecords(ctx context.Context,after string,before string,collection string,limit int,reverse *bool,user string) (*atproto.RepoListRecords_Output, error) 111 - out, handleErr = s.handleComAtprotoRepoListRecords(ctx, after, before, collection, limit, reverse, user) 96 + // func (s *Server) handleComAtprotoRepoListRecords(ctx context.Context,collection string,limit int,repo string,reverse *bool,rkeyEnd string,rkeyStart string) (*comatprototypes.RepoListRecords_Output, error) 97 + out, handleErr = s.handleComAtprotoRepoListRecords(ctx, collection, limit, repo, reverse, rkeyEnd, rkeyStart) 112 98 if handleErr != nil { 113 99 return handleErr 114 100 } 115 101 return c.JSON(200, out) 116 102 } 117 103 118 - func (s *Server) HandleComAtprotoServerGetAccountsConfig(c echo.Context) error { 119 - ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleComAtprotoServerGetAccountsConfig") 104 + func (s *Server) HandleComAtprotoServerDescribeServer(c echo.Context) error { 105 + ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleComAtprotoServerDescribeServer") 120 106 defer span.End() 121 - var out *atproto.ServerGetAccountsConfig_Output 107 + var out *atproto.ServerDescribeServer_Output 122 108 var handleErr error 123 - // func (s *Server) handleComAtprotoServerGetAccountsConfig(ctx context.Context) (*atproto.ServerGetAccountsConfig_Output, error) 124 - out, handleErr = s.handleComAtprotoServerGetAccountsConfig(ctx) 109 + // func (s *Server) handleComAtprotoServerDescribeServer(ctx context.Context) (*atproto.ServerDescribeServer_Output, error) 110 + out, handleErr = s.handleComAtprotoServerDescribeServer(ctx) 125 111 if handleErr != nil { 126 112 return handleErr 127 113 } 128 114 return c.JSON(200, out) 129 115 } 130 116 131 - func (s *Server) HandleComAtprotoSyncGetRepo(c echo.Context) error { 132 - ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleComAtprotoSyncGetRepo") 133 - defer span.End() 134 - did := c.QueryParam("did") 135 - earliest := c.QueryParam("earliest") 136 - latest := c.QueryParam("latest") 137 - var out io.Reader 138 - var handleErr error 139 - // func (s *Server) handleComAtprotoSyncGetRepo(ctx context.Context,did string,earliest string,latest string) (io.Reader, error) 140 - out, handleErr = s.handleComAtprotoSyncGetRepo(ctx, did, earliest, latest) 141 - if handleErr != nil { 142 - return handleErr 143 - } 144 - return c.Stream(200, "application/vnd.ipld.car", out) 145 - } 146 - 147 117 func (s *Server) HandleComAtprotoSyncGetHead(c echo.Context) error { 148 118 ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleComAtprotoSyncGetHead") 149 119 defer span.End() 150 120 did := c.QueryParam("did") 151 121 var out *atproto.SyncGetHead_Output 152 122 var handleErr error 153 - // func (s *Server) handleComAtprotoSyncGetHead(ctx context.Context,did string) (*comatprototypes.SyncGetHead_Output, error) 123 + // func (s *Server) handleComAtprotoSyncGetHead(ctx context.Context,did string) (*atproto.SyncGetHead_Output, error) 154 124 out, handleErr = s.handleComAtprotoSyncGetHead(ctx, did) 155 125 if handleErr != nil { 156 126 return handleErr
+5 -10
labeling/xrpc_handlers.go
··· 13 13 "github.com/ipfs/go-cid" 14 14 ) 15 15 16 - func (s *Server) handleComAtprotoAccountGet(ctx context.Context) error { 17 - // TODO: implementation 18 - return nil 19 - } 20 - 21 16 func (s *Server) handleComAtprotoIdentityResolveHandle(ctx context.Context, handle string) (*atproto.IdentityResolveHandle_Output, error) { 22 17 // only the one handle, for labelmaker 23 18 if handle == "" { ··· 29 24 } 30 25 } 31 26 32 - func (s *Server) handleComAtprotoRepoDescribe(ctx context.Context, user string) (*atproto.RepoDescribe_Output, error) { 27 + func (s *Server) handleComAtprotoRepoDescribeRepo(ctx context.Context, repo string) (*atproto.RepoDescribeRepo_Output, error) { 33 28 panic("not yet implemented") 34 29 } 35 30 36 - func (s *Server) handleComAtprotoRepoListRecords(ctx context.Context, after string, before string, collection string, limit int, reverse *bool, user string) (*atproto.RepoListRecords_Output, error) { 31 + func (s *Server) handleComAtprotoRepoListRecords(ctx context.Context, collection string, limit int, repo string, reverse *bool, rkeyEnd string, rkeyStart string) (*atproto.RepoListRecords_Output, error) { 37 32 panic("not yet implemented") 38 33 } 39 34 40 - func (s *Server) handleComAtprotoServerGetAccountsConfig(ctx context.Context) (*atproto.ServerGetAccountsConfig_Output, error) { 35 + func (s *Server) handleComAtprotoServerDescribeServer(ctx context.Context) (*atproto.ServerDescribeServer_Output, error) { 41 36 invcode := true 42 - return &atproto.ServerGetAccountsConfig_Output{ 37 + return &atproto.ServerDescribeServer_Output{ 43 38 InviteCodeRequired: &invcode, 44 39 AvailableUserDomains: []string{}, 45 - Links: &atproto.ServerGetAccountsConfig_Links{}, 40 + Links: &atproto.ServerDescribeServer_Links{}, 46 41 }, nil 47 42 } 48 43
+16 -38
pds/handlers.go
··· 14 14 "github.com/lestrrat-go/jwx/v2/jwt" 15 15 ) 16 16 17 - func (s *Server) handleAppBskyActorGetProfile(ctx context.Context, actor string) (*appbskytypes.ActorDefs_ProfileView, error) { 17 + func (s *Server) handleAppBskyActorGetProfile(ctx context.Context, actor string) (*appbskytypes.ActorDefs_ProfileViewDetailed, error) { 18 18 profile, err := s.feedgen.GetActorProfile(ctx, actor) 19 19 if err != nil { 20 20 return nil, err 21 21 } 22 22 23 - return &appbskytypes.ActorDefs_ProfileView{ 23 + return &appbskytypes.ActorDefs_ProfileViewDetailed{ 24 24 Viewer: nil, //*ActorGetProfile_MyState `json:"myState" cborgen:"myState"` 25 25 Did: profile.Did, 26 26 Description: nil, ··· 35 35 func (s *Server) handleAppBskyActorGetSuggestions(ctx context.Context, cursor string, limit int) (*appbskytypes.ActorGetSuggestions_Output, error) { 36 36 37 37 var out appbskytypes.ActorGetSuggestions_Output 38 - out.Actors = []*appbskytypes.ActorDefs_ProfileViewBasic{} 38 + out.Actors = []*appbskytypes.ActorDefs_ProfileView{} 39 39 return &out, nil 40 40 } 41 41 ··· 173 173 174 174 for _, v := range votes { 175 175 out.Likes = append(out.Likes, &appbskytypes.FeedGetLikes_Like{ 176 - Actor: v.Actor, 176 + Actor: s.actorBasicToView(ctx, v.Actor), 177 177 IndexedAt: v.IndexedAt.Format(time.RFC3339), 178 178 CreatedAt: v.CreatedAt, 179 179 }) ··· 198 198 } 199 199 200 200 var out appbskytypes.GraphGetFollows_Output 201 - out.Subject = ai.ActorRef() 201 + out.Subject = s.actorBasicToView(ctx, ai.ActorRef()) 202 202 203 - out.Follows = []*appbskytypes.ActorDefs_WithInfo{} 203 + out.Follows = []*appbskytypes.ActorDefs_ProfileView{} 204 204 for _, f := range follows { 205 - out.Follows = append(out.Follows, &appbskytypes.ActorDefs_WithInfo{ 205 + out.Follows = append(out.Follows, &appbskytypes.ActorDefs_ProfileView{ 206 206 Handle: f.Subject.Handle, 207 207 DisplayName: f.Subject.DisplayName, 208 208 Did: f.Subject.Did, ··· 356 356 panic("not yet implemented") 357 357 } 358 358 359 - func (s *Server) handleComAtprotoAccountGet(ctx context.Context) error { 360 - return nil 361 - } 362 - 363 - func (s *Server) handleComAtprotoAccountRequestDelete(ctx context.Context) error { 364 - panic("not yet implemented") 365 - } 366 - 367 359 func (s *Server) handleComAtprotoServerRequestPasswordReset(ctx context.Context, body *comatprototypes.ServerRequestPasswordReset_Input) error { 368 360 panic("not yet implemented") 369 361 } ··· 388 380 return &comatprototypes.IdentityResolveHandle_Output{Did: u.Did}, nil 389 381 } 390 382 391 - func (s *Server) handleComAtprotoRepoBatchWrite(ctx context.Context, input *comatprototypes.RepoBatchWrite_Input) error { 383 + func (s *Server) handleComAtprotoRepoApplyWrites(ctx context.Context, body *comatprototypes.RepoApplyWrites_Input) error { 392 384 u, err := s.getUser(ctx) 393 385 if err != nil { 394 386 return err 395 387 } 396 388 397 - if u.Did != input.Did { 389 + if u.Did != body.Repo { 398 390 return fmt.Errorf("writes for non-user actors not supported (DID mismatch)") 399 391 } 400 392 401 - return s.repoman.BatchWrite(ctx, u.ID, input.Writes) 393 + return s.repoman.BatchWrite(ctx, u.ID, body.Writes) 402 394 } 403 395 404 396 func (s *Server) handleComAtprotoRepoCreateRecord(ctx context.Context, input *comatprototypes.RepoCreateRecord_Input) (*comatprototypes.RepoCreateRecord_Output, error) { ··· 424 416 return err 425 417 } 426 418 427 - if u.Did != input.Did { 419 + if u.Did != input.Repo { 428 420 return fmt.Errorf("specified DID did not match authed user") 429 421 } 430 422 431 423 return s.repoman.DeleteRecord(ctx, u.ID, input.Collection, input.Rkey) 432 424 } 433 425 434 - func (s *Server) handleComAtprotoRepoGetRecord(ctx context.Context, c string, collection string, rkey string, user string) (*comatprototypes.RepoGetRecord_Output, error) { 435 - targetUser, err := s.lookupUser(ctx, user) 426 + func (s *Server) handleComAtprotoRepoGetRecord(ctx context.Context, c string, collection string, repo string, rkey string) (*comatprototypes.RepoGetRecord_Output, error) { 427 + targetUser, err := s.lookupUser(ctx, repo) 436 428 if err != nil { 437 429 return nil, err 438 430 } ··· 467 459 panic("not yet implemented") 468 460 } 469 461 470 - func (s *Server) handleComAtprotoServerGetAccountsConfig(ctx context.Context) (*comatprototypes.ServerGetAccountsConfig_Output, error) { 462 + func (s *Server) handleComAtprotoServerDescribeServer(ctx context.Context) (*comatprototypes.ServerDescribeServer_Output, error) { 471 463 invcode := false 472 - return &comatprototypes.ServerGetAccountsConfig_Output{ 464 + return &comatprototypes.ServerDescribeServer_Output{ 473 465 InviteCodeRequired: &invcode, 474 466 AvailableUserDomains: []string{ 475 467 s.handleSuffix, 476 468 }, 477 - Links: &comatprototypes.ServerGetAccountsConfig_Links{}, 469 + Links: &comatprototypes.ServerDescribeServer_Links{}, 478 470 }, nil 479 471 } 480 472 ··· 657 649 func (s *Server) handleComAtprotoAdminTakeModerationAction(ctx context.Context, body *comatprototypes.AdminTakeModerationAction_Input) (*comatprototypes.AdminDefs_ActionView, error) { 658 650 panic("nyi") 659 651 } 660 - func (s *Server) handleComAtprotoReportCreate(ctx context.Context, body *comatprototypes.ReportCreate_Input) (*comatprototypes.ReportCreate_Output, error) { 661 - panic("nyi") 662 - } 663 - 664 - func (s *Server) handleComAtprotoHandleUpdate(ctx context.Context, body *comatprototypes.HandleUpdate_Input) error { 665 - panic("nyi") 666 - } 667 652 668 653 func (s *Server) handleComAtprotoSyncGetBlocks(ctx context.Context, cids []string, did string) (io.Reader, error) { 669 654 panic("nyi") ··· 704 689 func (s *Server) handleComAtprotoModerationCreateReport(ctx context.Context, body *comatprototypes.ModerationCreateReport_Input) (*comatprototypes.ModerationCreateReport_Output, error) { 705 690 panic("nyi") 706 691 } 707 - func (s *Server) handleComAtprotoRepoApplyWrites(ctx context.Context, body *comatprototypes.RepoApplyWrites_Input) error { 708 - panic("nyi") 709 - } 710 692 711 693 func (s *Server) handleComAtprotoRepoDescribeRepo(ctx context.Context, repo string) (*comatprototypes.RepoDescribeRepo_Output, error) { 712 694 panic("nyi") 713 695 } 714 - 715 - func (s *Server) handleComAtprotoServerDescribeServer(ctx context.Context) (*comatprototypes.ServerDescribeServer_Output, error) { 716 - panic("nyi") 717 - }
+7 -21
pds/stubs.go
··· 37 37 ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleAppBskyActorGetProfile") 38 38 defer span.End() 39 39 actor := c.QueryParam("actor") 40 - var out *appbskytypes.ActorDefs_ProfileView 40 + var out *appbskytypes.ActorDefs_ProfileViewDetailed 41 41 var handleErr error 42 - // func (s *Server) handleAppBskyActorGetProfile(ctx context.Context,actor string) (*appbskytypes.ActorDefs_ProfileView, error) 42 + // func (s *Server) handleAppBskyActorGetProfile(ctx context.Context,actor string) (*appbskytypes.ActorDefs_ProfileViewDetailed, error) 43 43 out, handleErr = s.handleAppBskyActorGetProfile(ctx, actor) 44 44 if handleErr != nil { 45 45 return handleErr ··· 487 487 e.POST("/xrpc/com.atproto.server.deleteSession", s.HandleComAtprotoServerDeleteSession) 488 488 e.GET("/xrpc/com.atproto.server.describeServer", s.HandleComAtprotoServerDescribeServer) 489 489 e.GET("/xrpc/com.atproto.server.getSession", s.HandleComAtprotoServerGetSession) 490 - e.GET("/xrpc/com.atproto.server.getAccountsConfig", s.HandleComAtprotoServerGetAccountsConfig) 491 490 e.POST("/xrpc/com.atproto.server.refreshSession", s.HandleComAtprotoServerRefreshSession) 492 491 e.POST("/xrpc/com.atproto.server.requestAccountDelete", s.HandleComAtprotoServerRequestAccountDelete) 493 492 e.POST("/xrpc/com.atproto.server.requestPasswordReset", s.HandleComAtprotoServerRequestPasswordReset) ··· 931 930 return c.JSON(200, out) 932 931 } 933 932 934 - func (s *Server) HandleComAtprotoServerGetAccountsConfig(c echo.Context) error { 935 - ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleComAtprotoServerGetAccountsConfig") 933 + func (s *Server) HandleComAtprotoServerDescribeServer(c echo.Context) error { 934 + ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleComAtprotoServerDescribeServer") 936 935 defer span.End() 937 - var out *comatprototypes.ServerGetAccountsConfig_Output 936 + var out *comatprototypes.ServerDescribeServer_Output 938 937 var handleErr error 939 - // func (s *Server) handleComAtprotoServerGetAccountsConfig(ctx context.Context) (*comatprototypes.ServerGetAccountsConfig_Output, error) 940 - out, handleErr = s.handleComAtprotoServerGetAccountsConfig(ctx) 938 + // func (s *Server) handleComAtprotoServerDescribeServer(ctx context.Context) (*comatprototypes.ServerDescribeServer_Output, error) 939 + out, handleErr = s.handleComAtprotoServerDescribeServer(ctx) 941 940 if handleErr != nil { 942 941 return handleErr 943 942 } ··· 1007 1006 return handleErr 1008 1007 } 1009 1008 return nil 1010 - } 1011 - 1012 - func (s *Server) HandleComAtprotoServerDescribeServer(c echo.Context) error { 1013 - ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleComAtprotoServerDescribeServer") 1014 - defer span.End() 1015 - var out *comatprototypes.ServerDescribeServer_Output 1016 - var handleErr error 1017 - // func (s *Server) handleComAtprotoServerDescribeServer(ctx context.Context) (*comatprototypes.ServerDescribeServer_Output, error) 1018 - out, handleErr = s.handleComAtprotoServerDescribeServer(ctx) 1019 - if handleErr != nil { 1020 - return handleErr 1021 - } 1022 - return c.JSON(200, out) 1023 1009 } 1024 1010 1025 1011 func (s *Server) HandleComAtprotoServerGetSession(c echo.Context) error {