this repo has no description
0
fork

Configure Feed

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

legxen PDS stubs+handlers

This involved some manual merging, so as not to clobber existing
implementations, at least on the handler.go side of things.

+128 -59
+52 -37
pds/handlers.go
··· 186 186 return &out, nil 187 187 } 188 188 189 - func (s *Server) handleAppBskyFeedGetRepostedBy(ctx context.Context, before string, cid string, limit int, uri string) (*appbskytypes.FeedGetRepostedBy_Output, error) { 189 + func (s *Server) handleAppBskyFeedGetRepostedBy(ctx context.Context, before string, cc string, limit int, uri string) (*appbskytypes.FeedGetRepostedBy_Output, error) { 190 190 panic("not yet implemented") 191 - //appbskytypes.FeedGetRepostedBy_Output{} 192 191 } 193 192 194 193 func (s *Server) handleAppBskyFeedGetTimeline(ctx context.Context, algorithm string, before string, limit int) (*appbskytypes.FeedGetTimeline_Output, error) { ··· 300 299 return &out, nil 301 300 } 302 301 302 + func (s *Server) handleAppBskyGraphGetMutes(ctx context.Context, before string, limit int) (*appbskytypes.GraphGetMutes_Output, error) { 303 + panic("not yet implemented") 304 + } 305 + 306 + func (s *Server) handleAppBskyGraphMute(ctx context.Context, input *appbskytypes.GraphMute_Input) error { 307 + panic("not yet implemented") 308 + } 309 + 310 + func (s *Server) handleAppBskyGraphUnmute(ctx context.Context, input *appbskytypes.GraphUnmute_Input) error { 311 + panic("not yet implemented") 312 + } 313 + 303 314 func (s *Server) handleAppBskyNotificationGetCount(ctx context.Context) (*appbskytypes.NotificationGetCount_Output, error) { 304 315 u, err := s.getUser(ctx) 305 316 if err != nil { ··· 424 435 return nil, fmt.Errorf("invite codes not currently supported") 425 436 } 426 437 427 - func (s *Server) handleComAtprotoAccountDelete(ctx context.Context) error { 438 + func (s *Server) handleComAtprotoAccountDelete(ctx context.Context, input *comatprototypes.AccountDelete_Input) error { 428 439 panic("not yet implemented") 429 440 } 430 441 ··· 432 443 return nil 433 444 } 434 445 446 + func (s *Server) handleComAtprotoAccountRequestDelete(ctx context.Context) error { 447 + panic("not yet implemented") 448 + } 449 + 435 450 func (s *Server) handleComAtprotoAccountRequestPasswordReset(ctx context.Context, input *comatprototypes.AccountRequestPasswordReset_Input) error { 436 451 panic("not yet implemented") 437 452 } ··· 440 455 panic("not yet implemented") 441 456 } 442 457 458 + func (s *Server) handleComAtprotoBlobUpload(ctx context.Context, r io.Reader, ctype string) (*comatprototypes.BlobUpload_Output, error) { 459 + panic("not yet implemented") 460 + } 461 + 443 462 func (s *Server) handleComAtprotoHandleResolve(ctx context.Context, handle string) (*comatprototypes.HandleResolve_Output, error) { 444 463 if handle == "" { 445 464 return &comatprototypes.HandleResolve_Output{Did: s.signingKey.DID()}, nil ··· 623 642 624 643 } 625 644 626 - func (s *Server) handleComAtprotoSyncGetRepo(ctx context.Context, did string, from string) (io.Reader, error) { 627 - var fromcid cid.Cid 628 - if from != "" { 629 - cc, err := cid.Decode(from) 630 - if err != nil { 631 - return nil, err 632 - } 645 + func (s *Server) handleComAtprotoSyncUpdateRepo(ctx context.Context, r io.Reader) error { 646 + panic("not yet implemented") 647 + } 633 648 634 - fromcid = cc 635 - } 649 + func (s *Server) handleComAtprotoSyncGetCheckout(ctx context.Context, commit string, did string) (io.Reader, error) { 650 + panic("not yet implemented") 651 + } 636 652 637 - targetUser, err := s.lookupUser(ctx, did) 638 - if err != nil { 639 - return nil, err 640 - } 641 - 642 - buf := new(bytes.Buffer) 643 - if err := s.repoman.ReadRepo(ctx, targetUser.ID, fromcid, buf); err != nil { 644 - return nil, err 645 - } 646 - 647 - return buf, nil 653 + func (s *Server) handleComAtprotoSyncGetCommitPath(ctx context.Context, did string, earliest string, latest string) (*comatprototypes.SyncGetCommitPath_Output, error) { 654 + panic("not yet implemented") 648 655 } 649 656 650 - func (s *Server) handleComAtprotoSyncGetRoot(ctx context.Context, did string) (*comatprototypes.SyncGetRoot_Output, error) { 657 + func (s *Server) handleComAtprotoSyncGetHead(ctx context.Context, did string) (*comatprototypes.SyncGetHead_Output, error) { 651 658 user, err := s.lookupUserByDid(ctx, did) 652 659 if err != nil { 653 660 return nil, err ··· 658 665 return nil, err 659 666 } 660 667 661 - return &comatprototypes.SyncGetRoot_Output{ 668 + return &comatprototypes.SyncGetHead_Output{ 662 669 Root: root.String(), 663 670 }, nil 664 671 } 665 672 666 - func (s *Server) handleComAtprotoSyncUpdateRepo(ctx context.Context, r io.Reader) error { 673 + func (s *Server) handleComAtprotoSyncGetRecord(ctx context.Context, collection string, commit string, did string, rkey string) (io.Reader, error) { 667 674 panic("not yet implemented") 668 675 } 669 676 670 - func (s *Server) handleComAtprotoBlobUpload(ctx context.Context, r io.Reader, ctype string) (*comatprototypes.BlobUpload_Output, error) { 671 - panic("not yet implemented") 672 - } 677 + func (s *Server) handleComAtprotoSyncGetRepo(ctx context.Context, did string, from string) (io.Reader, error) { 678 + var fromcid cid.Cid 679 + if from != "" { 680 + cc, err := cid.Decode(from) 681 + if err != nil { 682 + return nil, err 683 + } 673 684 674 - func (s *Server) handleAppBskyGraphGetMutes(ctx context.Context, before string, limit int) (*appbskytypes.GraphGetMutes_Output, error) { 675 - panic("not yet implemented") 676 - } 685 + fromcid = cc 686 + } 677 687 678 - func (s *Server) handleAppBskyGraphMute(ctx context.Context, input *appbskytypes.GraphMute_Input) error { 679 - panic("not yet implemented") 680 - } 688 + targetUser, err := s.lookupUser(ctx, did) 689 + if err != nil { 690 + return nil, err 691 + } 681 692 682 - func (s *Server) handleAppBskyGraphUnmute(ctx context.Context, input *appbskytypes.GraphUnmute_Input) error { 683 - panic("not yet implemented") 693 + buf := new(bytes.Buffer) 694 + if err := s.repoman.ReadRepo(ctx, targetUser.ID, fromcid, buf); err != nil { 695 + return nil, err 696 + } 697 + 698 + return buf, nil 684 699 }
+76 -22
pds/stubs.go
··· 30 30 e.GET("/xrpc/app.bsky.notification.getCount", s.HandleAppBskyNotificationGetCount) 31 31 e.GET("/xrpc/app.bsky.notification.list", s.HandleAppBskyNotificationList) 32 32 e.POST("/xrpc/app.bsky.notification.updateSeen", s.HandleAppBskyNotificationUpdateSeen) 33 - 34 33 return nil 35 34 } 36 35 ··· 461 460 e.POST("/xrpc/com.atproto.account.createInviteCode", s.HandleComAtprotoAccountCreateInviteCode) 462 461 e.POST("/xrpc/com.atproto.account.delete", s.HandleComAtprotoAccountDelete) 463 462 e.GET("/xrpc/com.atproto.account.get", s.HandleComAtprotoAccountGet) 463 + e.POST("/xrpc/com.atproto.account.requestDelete", s.HandleComAtprotoAccountRequestDelete) 464 464 e.POST("/xrpc/com.atproto.account.requestPasswordReset", s.HandleComAtprotoAccountRequestPasswordReset) 465 465 e.POST("/xrpc/com.atproto.account.resetPassword", s.HandleComAtprotoAccountResetPassword) 466 466 e.POST("/xrpc/com.atproto.blob.upload", s.HandleComAtprotoBlobUpload) ··· 477 477 e.POST("/xrpc/com.atproto.session.delete", s.HandleComAtprotoSessionDelete) 478 478 e.GET("/xrpc/com.atproto.session.get", s.HandleComAtprotoSessionGet) 479 479 e.POST("/xrpc/com.atproto.session.refresh", s.HandleComAtprotoSessionRefresh) 480 + e.GET("/xrpc/com.atproto.sync.getCheckout", s.HandleComAtprotoSyncGetCheckout) 481 + e.GET("/xrpc/com.atproto.sync.getCommitPath", s.HandleComAtprotoSyncGetCommitPath) 482 + e.GET("/xrpc/com.atproto.sync.getHead", s.HandleComAtprotoSyncGetHead) 483 + e.GET("/xrpc/com.atproto.sync.getRecord", s.HandleComAtprotoSyncGetRecord) 480 484 e.GET("/xrpc/com.atproto.sync.getRepo", s.HandleComAtprotoSyncGetRepo) 481 - e.GET("/xrpc/com.atproto.sync.getRoot", s.HandleComAtprotoSyncGetRoot) 482 - e.POST("/xrpc/com.atproto.sync.updateRepo", s.HandleComAtprotoSyncUpdateRepo) 483 485 return nil 484 486 } 485 487 ··· 522 524 func (s *Server) HandleComAtprotoAccountDelete(c echo.Context) error { 523 525 ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleComAtprotoAccountDelete") 524 526 defer span.End() 527 + 528 + var body comatprototypes.AccountDelete_Input 529 + if err := c.Bind(&body); err != nil { 530 + return err 531 + } 525 532 var handleErr error 526 - // func (s *Server) handleComAtprotoAccountDelete(ctx context.Context) error 527 - handleErr = s.handleComAtprotoAccountDelete(ctx) 533 + // func (s *Server) handleComAtprotoAccountDelete(ctx context.Context,body *comatprototypes.AccountDelete_Input) error 534 + handleErr = s.handleComAtprotoAccountDelete(ctx, &body) 528 535 if handleErr != nil { 529 536 return handleErr 530 537 } ··· 537 544 var handleErr error 538 545 // func (s *Server) handleComAtprotoAccountGet(ctx context.Context) error 539 546 handleErr = s.handleComAtprotoAccountGet(ctx) 547 + if handleErr != nil { 548 + return handleErr 549 + } 550 + return nil 551 + } 552 + 553 + func (s *Server) HandleComAtprotoAccountRequestDelete(c echo.Context) error { 554 + ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleComAtprotoAccountRequestDelete") 555 + defer span.End() 556 + var handleErr error 557 + // func (s *Server) handleComAtprotoAccountRequestDelete(ctx context.Context) error 558 + handleErr = s.handleComAtprotoAccountRequestDelete(ctx) 540 559 if handleErr != nil { 541 560 return handleErr 542 561 } ··· 813 832 return c.JSON(200, out) 814 833 } 815 834 816 - func (s *Server) HandleComAtprotoSyncGetRepo(c echo.Context) error { 817 - ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleComAtprotoSyncGetRepo") 835 + func (s *Server) HandleComAtprotoSyncGetCheckout(c echo.Context) error { 836 + ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleComAtprotoSyncGetCheckout") 818 837 defer span.End() 838 + commit := c.QueryParam("commit") 819 839 did := c.QueryParam("did") 820 - from := c.QueryParam("from") 821 840 var out io.Reader 822 841 var handleErr error 823 - // func (s *Server) handleComAtprotoSyncGetRepo(ctx context.Context,did string,from string) (io.Reader, error) 824 - out, handleErr = s.handleComAtprotoSyncGetRepo(ctx, did, from) 842 + // func (s *Server) handleComAtprotoSyncGetCheckout(ctx context.Context,commit string,did string) (io.Reader, error) 843 + out, handleErr = s.handleComAtprotoSyncGetCheckout(ctx, commit, did) 825 844 if handleErr != nil { 826 845 return handleErr 827 846 } 828 - return c.Stream(200, "application/octet-stream", out) 847 + return c.Stream(200, "application/vnd.ipld.car", out) 829 848 } 830 849 831 - func (s *Server) HandleComAtprotoSyncGetRoot(c echo.Context) error { 832 - ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleComAtprotoSyncGetRoot") 850 + func (s *Server) HandleComAtprotoSyncGetCommitPath(c echo.Context) error { 851 + ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleComAtprotoSyncGetCommitPath") 833 852 defer span.End() 834 853 did := c.QueryParam("did") 835 - var out *comatprototypes.SyncGetRoot_Output 854 + earliest := c.QueryParam("earliest") 855 + latest := c.QueryParam("latest") 856 + var out *comatprototypes.SyncGetCommitPath_Output 836 857 var handleErr error 837 - // func (s *Server) handleComAtprotoSyncGetRoot(ctx context.Context,did string) (*comatprototypes.SyncGetRoot_Output, error) 838 - out, handleErr = s.handleComAtprotoSyncGetRoot(ctx, did) 858 + // func (s *Server) handleComAtprotoSyncGetCommitPath(ctx context.Context,did string,earliest string,latest string) (*comatprototypes.SyncGetCommitPath_Output, error) 859 + out, handleErr = s.handleComAtprotoSyncGetCommitPath(ctx, did, earliest, latest) 860 + if handleErr != nil { 861 + return handleErr 862 + } 863 + return c.JSON(200, out) 864 + } 865 + 866 + func (s *Server) HandleComAtprotoSyncGetHead(c echo.Context) error { 867 + ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleComAtprotoSyncGetHead") 868 + defer span.End() 869 + did := c.QueryParam("did") 870 + var out *comatprototypes.SyncGetHead_Output 871 + var handleErr error 872 + // func (s *Server) handleComAtprotoSyncGetHead(ctx context.Context,did string) (*comatprototypes.SyncGetHead_Output, error) 873 + out, handleErr = s.handleComAtprotoSyncGetHead(ctx, did) 839 874 if handleErr != nil { 840 875 return handleErr 841 876 } 842 877 return c.JSON(200, out) 843 878 } 844 879 845 - func (s *Server) HandleComAtprotoSyncUpdateRepo(c echo.Context) error { 846 - ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleComAtprotoSyncUpdateRepo") 880 + func (s *Server) HandleComAtprotoSyncGetRecord(c echo.Context) error { 881 + ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleComAtprotoSyncGetRecord") 882 + defer span.End() 883 + collection := c.QueryParam("collection") 884 + commit := c.QueryParam("commit") 885 + did := c.QueryParam("did") 886 + rkey := c.QueryParam("rkey") 887 + var out io.Reader 888 + var handleErr error 889 + // func (s *Server) handleComAtprotoSyncGetRecord(ctx context.Context,collection string,commit string,did string,rkey string) (io.Reader, error) 890 + out, handleErr = s.handleComAtprotoSyncGetRecord(ctx, collection, commit, did, rkey) 891 + if handleErr != nil { 892 + return handleErr 893 + } 894 + return c.Stream(200, "application/vnd.ipld.car", out) 895 + } 896 + 897 + func (s *Server) HandleComAtprotoSyncGetRepo(c echo.Context) error { 898 + ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleComAtprotoSyncGetRepo") 847 899 defer span.End() 848 - body := c.Request().Body 900 + did := c.QueryParam("did") 901 + from := c.QueryParam("from") 902 + var out io.Reader 849 903 var handleErr error 850 - // func (s *Server) handleComAtprotoSyncUpdateRepo(ctx context.Context,r io.Reader) error 851 - handleErr = s.handleComAtprotoSyncUpdateRepo(ctx, body) 904 + // func (s *Server) handleComAtprotoSyncGetRepo(ctx context.Context,did string,from string) (io.Reader, error) 905 + out, handleErr = s.handleComAtprotoSyncGetRepo(ctx, did, from) 852 906 if handleErr != nil { 853 907 return handleErr 854 908 } 855 - return nil 909 + return c.Stream(200, "application/vnd.ipld.car", out) 856 910 }