fork of indigo with slightly nicer lexgen

incremental implementation of xrpc methods

+2 -2
api/atproto/accountcreate.go
··· 20 20 } 21 21 22 22 type AccountCreate_Output struct { 23 + Handle string `json:"handle" cborgen:"handle"` 24 + Did string `json:"did" cborgen:"did"` 23 25 AccessJwt string `json:"accessJwt" cborgen:"accessJwt"` 24 26 RefreshJwt string `json:"refreshJwt" cborgen:"refreshJwt"` 25 - Handle string `json:"handle" cborgen:"handle"` 26 - Did string `json:"did" cborgen:"did"` 27 27 } 28 28 29 29 func AccountCreate(ctx context.Context, c *xrpc.Client, input AccountCreate_Input) (*AccountCreate_Output, error) {
+21 -21
api/atproto/repobatchWrite.go
··· 14 14 func init() { 15 15 } 16 16 17 - type RepoBatchWrite_Create struct { 18 - Action string `json:"action" cborgen:"action"` 19 - Collection string `json:"collection" cborgen:"collection"` 20 - Rkey *string `json:"rkey" cborgen:"rkey"` 21 - Value any `json:"value" cborgen:"value"` 22 - } 23 - 24 - type RepoBatchWrite_Update struct { 25 - Action string `json:"action" cborgen:"action"` 26 - Collection string `json:"collection" cborgen:"collection"` 27 - Rkey string `json:"rkey" cborgen:"rkey"` 28 - Value any `json:"value" cborgen:"value"` 29 - } 30 - 31 - type RepoBatchWrite_Delete struct { 32 - Action string `json:"action" cborgen:"action"` 33 - Collection string `json:"collection" cborgen:"collection"` 34 - Rkey string `json:"rkey" cborgen:"rkey"` 35 - } 36 - 37 17 type RepoBatchWrite_Input struct { 18 + Did string `json:"did" cborgen:"did"` 38 19 Validate *bool `json:"validate" cborgen:"validate"` 39 20 Writes []*RepoBatchWrite_Input_Writes_Elem `json:"writes" cborgen:"writes"` 40 - Did string `json:"did" cborgen:"did"` 41 21 } 42 22 43 23 type RepoBatchWrite_Input_Writes_Elem struct { ··· 78 58 default: 79 59 return fmt.Errorf("closed enums must have a matching value") 80 60 } 61 + } 62 + 63 + type RepoBatchWrite_Create struct { 64 + Action string `json:"action" cborgen:"action"` 65 + Collection string `json:"collection" cborgen:"collection"` 66 + Rkey *string `json:"rkey" cborgen:"rkey"` 67 + Value any `json:"value" cborgen:"value"` 68 + } 69 + 70 + type RepoBatchWrite_Update struct { 71 + Value any `json:"value" cborgen:"value"` 72 + Action string `json:"action" cborgen:"action"` 73 + Collection string `json:"collection" cborgen:"collection"` 74 + Rkey string `json:"rkey" cborgen:"rkey"` 75 + } 76 + 77 + type RepoBatchWrite_Delete struct { 78 + Action string `json:"action" cborgen:"action"` 79 + Collection string `json:"collection" cborgen:"collection"` 80 + Rkey string `json:"rkey" cborgen:"rkey"` 81 81 } 82 82 83 83 func RepoBatchWrite(ctx context.Context, c *xrpc.Client, input RepoBatchWrite_Input) error {
+3 -3
api/atproto/repocreateRecord.go
··· 12 12 } 13 13 14 14 type RepoCreateRecord_Input struct { 15 - Validate *bool `json:"validate" cborgen:"validate"` 16 - Record any `json:"record" cborgen:"record"` 17 15 Did string `json:"did" cborgen:"did"` 18 16 Collection string `json:"collection" cborgen:"collection"` 17 + Validate *bool `json:"validate" cborgen:"validate"` 18 + Record any `json:"record" cborgen:"record"` 19 19 } 20 20 21 21 type RepoCreateRecord_Output struct { 22 - Uri string `json:"uri" cborgen:"uri"` 23 22 Cid string `json:"cid" cborgen:"cid"` 23 + Uri string `json:"uri" cborgen:"uri"` 24 24 } 25 25 26 26 func RepoCreateRecord(ctx context.Context, c *xrpc.Client, input RepoCreateRecord_Input) (*RepoCreateRecord_Output, error) {
+2 -2
api/atproto/repodescribe.go
··· 12 12 } 13 13 14 14 type RepoDescribe_Output struct { 15 + Handle string `json:"handle" cborgen:"handle"` 16 + Did string `json:"did" cborgen:"did"` 15 17 DidDoc any `json:"didDoc" cborgen:"didDoc"` 16 18 Collections []string `json:"collections" cborgen:"collections"` 17 19 HandleIsCorrect bool `json:"handleIsCorrect" cborgen:"handleIsCorrect"` 18 - Handle string `json:"handle" cborgen:"handle"` 19 - Did string `json:"did" cborgen:"did"` 20 20 } 21 21 22 22 func RepoDescribe(ctx context.Context, c *xrpc.Client, user string) (*RepoDescribe_Output, error) {
+1 -1
api/atproto/repogetRecord.go
··· 12 12 } 13 13 14 14 type RepoGetRecord_Output struct { 15 + Value any `json:"value" cborgen:"value"` 15 16 Uri string `json:"uri" cborgen:"uri"` 16 17 Cid *string `json:"cid" cborgen:"cid"` 17 - Value any `json:"value" cborgen:"value"` 18 18 } 19 19 20 20 func RepoGetRecord(ctx context.Context, c *xrpc.Client, cid string, collection string, rkey string, user string) (*RepoGetRecord_Output, error) {
+1 -1
api/atproto/sessioncreate.go
··· 17 17 } 18 18 19 19 type SessionCreate_Output struct { 20 - Did string `json:"did" cborgen:"did"` 21 20 AccessJwt string `json:"accessJwt" cborgen:"accessJwt"` 22 21 RefreshJwt string `json:"refreshJwt" cborgen:"refreshJwt"` 23 22 Handle string `json:"handle" cborgen:"handle"` 23 + Did string `json:"did" cborgen:"did"` 24 24 } 25 25 26 26 func SessionCreate(ctx context.Context, c *xrpc.Client, input SessionCreate_Input) (*SessionCreate_Output, error) {
+1 -1
api/atproto/sessionrefresh.go
··· 12 12 } 13 13 14 14 type SessionRefresh_Output struct { 15 + Did string `json:"did" cborgen:"did"` 15 16 AccessJwt string `json:"accessJwt" cborgen:"accessJwt"` 16 17 RefreshJwt string `json:"refreshJwt" cborgen:"refreshJwt"` 17 18 Handle string `json:"handle" cborgen:"handle"` 18 - Did string `json:"did" cborgen:"did"` 19 19 } 20 20 21 21 func SessionRefresh(ctx context.Context, c *xrpc.Client) (*SessionRefresh_Output, error) {
+6 -6
api/bsky/actorgetProfile.go
··· 12 12 } 13 13 14 14 type ActorGetProfile_Output struct { 15 + Handle string `json:"handle" cborgen:"handle"` 16 + Creator string `json:"creator" cborgen:"creator"` 17 + DisplayName *string `json:"displayName" cborgen:"displayName"` 15 18 Description *string `json:"description" cborgen:"description"` 16 19 FollowersCount int64 `json:"followersCount" cborgen:"followersCount"` 17 20 MembersCount int64 `json:"membersCount" cborgen:"membersCount"` 18 - PostsCount int64 `json:"postsCount" cborgen:"postsCount"` 19 21 Did string `json:"did" cborgen:"did"` 20 22 Declaration *SystemDeclRef `json:"declaration" cborgen:"declaration"` 21 - Handle string `json:"handle" cborgen:"handle"` 22 23 MyState *ActorGetProfile_MyState `json:"myState" cborgen:"myState"` 23 - Creator string `json:"creator" cborgen:"creator"` 24 - DisplayName *string `json:"displayName" cborgen:"displayName"` 25 24 FollowsCount int64 `json:"followsCount" cborgen:"followsCount"` 25 + PostsCount int64 `json:"postsCount" cborgen:"postsCount"` 26 26 } 27 27 28 28 type ActorGetProfile_MyState struct { 29 - Follow string `json:"follow" cborgen:"follow"` 30 - Member string `json:"member" cborgen:"member"` 29 + Follow *string `json:"follow" cborgen:"follow"` 30 + Member *string `json:"member" cborgen:"member"` 31 31 } 32 32 33 33 func ActorGetProfile(ctx context.Context, c *xrpc.Client, actor string) (*ActorGetProfile_Output, error) {
+2 -2
api/bsky/actorgetSuggestions.go
··· 17 17 } 18 18 19 19 type ActorGetSuggestions_Actor struct { 20 - MyState *ActorGetSuggestions_MyState `json:"myState" cborgen:"myState"` 21 20 Did string `json:"did" cborgen:"did"` 22 21 Declaration *SystemDeclRef `json:"declaration" cborgen:"declaration"` 23 22 Handle string `json:"handle" cborgen:"handle"` 24 23 DisplayName *string `json:"displayName" cborgen:"displayName"` 25 24 Description *string `json:"description" cborgen:"description"` 26 25 IndexedAt *string `json:"indexedAt" cborgen:"indexedAt"` 26 + MyState *ActorGetSuggestions_MyState `json:"myState" cborgen:"myState"` 27 27 } 28 28 29 29 type ActorGetSuggestions_MyState struct { 30 - Follow string `json:"follow" cborgen:"follow"` 30 + Follow *string `json:"follow" cborgen:"follow"` 31 31 } 32 32 33 33 func ActorGetSuggestions(ctx context.Context, c *xrpc.Client, cursor string, limit int64) (*ActorGetSuggestions_Output, error) {
+1 -1
api/bsky/actorref.go
··· 11 11 } 12 12 13 13 type ActorRef_WithInfo struct { 14 - Did string `json:"did" cborgen:"did"` 15 14 Declaration *SystemDeclRef `json:"declaration" cborgen:"declaration"` 16 15 Handle string `json:"handle" cborgen:"handle"` 17 16 DisplayName *string `json:"displayName" cborgen:"displayName"` 17 + Did string `json:"did" cborgen:"did"` 18 18 }
+3 -3
api/bsky/actorsearch.go
··· 17 17 } 18 18 19 19 type ActorSearch_User struct { 20 + Did string `json:"did" cborgen:"did"` 21 + Declaration *SystemDeclRef `json:"declaration" cborgen:"declaration"` 22 + Handle string `json:"handle" cborgen:"handle"` 20 23 DisplayName *string `json:"displayName" cborgen:"displayName"` 21 24 Description *string `json:"description" cborgen:"description"` 22 25 IndexedAt *string `json:"indexedAt" cborgen:"indexedAt"` 23 - Did string `json:"did" cborgen:"did"` 24 - Declaration *SystemDeclRef `json:"declaration" cborgen:"declaration"` 25 - Handle string `json:"handle" cborgen:"handle"` 26 26 } 27 27 28 28 func ActorSearch(ctx context.Context, c *xrpc.Client, before string, limit int64, term string) (*ActorSearch_Output, error) {
+5 -5
api/bsky/actorsearchTypeahead.go
··· 11 11 func init() { 12 12 } 13 13 14 - type ActorSearchTypeahead_Output struct { 15 - Users []*ActorSearchTypeahead_User `json:"users" cborgen:"users"` 16 - } 17 - 18 14 type ActorSearchTypeahead_User struct { 15 + DisplayName *string `json:"displayName" cborgen:"displayName"` 19 16 Did string `json:"did" cborgen:"did"` 20 17 Declaration *SystemDeclRef `json:"declaration" cborgen:"declaration"` 21 18 Handle string `json:"handle" cborgen:"handle"` 22 - DisplayName *string `json:"displayName" cborgen:"displayName"` 19 + } 20 + 21 + type ActorSearchTypeahead_Output struct { 22 + Users []*ActorSearchTypeahead_User `json:"users" cborgen:"users"` 23 23 } 24 24 25 25 func ActorSearchTypeahead(ctx context.Context, c *xrpc.Client, limit int64, term string) (*ActorSearchTypeahead_Output, error) {
+3 -3
api/bsky/actorupdateProfile.go
··· 12 12 } 13 13 14 14 type ActorUpdateProfile_Input struct { 15 - DisplayName string `json:"displayName" cborgen:"displayName"` 16 - Description string `json:"description" cborgen:"description"` 17 - Did string `json:"did" cborgen:"did"` 15 + Did *string `json:"did" cborgen:"did"` 16 + DisplayName *string `json:"displayName" cborgen:"displayName"` 17 + Description *string `json:"description" cborgen:"description"` 18 18 } 19 19 20 20 type ActorUpdateProfile_Output struct {
+14 -14
api/bsky/feedembed.go
··· 12 12 func init() { 13 13 } 14 14 15 + type FeedEmbed_Record struct { 16 + Record any `json:"record" cborgen:"record"` 17 + Type string `json:"type" cborgen:"type"` 18 + Author *ActorRef_WithInfo `json:"author" cborgen:"author"` 19 + } 20 + 21 + type FeedEmbed_External struct { 22 + ImageUri string `json:"imageUri" cborgen:"imageUri"` 23 + Type string `json:"type" cborgen:"type"` 24 + Uri string `json:"uri" cborgen:"uri"` 25 + Title string `json:"title" cborgen:"title"` 26 + Description string `json:"description" cborgen:"description"` 27 + } 28 + 15 29 type FeedEmbed struct { 16 30 Items []*FeedEmbed_Items_Elem `json:"items" cborgen:"items"` 17 31 } ··· 61 75 Thumb *util.Blob `json:"thumb" cborgen:"thumb"` 62 76 Original *util.Blob `json:"original" cborgen:"original"` 63 77 } 64 - 65 - type FeedEmbed_Record struct { 66 - Type string `json:"type" cborgen:"type"` 67 - Author *ActorRef_WithInfo `json:"author" cborgen:"author"` 68 - Record any `json:"record" cborgen:"record"` 69 - } 70 - 71 - type FeedEmbed_External struct { 72 - Uri string `json:"uri" cborgen:"uri"` 73 - Title string `json:"title" cborgen:"title"` 74 - Description string `json:"description" cborgen:"description"` 75 - ImageUri string `json:"imageUri" cborgen:"imageUri"` 76 - Type string `json:"type" cborgen:"type"` 77 - }
+11 -11
api/bsky/feedgetAuthorFeed.go
··· 12 12 } 13 13 14 14 type FeedGetAuthorFeed_Output struct { 15 - Feed []*FeedGetAuthorFeed_FeedItem `json:"feed" cborgen:"feed"` 16 15 Cursor *string `json:"cursor" cborgen:"cursor"` 16 + Feed []*FeedGetAuthorFeed_FeedItem `json:"feed" cborgen:"feed"` 17 17 } 18 18 19 19 type FeedGetAuthorFeed_FeedItem struct { 20 - IndexedAt string `json:"indexedAt" cborgen:"indexedAt"` 21 - RepostedBy *ActorRef_WithInfo `json:"repostedBy" cborgen:"repostedBy"` 22 20 ReplyCount int64 `json:"replyCount" cborgen:"replyCount"` 21 + UpvoteCount int64 `json:"upvoteCount" cborgen:"upvoteCount"` 22 + MyState *FeedGetAuthorFeed_MyState `json:"myState" cborgen:"myState"` 23 + Uri string `json:"uri" cborgen:"uri"` 23 24 Author *ActorRef_WithInfo `json:"author" cborgen:"author"` 24 - TrendedBy *ActorRef_WithInfo `json:"trendedBy" cborgen:"trendedBy"` 25 + RepostedBy *ActorRef_WithInfo `json:"repostedBy" cborgen:"repostedBy"` 25 26 Record any `json:"record" cborgen:"record"` 26 27 Embed *FeedEmbed `json:"embed" cborgen:"embed"` 27 - RepostCount int64 `json:"repostCount" cborgen:"repostCount"` 28 - UpvoteCount int64 `json:"upvoteCount" cborgen:"upvoteCount"` 29 - Uri string `json:"uri" cborgen:"uri"` 30 28 Cid string `json:"cid" cborgen:"cid"` 29 + TrendedBy *ActorRef_WithInfo `json:"trendedBy" cborgen:"trendedBy"` 30 + RepostCount int64 `json:"repostCount" cborgen:"repostCount"` 31 31 DownvoteCount int64 `json:"downvoteCount" cborgen:"downvoteCount"` 32 - MyState *FeedGetAuthorFeed_MyState `json:"myState" cborgen:"myState"` 32 + IndexedAt string `json:"indexedAt" cborgen:"indexedAt"` 33 33 } 34 34 35 35 type FeedGetAuthorFeed_MyState struct { 36 - Repost string `json:"repost" cborgen:"repost"` 37 - Upvote string `json:"upvote" cborgen:"upvote"` 38 - Downvote string `json:"downvote" cborgen:"downvote"` 36 + Downvote *string `json:"downvote" cborgen:"downvote"` 37 + Repost *string `json:"repost" cborgen:"repost"` 38 + Upvote *string `json:"upvote" cborgen:"upvote"` 39 39 } 40 40 41 41 func FeedGetAuthorFeed(ctx context.Context, c *xrpc.Client, author string, before string, limit int64) (*FeedGetAuthorFeed_Output, error) {
+17 -17
api/bsky/feedgetPostThread.go
··· 14 14 func init() { 15 15 } 16 16 17 + type FeedGetPostThread_NotFoundPost struct { 18 + Uri string `json:"uri" cborgen:"uri"` 19 + NotFound bool `json:"notFound" cborgen:"notFound"` 20 + } 21 + 22 + type FeedGetPostThread_MyState struct { 23 + Repost *string `json:"repost" cborgen:"repost"` 24 + Upvote *string `json:"upvote" cborgen:"upvote"` 25 + Downvote *string `json:"downvote" cborgen:"downvote"` 26 + } 27 + 17 28 type FeedGetPostThread_Output struct { 18 29 Thread *FeedGetPostThread_Output_Thread `json:"thread" cborgen:"thread"` 19 30 } ··· 52 63 } 53 64 54 65 type FeedGetPostThread_Post struct { 66 + MyState *FeedGetPostThread_MyState `json:"myState" cborgen:"myState"` 67 + Uri string `json:"uri" cborgen:"uri"` 68 + Parent *FeedGetPostThread_Post_Parent `json:"parent" cborgen:"parent"` 69 + ReplyCount int64 `json:"replyCount" cborgen:"replyCount"` 70 + Replies []*FeedGetPostThread_Post_Replies_Elem `json:"replies" cborgen:"replies"` 71 + UpvoteCount int64 `json:"upvoteCount" cborgen:"upvoteCount"` 55 72 DownvoteCount int64 `json:"downvoteCount" cborgen:"downvoteCount"` 56 73 IndexedAt string `json:"indexedAt" cborgen:"indexedAt"` 57 - Replies []*FeedGetPostThread_Post_Replies_Elem `json:"replies" cborgen:"replies"` 58 - Uri string `json:"uri" cborgen:"uri"` 59 74 Cid string `json:"cid" cborgen:"cid"` 60 75 Author *ActorRef_WithInfo `json:"author" cborgen:"author"` 61 76 Record any `json:"record" cborgen:"record"` 62 77 Embed *FeedEmbed `json:"embed" cborgen:"embed"` 63 - Parent *FeedGetPostThread_Post_Parent `json:"parent" cborgen:"parent"` 64 - ReplyCount int64 `json:"replyCount" cborgen:"replyCount"` 65 78 RepostCount int64 `json:"repostCount" cborgen:"repostCount"` 66 - UpvoteCount int64 `json:"upvoteCount" cborgen:"upvoteCount"` 67 - MyState *FeedGetPostThread_MyState `json:"myState" cborgen:"myState"` 68 79 } 69 80 70 81 type FeedGetPostThread_Post_Parent struct { ··· 131 142 default: 132 143 return nil 133 144 } 134 - } 135 - 136 - type FeedGetPostThread_NotFoundPost struct { 137 - Uri string `json:"uri" cborgen:"uri"` 138 - NotFound bool `json:"notFound" cborgen:"notFound"` 139 - } 140 - 141 - type FeedGetPostThread_MyState struct { 142 - Repost string `json:"repost" cborgen:"repost"` 143 - Upvote string `json:"upvote" cborgen:"upvote"` 144 - Downvote string `json:"downvote" cborgen:"downvote"` 145 145 } 146 146 147 147 func FeedGetPostThread(ctx context.Context, c *xrpc.Client, depth int64, uri string) (*FeedGetPostThread_Output, error) {
+2 -2
api/bsky/feedgetRepostedBy.go
··· 12 12 } 13 13 14 14 type FeedGetRepostedBy_Output struct { 15 + Cursor *string `json:"cursor" cborgen:"cursor"` 16 + RepostedBy []*FeedGetRepostedBy_RepostedBy `json:"repostedBy" cborgen:"repostedBy"` 15 17 Uri string `json:"uri" cborgen:"uri"` 16 18 Cid *string `json:"cid" cborgen:"cid"` 17 - Cursor *string `json:"cursor" cborgen:"cursor"` 18 - RepostedBy []*FeedGetRepostedBy_RepostedBy `json:"repostedBy" cborgen:"repostedBy"` 19 19 } 20 20 21 21 type FeedGetRepostedBy_RepostedBy struct {
+10 -10
api/bsky/feedgetTimeline.go
··· 11 11 func init() { 12 12 } 13 13 14 - type FeedGetTimeline_MyState struct { 15 - Repost string `json:"repost" cborgen:"repost"` 16 - Upvote string `json:"upvote" cborgen:"upvote"` 17 - Downvote string `json:"downvote" cborgen:"downvote"` 18 - } 19 - 20 14 type FeedGetTimeline_Output struct { 21 15 Cursor *string `json:"cursor" cborgen:"cursor"` 22 16 Feed []*FeedGetTimeline_FeedItem `json:"feed" cborgen:"feed"` 23 17 } 24 18 25 19 type FeedGetTimeline_FeedItem struct { 20 + IndexedAt string `json:"indexedAt" cborgen:"indexedAt"` 21 + Uri string `json:"uri" cborgen:"uri"` 22 + Record any `json:"record" cborgen:"record"` 26 23 ReplyCount int64 `json:"replyCount" cborgen:"replyCount"` 27 - TrendedBy *ActorRef_WithInfo `json:"trendedBy" cborgen:"trendedBy"` 28 24 RepostedBy *ActorRef_WithInfo `json:"repostedBy" cborgen:"repostedBy"` 29 25 Embed *FeedEmbed `json:"embed" cborgen:"embed"` 30 - Record any `json:"record" cborgen:"record"` 31 26 RepostCount int64 `json:"repostCount" cborgen:"repostCount"` 32 27 UpvoteCount int64 `json:"upvoteCount" cborgen:"upvoteCount"` 33 28 DownvoteCount int64 `json:"downvoteCount" cborgen:"downvoteCount"` 34 - IndexedAt string `json:"indexedAt" cborgen:"indexedAt"` 35 - Uri string `json:"uri" cborgen:"uri"` 36 29 Cid string `json:"cid" cborgen:"cid"` 37 30 Author *ActorRef_WithInfo `json:"author" cborgen:"author"` 31 + TrendedBy *ActorRef_WithInfo `json:"trendedBy" cborgen:"trendedBy"` 38 32 MyState *FeedGetTimeline_MyState `json:"myState" cborgen:"myState"` 33 + } 34 + 35 + type FeedGetTimeline_MyState struct { 36 + Repost *string `json:"repost" cborgen:"repost"` 37 + Upvote *string `json:"upvote" cborgen:"upvote"` 38 + Downvote *string `json:"downvote" cborgen:"downvote"` 39 39 } 40 40 41 41 func FeedGetTimeline(ctx context.Context, c *xrpc.Client, algorithm string, before string, limit int64) (*FeedGetTimeline_Output, error) {
+1 -1
api/bsky/feedgetVotes.go
··· 19 19 } 20 20 21 21 type FeedGetVotes_Vote struct { 22 + Actor *ActorRef_WithInfo `json:"actor" cborgen:"actor"` 22 23 Direction string `json:"direction" cborgen:"direction"` 23 24 IndexedAt string `json:"indexedAt" cborgen:"indexedAt"` 24 25 CreatedAt string `json:"createdAt" cborgen:"createdAt"` 25 - Actor *ActorRef_WithInfo `json:"actor" cborgen:"actor"` 26 26 } 27 27 28 28 func FeedGetVotes(ctx context.Context, c *xrpc.Client, before string, cid string, direction string, limit int64, uri string) (*FeedGetVotes_Output, error) {
+10 -10
api/bsky/feedpost.go
··· 11 11 util.RegisterType("app.bsky.feed.post", FeedPost{}) 12 12 } 13 13 14 - // RECORDTYPE: FeedPost 15 - type FeedPost struct { 16 - LexiconTypeID string `json:"$type" cborgen:"$type,const=app.bsky.feed.post"` 17 - Text string `json:"text" cborgen:"text"` 18 - Entities []*FeedPost_Entity `json:"entities" cborgen:"entities"` 19 - Reply *FeedPost_ReplyRef `json:"reply" cborgen:"reply"` 20 - CreatedAt string `json:"createdAt" cborgen:"createdAt"` 21 - } 22 - 23 14 type FeedPost_ReplyRef struct { 24 15 Root *comatprototypes.RepoStrongRef `json:"root" cborgen:"root"` 25 16 Parent *comatprototypes.RepoStrongRef `json:"parent" cborgen:"parent"` ··· 32 23 } 33 24 34 25 type FeedPost_TextSlice struct { 26 + Start int64 `json:"start" cborgen:"start"` 35 27 End int64 `json:"end" cborgen:"end"` 36 - Start int64 `json:"start" cborgen:"start"` 28 + } 29 + 30 + // RECORDTYPE: FeedPost 31 + type FeedPost struct { 32 + LexiconTypeID string `json:"$type" cborgen:"$type,const=app.bsky.feed.post"` 33 + Text string `json:"text" cborgen:"text"` 34 + Entities []*FeedPost_Entity `json:"entities" cborgen:"entities"` 35 + Reply *FeedPost_ReplyRef `json:"reply" cborgen:"reply"` 36 + CreatedAt string `json:"createdAt" cborgen:"createdAt"` 37 37 }
+2 -2
api/bsky/feedsetVote.go
··· 18 18 } 19 19 20 20 type FeedSetVote_Output struct { 21 - Upvote string `json:"upvote" cborgen:"upvote"` 22 - Downvote string `json:"downvote" cborgen:"downvote"` 21 + Upvote *string `json:"upvote" cborgen:"upvote"` 22 + Downvote *string `json:"downvote" cborgen:"downvote"` 23 23 } 24 24 25 25 func FeedSetVote(ctx context.Context, c *xrpc.Client, input FeedSetVote_Input) (*FeedSetVote_Output, error) {
+1 -1
api/bsky/graphassertion.go
··· 13 13 // RECORDTYPE: GraphAssertion 14 14 type GraphAssertion struct { 15 15 LexiconTypeID string `json:"$type" cborgen:"$type,const=app.bsky.graph.assertion"` 16 + Subject *ActorRef `json:"subject" cborgen:"subject"` 16 17 CreatedAt string `json:"createdAt" cborgen:"createdAt"` 17 18 Assertion string `json:"assertion" cborgen:"assertion"` 18 - Subject *ActorRef `json:"subject" cborgen:"subject"` 19 19 }
+1 -1
api/bsky/graphfollow.go
··· 13 13 // RECORDTYPE: GraphFollow 14 14 type GraphFollow struct { 15 15 LexiconTypeID string `json:"$type" cborgen:"$type,const=app.bsky.graph.follow"` 16 - Subject *ActorRef `json:"subject" cborgen:"subject"` 17 16 CreatedAt string `json:"createdAt" cborgen:"createdAt"` 17 + Subject *ActorRef `json:"subject" cborgen:"subject"` 18 18 }
+1 -1
api/bsky/graphgetAssertions.go
··· 17 17 } 18 18 19 19 type GraphGetAssertions_Assertion struct { 20 - Cid string `json:"cid" cborgen:"cid"` 21 20 Assertion string `json:"assertion" cborgen:"assertion"` 22 21 Confirmation *GraphGetAssertions_Confirmation `json:"confirmation" cborgen:"confirmation"` 23 22 Author *ActorRef_WithInfo `json:"author" cborgen:"author"` ··· 25 24 IndexedAt string `json:"indexedAt" cborgen:"indexedAt"` 26 25 CreatedAt string `json:"createdAt" cborgen:"createdAt"` 27 26 Uri string `json:"uri" cborgen:"uri"` 27 + Cid string `json:"cid" cborgen:"cid"` 28 28 } 29 29 30 30 type GraphGetAssertions_Confirmation struct {
+6 -6
api/bsky/graphgetFollowers.go
··· 12 12 } 13 13 14 14 type GraphGetFollowers_Output struct { 15 + Followers []*GraphGetFollowers_Follower `json:"followers" cborgen:"followers"` 15 16 Subject *GraphGetFollowers_Subject `json:"subject" cborgen:"subject"` 16 17 Cursor *string `json:"cursor" cborgen:"cursor"` 17 - Followers []*GraphGetFollowers_Follower `json:"followers" cborgen:"followers"` 18 18 } 19 19 20 20 type GraphGetFollowers_Subject struct { 21 - Did string `json:"did" cborgen:"did"` 22 - Declaration *SystemDeclRef `json:"declaration" cborgen:"declaration"` 23 21 Handle string `json:"handle" cborgen:"handle"` 24 22 DisplayName *string `json:"displayName" cborgen:"displayName"` 23 + Did string `json:"did" cborgen:"did"` 24 + Declaration *SystemDeclRef `json:"declaration" cborgen:"declaration"` 25 25 } 26 26 27 27 type GraphGetFollowers_Follower struct { 28 + Declaration *SystemDeclRef `json:"declaration" cborgen:"declaration"` 29 + Handle string `json:"handle" cborgen:"handle"` 30 + DisplayName *string `json:"displayName" cborgen:"displayName"` 28 31 CreatedAt *string `json:"createdAt" cborgen:"createdAt"` 29 32 IndexedAt string `json:"indexedAt" cborgen:"indexedAt"` 30 33 Did string `json:"did" cborgen:"did"` 31 - Declaration *SystemDeclRef `json:"declaration" cborgen:"declaration"` 32 - Handle string `json:"handle" cborgen:"handle"` 33 - DisplayName *string `json:"displayName" cborgen:"displayName"` 34 34 } 35 35 36 36 func GraphGetFollowers(ctx context.Context, c *xrpc.Client, before string, limit int64, user string) (*GraphGetFollowers_Output, error) {
+3 -3
api/bsky/graphgetFollows.go
··· 12 12 } 13 13 14 14 type GraphGetFollows_Output struct { 15 + Subject *ActorRef_WithInfo `json:"subject" cborgen:"subject"` 15 16 Cursor *string `json:"cursor" cborgen:"cursor"` 16 17 Follows []*GraphGetFollows_Follow `json:"follows" cborgen:"follows"` 17 - Subject *ActorRef_WithInfo `json:"subject" cborgen:"subject"` 18 18 } 19 19 20 20 type GraphGetFollows_Follow struct { 21 + CreatedAt *string `json:"createdAt" cborgen:"createdAt"` 22 + IndexedAt string `json:"indexedAt" cborgen:"indexedAt"` 21 23 Did string `json:"did" cborgen:"did"` 22 24 Declaration *SystemDeclRef `json:"declaration" cborgen:"declaration"` 23 25 Handle string `json:"handle" cborgen:"handle"` 24 26 DisplayName *string `json:"displayName" cborgen:"displayName"` 25 - CreatedAt *string `json:"createdAt" cborgen:"createdAt"` 26 - IndexedAt string `json:"indexedAt" cborgen:"indexedAt"` 27 27 } 28 28 29 29 func GraphGetFollows(ctx context.Context, c *xrpc.Client, before string, limit int64, user string) (*GraphGetFollows_Output, error) {
+3 -3
api/bsky/graphgetMembers.go
··· 12 12 } 13 13 14 14 type GraphGetMembers_Output struct { 15 - Subject *ActorRef_WithInfo `json:"subject" cborgen:"subject"` 16 15 Cursor *string `json:"cursor" cborgen:"cursor"` 17 16 Members []*GraphGetMembers_Member `json:"members" cborgen:"members"` 17 + Subject *ActorRef_WithInfo `json:"subject" cborgen:"subject"` 18 18 } 19 19 20 20 type GraphGetMembers_Member struct { 21 - Declaration *SystemDeclRef `json:"declaration" cborgen:"declaration"` 22 - Handle string `json:"handle" cborgen:"handle"` 23 21 DisplayName *string `json:"displayName" cborgen:"displayName"` 24 22 CreatedAt *string `json:"createdAt" cborgen:"createdAt"` 25 23 IndexedAt string `json:"indexedAt" cborgen:"indexedAt"` 26 24 Did string `json:"did" cborgen:"did"` 25 + Declaration *SystemDeclRef `json:"declaration" cborgen:"declaration"` 26 + Handle string `json:"handle" cborgen:"handle"` 27 27 } 28 28 29 29 func GraphGetMembers(ctx context.Context, c *xrpc.Client, actor string, before string, limit int64) (*GraphGetMembers_Output, error) {
+2 -2
api/bsky/graphgetMemberships.go
··· 18 18 } 19 19 20 20 type GraphGetMemberships_Membership struct { 21 - IndexedAt string `json:"indexedAt" cborgen:"indexedAt"` 22 - Did string `json:"did" cborgen:"did"` 23 21 Declaration *SystemDeclRef `json:"declaration" cborgen:"declaration"` 24 22 Handle string `json:"handle" cborgen:"handle"` 25 23 DisplayName *string `json:"displayName" cborgen:"displayName"` 26 24 CreatedAt *string `json:"createdAt" cborgen:"createdAt"` 25 + IndexedAt string `json:"indexedAt" cborgen:"indexedAt"` 26 + Did string `json:"did" cborgen:"did"` 27 27 } 28 28 29 29 func GraphGetMemberships(ctx context.Context, c *xrpc.Client, actor string, before string, limit int64) (*GraphGetMemberships_Output, error) {
+1 -1
api/bsky/systemdeclRef.go
··· 6 6 } 7 7 8 8 type SystemDeclRef struct { 9 - ActorType string `json:"actorType" cborgen:"actorType"` 10 9 Cid string `json:"cid" cborgen:"cid"` 10 + ActorType string `json:"actorType" cborgen:"actorType"` 11 11 }
+6
api/server/auth.go
··· 2 2 3 3 import ( 4 4 "context" 5 + "crypto/rand" 6 + "encoding/base64" 5 7 "time" 6 8 7 9 "github.com/lestrrat-go/jwx/jwa" ··· 25 27 func (s *Server) createAuthTokenForUser(ctx context.Context, handle, did string) (*xrpc.AuthInfo, error) { 26 28 accessTok := makeToken(did, "com.atproto.access", time.Now().Add(24*time.Hour)) 27 29 refreshTok := makeToken(did, "com.atproto.refresh", time.Now().Add(7*24*time.Hour)) 30 + 31 + rval := make([]byte, 10) 32 + rand.Read(rval) 33 + refreshTok.Set("jti", base64.StdEncoding.EncodeToString(rval)) 28 34 29 35 accSig, err := jwt.Sign(accessTok, jwa.HS256, s.signingKey) 30 36 if err != nil {
+184 -33
api/server/feedgen.go
··· 24 24 25 25 type FeedPost struct { 26 26 gorm.Model 27 - Author uint 28 - RepostedBy uint 29 - TrendedBy uint 30 - Tid string 27 + Author uint 28 + RepostedBy uint 29 + TrendedBy uint 30 + // TODO: only keeping rkey here, assuming collection is app.bsky.feed.post 31 + Rkey string 31 32 Cid string 32 33 UpCount int64 33 34 ReplyCount int64 ··· 36 37 37 38 type ActorInfo struct { 38 39 gorm.Model 39 - User uint `gorm:"index"` 40 - Handle string 41 - Did string 42 - Name string 43 - Following int 44 - Followers int 45 - Posts int 46 - DeclRefCid string 47 - Type string 40 + User uint `gorm:"index"` 41 + Handle string 42 + DisplayName string 43 + Did string 44 + Name string 45 + Following int64 46 + Followers int64 47 + Posts int64 48 + DeclRefCid string 49 + Type string 50 + } 51 + 52 + type VoteDir int 53 + 54 + func (vd VoteDir) String() string { 55 + switch vd { 56 + case VoteDirUp: 57 + return "up" 58 + case VoteDirDown: 59 + return "down" 60 + default: 61 + return "<unknown>" 62 + } 48 63 } 49 64 50 - type UpVoteRecord struct { 65 + const ( 66 + VoteDirUp = VoteDir(1) 67 + VoteDirDown = VoteDir(2) 68 + ) 69 + 70 + type VoteRecord struct { 51 71 gorm.Model 52 - User uint 53 - Likes uint 72 + Dir VoteDir 73 + User uint 74 + Post uint 75 + Created string 54 76 } 55 77 56 78 type FollowRecord struct { ··· 63 85 db.AutoMigrate(&FeedPost{}) 64 86 db.AutoMigrate(&ActorInfo{}) 65 87 db.AutoMigrate(&FollowRecord{}) 66 - db.AutoMigrate(&UpVoteRecord{}) 88 + db.AutoMigrate(&VoteRecord{}) 67 89 68 90 return &FeedGenerator{ 69 91 db: db, ··· 113 135 return "", err 114 136 } 115 137 116 - return ai.Handle, nil 138 + return ai.Did, nil 117 139 } 118 140 119 141 func (fg *FeedGenerator) getActorRefInfo(ctx context.Context, user uint) (*bsky.ActorRef_WithInfo, error) { ··· 143 165 } 144 166 145 167 out := HydratedFeedItem{ 146 - Uri: "at://" + authorDid + "/" + item.Tid, 168 + Uri: "at://" + authorDid + "/app.bsky.feed.post/" + item.Rkey, 147 169 ReplyCount: item.ReplyCount, 148 170 RepostCount: item.RepostCount, 149 171 UpvoteCount: item.UpCount, ··· 272 294 } 273 295 274 296 type parsedUri struct { 275 - Did string 276 - Rkey string 297 + Did string 298 + Collection string 299 + Rkey string 277 300 } 278 301 279 302 func parseAtUri(uri string) (*parsedUri, error) { ··· 287 310 return nil, fmt.Errorf("AT uris must have three parts: did, collection, tid") 288 311 } 289 312 290 - did := parts[0] 291 - rkey := parts[1] + "/" + parts[2] 292 - 293 313 return &parsedUri{ 294 - Did: did, 295 - Rkey: rkey, 314 + Did: parts[0], 315 + Collection: parts[1], 316 + Rkey: parts[2], 296 317 }, nil 297 318 } 298 319 ··· 300 321 switch rec := evt.Record.(type) { 301 322 case *bsky.FeedPost: 302 323 fp := FeedPost{ 303 - Tid: evt.Rkey, 324 + Rkey: evt.Rkey, 304 325 Cid: evt.RecCid.String(), 305 326 Author: evt.User, 306 327 } ··· 314 335 return nil 315 336 case *bsky.FeedVote: 316 337 var val int 338 + var dbdir VoteDir 317 339 switch rec.Direction { 318 340 case "up": 319 341 val = 1 342 + dbdir = VoteDirUp 320 343 case "down": 321 344 val = -1 345 + dbdir = VoteDirDown 322 346 default: 323 347 return fmt.Errorf("invalid vote direction: %q", rec.Direction) 324 348 } ··· 334 358 } 335 359 336 360 var post FeedPost 337 - if err := fg.db.First(&post, "tid = ? AND author = ?", puri.Rkey, act.User).Error; err != nil { 361 + if err := fg.db.First(&post, "rkey = ? AND author = ?", puri.Rkey, act.User).Error; err != nil { 338 362 return err 339 363 } 340 364 341 - if err := fg.db.Create(&UpVoteRecord{ 342 - User: evt.User, 343 - Likes: post.ID, 365 + if err := fg.db.Create(&VoteRecord{ 366 + Dir: dbdir, 367 + User: evt.User, 368 + Post: post.ID, 369 + Created: rec.CreatedAt, 344 370 }).Error; err != nil { 345 371 return err 346 372 } ··· 371 397 372 398 func (fg *FeedGenerator) GetActorProfile(ctx context.Context, actor string) (*ActorInfo, error) { 373 399 var ai ActorInfo 374 - if err := fg.db.First(&ai, "handle = ?", actor).Error; err != nil { 400 + if strings.HasPrefix(actor, "did:") { 401 + if err := fg.db.First(&ai, "did = ?", actor).Error; err != nil { 402 + return nil, err 403 + } 404 + } else { 405 + if err := fg.db.First(&ai, "handle = ?", actor).Error; err != nil { 406 + return nil, err 407 + } 408 + } 409 + 410 + return &ai, nil 411 + } 412 + 413 + func (fg *FeedGenerator) GetPost(ctx context.Context, uri string) (*FeedPost, error) { 414 + puri, err := parseAtUri(uri) 415 + if err != nil { 416 + return nil, err 417 + } 418 + 419 + var post FeedPost 420 + if err := fg.db.First(&post, "rkey = ? AND author = (?)", puri.Rkey, fg.db.Model(ActorInfo{}).Where("did = ?", puri.Did).Select("id")).Error; err != nil { 421 + return nil, err 422 + } 423 + 424 + return &post, nil 425 + } 426 + 427 + type ThreadPost struct { 428 + Post *HydratedFeedItem 429 + 430 + ParentUri string 431 + Parent *ThreadPost 432 + } 433 + 434 + func (fg *FeedGenerator) GetPostThread(ctx context.Context, uri string, depth int) (*ThreadPost, error) { 435 + post, err := fg.GetPost(ctx, uri) 436 + if err != nil { 437 + return nil, fmt.Errorf("getting post for thread: %w", err) 438 + } 439 + 440 + hi, err := fg.hydrateItem(ctx, post) 441 + if err != nil { 375 442 return nil, err 376 443 } 377 444 378 - return nil, nil 445 + p, ok := hi.Record.(*bsky.FeedPost) 446 + if !ok { 447 + return nil, fmt.Errorf("getPostThread can only operate on app.bsky.feed.post records") 448 + } 449 + 450 + out := &ThreadPost{ 451 + Post: hi, 452 + } 453 + 454 + if p.Reply != nil { 455 + out.ParentUri = p.Reply.Parent.Uri 456 + if depth > 0 { 457 + 458 + parent, err := fg.GetPostThread(ctx, p.Reply.Parent.Uri, depth-1) 459 + if err != nil { 460 + // TODO: check for and handle 'not found' 461 + return nil, err 462 + } 463 + out.Parent = parent 464 + } 465 + } 466 + 467 + return out, nil 468 + } 469 + 470 + type HydratedVote struct { 471 + Actor *bsky.ActorRef_WithInfo 472 + Direction string 473 + IndexedAt time.Time 474 + CreatedAt string 475 + } 476 + 477 + func (fg *FeedGenerator) hydrateVote(ctx context.Context, v *VoteRecord) (*HydratedVote, error) { 478 + aref, err := fg.getActorRefInfo(ctx, v.User) 479 + if err != nil { 480 + return nil, err 481 + } 482 + 483 + return &HydratedVote{ 484 + Actor: aref, 485 + Direction: v.Dir.String(), 486 + IndexedAt: v.UpdatedAt, 487 + CreatedAt: v.Created, 488 + }, nil 489 + } 490 + 491 + func (fg *FeedGenerator) GetVotes(ctx context.Context, uri string, pcid cid.Cid, dir string, limit int, before string) ([]*HydratedVote, error) { 492 + if before != "" { 493 + log.Println("not respecting 'before' yet") 494 + } 495 + 496 + p, err := fg.GetPost(ctx, uri) 497 + if err != nil { 498 + return nil, err 499 + } 500 + 501 + if p.Cid != pcid.String() { 502 + return nil, fmt.Errorf("listing likes of old post versions not supported") 503 + } 504 + 505 + var dbdir VoteDir 506 + switch dir { 507 + case "up": 508 + dbdir = VoteDirUp 509 + case "down": 510 + dbdir = VoteDirDown 511 + default: 512 + return nil, fmt.Errorf("there are only two directions, up or down") 513 + } 514 + 515 + var voterecs []VoteRecord 516 + if err := fg.db.Limit(limit).Find(&voterecs, "dir = ? AND post = ?", dbdir, p.ID).Error; err != nil { 517 + return nil, err 518 + } 519 + 520 + var out []*HydratedVote 521 + for _, vr := range voterecs { 522 + hv, err := fg.hydrateVote(ctx, &vr) 523 + if err != nil { 524 + return nil, err 525 + } 526 + out = append(out, hv) 527 + } 528 + 529 + return out, nil 379 530 }
+122 -31
api/server/handlers.go
··· 18 18 } 19 19 20 20 func (s *Server) handleAppBskyActorGetProfile(ctx context.Context, actor string) (*appbskytypes.ActorGetProfile_Output, error) { 21 - fmt.Println("Get profile:", actor) 22 - 23 - return nil, nil 24 - 25 - /* 26 - profile, err := s.feedgen.GetActorProfile(ctx, actor) 27 - if err != nil { 28 - return nil, err 29 - } 21 + profile, err := s.feedgen.GetActorProfile(ctx, actor) 22 + if err != nil { 23 + return nil, err 24 + } 30 25 31 - var out appbskytypes.ActorGetProfile_Output 32 - out := ActorGetProfile_Output { 33 - MyState : nil, //*ActorGetProfile_MyState `json:"myState" cborgen:"myState"` 34 - Did string `json:"did" cborgen:"did"` 35 - Declaration *SystemDeclRef `json:"declaration" cborgen:"declaration"` 36 - Description string `json:"description" cborgen:"description"` 37 - PostsCount int64 `json:"postsCount" cborgen:"postsCount"` 38 - FollowsCount int64 `json:"followsCount" cborgen:"followsCount"` 39 - MembersCount int64 `json:"membersCount" cborgen:"membersCount"` 40 - Handle string `json:"handle" cborgen:"handle"` 41 - Creator string `json:"creator" cborgen:"creator"` 42 - DisplayName string `json:"displayName" cborgen:"displayName"` 43 - FollowersCount int64 `json:"followersCount" cborgen:"followersCount"` 44 - } 45 - */ 26 + return &appbskytypes.ActorGetProfile_Output{ 27 + MyState: nil, //*ActorGetProfile_MyState `json:"myState" cborgen:"myState"` 28 + Did: profile.Did, 29 + Declaration: &appbskytypes.SystemDeclRef{ 30 + Cid: profile.DeclRefCid, 31 + ActorType: profile.Type, 32 + }, 33 + Description: nil, 34 + PostsCount: profile.Posts, 35 + FollowsCount: profile.Following, 36 + MembersCount: 0, // TODO: 37 + Handle: profile.Handle, 38 + Creator: "", //TODO: 39 + DisplayName: &profile.DisplayName, 40 + FollowersCount: profile.Followers, 41 + }, nil 46 42 } 47 43 48 44 func (s *Server) handleAppBskyActorGetSuggestions(ctx context.Context, cursor string, limit int) (*appbskytypes.ActorGetSuggestions_Output, error) { ··· 103 99 return &out, nil 104 100 } 105 101 106 - func (s *Server) handleAppBskyFeedGetPostThread(ctx context.Context, depth int, uri string) (*appbskytypes.FeedGetPostThread_Output, error) { 107 - panic("not yet implemented") 102 + func (s *Server) handleAppBskyFeedGetPostThread(ctx context.Context, depth *int, uri string) (*appbskytypes.FeedGetPostThread_Output, error) { 103 + 104 + d := 6 105 + if depth != nil { 106 + d = *depth 107 + } 108 + 109 + pthread, err := s.feedgen.GetPostThread(ctx, uri, d) 110 + if err != nil { 111 + return nil, err 112 + } 113 + 114 + var convertToOutputType func(thr *ThreadPost) *appbskytypes.FeedGetPostThread_Post 115 + convertToOutputType = func(thr *ThreadPost) *appbskytypes.FeedGetPostThread_Post { 116 + p := thr.Post 117 + out := &appbskytypes.FeedGetPostThread_Post{ 118 + MyState: nil, // TODO: 119 + Uri: p.Uri, 120 + Parent: nil, 121 + ReplyCount: p.ReplyCount, 122 + Replies: []*appbskytypes.FeedGetPostThread_Post_Replies_Elem{}, 123 + UpvoteCount: p.UpvoteCount, 124 + DownvoteCount: 0, // TODO: 125 + IndexedAt: p.IndexedAt, 126 + Cid: p.Cid, 127 + Author: p.Author, 128 + Record: p.Record, 129 + Embed: nil, // TODO: embeds 130 + RepostCount: p.RepostCount, 131 + } 132 + 133 + if thr.ParentUri != "" { 134 + if thr.Parent == nil { 135 + out.Parent = &appbskytypes.FeedGetPostThread_Post_Parent{ 136 + FeedGetPostThread_NotFoundPost: &appbskytypes.FeedGetPostThread_NotFoundPost{ 137 + Uri: thr.ParentUri, 138 + NotFound: true, 139 + }, 140 + } 141 + } else { 142 + out.Parent = &appbskytypes.FeedGetPostThread_Post_Parent{ 143 + FeedGetPostThread_Post: convertToOutputType(thr.Parent), 144 + } 145 + } 146 + } 147 + 148 + return out 149 + } 150 + 151 + out := appbskytypes.FeedGetPostThread_Output{ 152 + Thread: &appbskytypes.FeedGetPostThread_Output_Thread{ 153 + FeedGetPostThread_Post: convertToOutputType(pthread), 154 + //FeedGetPostThread_NotFoundPost: &appbskytypes.FeedGetPostThread_NotFoundPost{}, 155 + }, 156 + } 157 + 158 + return &out, nil 108 159 } 109 160 110 161 func (s *Server) handleAppBskyFeedGetRepostedBy(ctx context.Context, before string, cid string, limit int, uri string) (*appbskytypes.FeedGetRepostedBy_Output, error) { ··· 146 197 return &out, nil 147 198 } 148 199 149 - func (s *Server) handleAppBskyFeedGetVotes(ctx context.Context, before string, cid string, direction string, limit int, uri string) (*appbskytypes.FeedGetVotes_Output, error) { 150 - panic("not yet implemented") 200 + func (s *Server) handleAppBskyFeedGetVotes(ctx context.Context, before string, cc string, direction string, limit int, uri string) (*appbskytypes.FeedGetVotes_Output, error) { 201 + pcid, err := cid.Decode(cc) 202 + if err != nil { 203 + return nil, err 204 + } 205 + 206 + votes, err := s.feedgen.GetVotes(ctx, uri, pcid, direction, limit, before) 207 + if err != nil { 208 + return nil, err 209 + } 210 + 211 + var out appbskytypes.FeedGetVotes_Output 212 + out.Uri = uri 213 + out.Votes = []*appbskytypes.FeedGetVotes_Vote{} 214 + 215 + for _, v := range votes { 216 + out.Votes = append(out.Votes, &appbskytypes.FeedGetVotes_Vote{ 217 + Actor: v.Actor, 218 + Direction: v.Direction, 219 + IndexedAt: v.IndexedAt.Format(time.RFC3339), 220 + CreatedAt: v.CreatedAt, 221 + }) 222 + } 223 + 224 + return &out, nil 151 225 } 152 226 153 227 func (s *Server) handleAppBskyFeedSetVote(ctx context.Context, input *appbskytypes.FeedSetVote_Input) (*appbskytypes.FeedSetVote_Output, error) { ··· 193 267 } 194 268 195 269 func (s *Server) handleAppBskyGraphGetMemberships(ctx context.Context, actor string, before string, limit int) (*appbskytypes.GraphGetMemberships_Output, error) { 196 - panic("not yet implemented") 270 + ai, err := s.feedgen.GetActorProfile(ctx, actor) 271 + if err != nil { 272 + return nil, err 273 + } 274 + 275 + return &appbskytypes.GraphGetMemberships_Output{ 276 + Subject: infoToActorRef(ai), 277 + Memberships: []*appbskytypes.GraphGetMemberships_Membership{}, 278 + }, nil 197 279 } 198 280 199 281 func (s *Server) handleAppBskyNotificationGetCount(ctx context.Context) (*appbskytypes.NotificationGetCount_Output, error) { ··· 226 308 227 309 if err := s.validateHandle(input.Handle); err != nil { 228 310 return nil, err 311 + } 229 312 313 + _, err := s.lookupUserByHandle(ctx, input.Handle) 314 + switch err { 315 + default: 316 + return nil, err 317 + case nil: 318 + return nil, fmt.Errorf("handle already registered") 319 + case ErrNoSuchUser: 320 + // handle is available, lets go 230 321 } 231 322 232 323 var recoveryKey string ··· 326 417 return nil, err 327 418 } 328 419 329 - rkey, recid, err := s.repoman.CreateRecord(ctx, u.ID, input.Collection, rec) 420 + rpath, recid, err := s.repoman.CreateRecord(ctx, u.ID, input.Collection, rec) 330 421 if err != nil { 331 422 return nil, err 332 423 } 333 424 334 425 return &comatprototypes.RepoCreateRecord_Output{ 335 - Uri: "at://" + u.DID + "/" + rkey, 426 + Uri: "at://" + u.DID + "/" + rpath, 336 427 Cid: recid.String(), 337 428 }, nil 338 429 }
+24 -1
api/server/server.go
··· 16 16 "github.com/labstack/echo/v4" 17 17 "github.com/labstack/echo/v4/middleware" 18 18 jwk "github.com/lestrrat-go/jwx/jwk" 19 + appbskytypes "github.com/whyrusleeping/gosky/api/bsky" 19 20 "github.com/whyrusleeping/gosky/carstore" 20 21 "github.com/whyrusleeping/gosky/lex/util" 21 22 "github.com/whyrusleeping/gosky/repomgr" ··· 137 138 DID string `gorm:"uniqueIndex"` 138 139 } 139 140 141 + type RefreshToken struct { 142 + gorm.Model 143 + Token string 144 + } 145 + 140 146 func toTime(i interface{}) (time.Time, error) { 141 147 ival, ok := i.(float64) 142 148 if !ok { ··· 225 231 return &u, nil 226 232 } 227 233 234 + var ErrNoSuchUser = fmt.Errorf("no such user") 235 + 228 236 func (s *Server) lookupUserByHandle(ctx context.Context, handle string) (*User, error) { 229 237 var didEntry FakeDidMapping 230 238 if err := s.db.First(&didEntry, "handle = ?", handle).Error; err != nil { 239 + if err == gorm.ErrRecordNotFound { 240 + return nil, ErrNoSuchUser 241 + } 231 242 return nil, err 232 243 } 233 244 234 245 var u User 235 246 if err := s.db.First(&u, "handle = ?", didEntry.Handle).Error; err != nil { 236 247 if err == gorm.ErrRecordNotFound { 237 - return nil, fmt.Errorf("no such user with handle: %s", handle) 248 + return nil, ErrNoSuchUser 238 249 } 239 250 return nil, err 240 251 } ··· 328 339 329 340 return nil 330 341 } 342 + 343 + func infoToActorRef(ai *ActorInfo) *appbskytypes.ActorRef_WithInfo { 344 + return &appbskytypes.ActorRef_WithInfo{ 345 + Declaration: &appbskytypes.SystemDeclRef{ 346 + Cid: ai.DeclRefCid, 347 + ActorType: ai.Type, 348 + }, 349 + Handle: ai.Handle, 350 + DisplayName: &ai.DisplayName, 351 + Did: ai.Did, 352 + } 353 + }
+473 -391
api/server/stubs.go
··· 10 10 "go.opentelemetry.io/otel" 11 11 ) 12 12 13 - func (s *Server) RegisterHandlersComAtproto(e *echo.Echo) error { 14 - e.POST("/xrpc/com.atproto.account.create", s.HandleComAtprotoAccountCreate) 15 - e.POST("/xrpc/com.atproto.account.createInviteCode", s.HandleComAtprotoAccountCreateInviteCode) 16 - e.POST("/xrpc/com.atproto.account.delete", s.HandleComAtprotoAccountDelete) 17 - e.GET("/xrpc/com.atproto.account.get", s.HandleComAtprotoAccountGet) 18 - e.POST("/xrpc/com.atproto.account.requestPasswordReset", s.HandleComAtprotoAccountRequestPasswordReset) 19 - e.POST("/xrpc/com.atproto.account.resetPassword", s.HandleComAtprotoAccountResetPassword) 20 - e.GET("/xrpc/com.atproto.handle.resolve", s.HandleComAtprotoHandleResolve) 21 - e.POST("/xrpc/com.atproto.repo.batchWrite", s.HandleComAtprotoRepoBatchWrite) 22 - e.POST("/xrpc/com.atproto.repo.createRecord", s.HandleComAtprotoRepoCreateRecord) 23 - e.POST("/xrpc/com.atproto.repo.deleteRecord", s.HandleComAtprotoRepoDeleteRecord) 24 - e.GET("/xrpc/com.atproto.repo.describe", s.HandleComAtprotoRepoDescribe) 25 - e.GET("/xrpc/com.atproto.repo.getRecord", s.HandleComAtprotoRepoGetRecord) 26 - e.GET("/xrpc/com.atproto.repo.listRecords", s.HandleComAtprotoRepoListRecords) 27 - e.POST("/xrpc/com.atproto.repo.putRecord", s.HandleComAtprotoRepoPutRecord) 28 - e.GET("/xrpc/com.atproto.server.getAccountsConfig", s.HandleComAtprotoServerGetAccountsConfig) 29 - e.POST("/xrpc/com.atproto.session.create", s.HandleComAtprotoSessionCreate) 30 - e.POST("/xrpc/com.atproto.session.delete", s.HandleComAtprotoSessionDelete) 31 - e.GET("/xrpc/com.atproto.session.get", s.HandleComAtprotoSessionGet) 32 - e.POST("/xrpc/com.atproto.session.refresh", s.HandleComAtprotoSessionRefresh) 33 - e.GET("/xrpc/com.atproto.sync.getRepo", s.HandleComAtprotoSyncGetRepo) 34 - e.GET("/xrpc/com.atproto.sync.getRoot", s.HandleComAtprotoSyncGetRoot) 35 - e.POST("/xrpc/com.atproto.sync.updateRepo", s.HandleComAtprotoSyncUpdateRepo) 13 + func (s *Server) RegisterHandlersAppBsky(e *echo.Echo) error { 14 + e.POST("/xrpc/app.bsky.actor.createScene", s.HandleAppBskyActorCreateScene) 15 + e.GET("/xrpc/app.bsky.actor.getProfile", s.HandleAppBskyActorGetProfile) 16 + e.GET("/xrpc/app.bsky.actor.getSuggestions", s.HandleAppBskyActorGetSuggestions) 17 + e.GET("/xrpc/app.bsky.actor.search", s.HandleAppBskyActorSearch) 18 + e.GET("/xrpc/app.bsky.actor.searchTypeahead", s.HandleAppBskyActorSearchTypeahead) 19 + e.POST("/xrpc/app.bsky.actor.updateProfile", s.HandleAppBskyActorUpdateProfile) 20 + e.GET("/xrpc/app.bsky.feed.getAuthorFeed", s.HandleAppBskyFeedGetAuthorFeed) 21 + e.GET("/xrpc/app.bsky.feed.getPostThread", s.HandleAppBskyFeedGetPostThread) 22 + e.GET("/xrpc/app.bsky.feed.getRepostedBy", s.HandleAppBskyFeedGetRepostedBy) 23 + e.GET("/xrpc/app.bsky.feed.getTimeline", s.HandleAppBskyFeedGetTimeline) 24 + e.GET("/xrpc/app.bsky.feed.getVotes", s.HandleAppBskyFeedGetVotes) 25 + e.POST("/xrpc/app.bsky.feed.setVote", s.HandleAppBskyFeedSetVote) 26 + e.GET("/xrpc/app.bsky.graph.getAssertions", s.HandleAppBskyGraphGetAssertions) 27 + e.GET("/xrpc/app.bsky.graph.getFollowers", s.HandleAppBskyGraphGetFollowers) 28 + e.GET("/xrpc/app.bsky.graph.getFollows", s.HandleAppBskyGraphGetFollows) 29 + e.GET("/xrpc/app.bsky.graph.getMembers", s.HandleAppBskyGraphGetMembers) 30 + e.GET("/xrpc/app.bsky.graph.getMemberships", s.HandleAppBskyGraphGetMemberships) 31 + e.GET("/xrpc/app.bsky.notification.getCount", s.HandleAppBskyNotificationGetCount) 32 + e.GET("/xrpc/app.bsky.notification.list", s.HandleAppBskyNotificationList) 33 + e.POST("/xrpc/app.bsky.notification.updateSeen", s.HandleAppBskyNotificationUpdateSeen) 36 34 return nil 37 35 } 38 36 39 - func (s *Server) HandleComAtprotoAccountCreate(c echo.Context) error { 40 - ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleComAtprotoAccountCreate") 37 + func (s *Server) HandleAppBskyActorCreateScene(c echo.Context) error { 38 + ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleAppBskyActorCreateScene") 41 39 defer span.End() 42 40 43 - var body comatprototypes.AccountCreate_Input 41 + var body appbskytypes.ActorCreateScene_Input 44 42 if err := c.Bind(&body); err != nil { 45 43 return err 46 44 } 47 - var out *comatprototypes.AccountCreate_Output 45 + var out *appbskytypes.ActorCreateScene_Output 48 46 var handleErr error 49 - // func (s *Server) handleComAtprotoAccountCreate(ctx context.Context,body comatprototypes.AccountCreate_Input) (*comatprototypes.AccountCreate_Output, error) 50 - out, handleErr = s.handleComAtprotoAccountCreate(ctx, &body) 47 + // func (s *Server) handleAppBskyActorCreateScene(ctx context.Context,body appbskytypes.ActorCreateScene_Input) (*appbskytypes.ActorCreateScene_Output, error) 48 + out, handleErr = s.handleAppBskyActorCreateScene(ctx, &body) 51 49 if handleErr != nil { 52 50 return handleErr 53 51 } 54 52 return c.JSON(200, out) 55 53 } 56 54 57 - func (s *Server) HandleComAtprotoAccountCreateInviteCode(c echo.Context) error { 58 - ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleComAtprotoAccountCreateInviteCode") 55 + func (s *Server) HandleAppBskyActorGetProfile(c echo.Context) error { 56 + ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleAppBskyActorGetProfile") 59 57 defer span.End() 60 - 61 - var body comatprototypes.AccountCreateInviteCode_Input 62 - if err := c.Bind(&body); err != nil { 63 - return err 64 - } 65 - var out *comatprototypes.AccountCreateInviteCode_Output 58 + actor := c.QueryParam("actor") 59 + var out *appbskytypes.ActorGetProfile_Output 66 60 var handleErr error 67 - // func (s *Server) handleComAtprotoAccountCreateInviteCode(ctx context.Context,body comatprototypes.AccountCreateInviteCode_Input) (*comatprototypes.AccountCreateInviteCode_Output, error) 68 - out, handleErr = s.handleComAtprotoAccountCreateInviteCode(ctx, &body) 61 + // func (s *Server) handleAppBskyActorGetProfile(ctx context.Context,actor string) (*appbskytypes.ActorGetProfile_Output, error) 62 + out, handleErr = s.handleAppBskyActorGetProfile(ctx, actor) 69 63 if handleErr != nil { 70 64 return handleErr 71 65 } 72 66 return c.JSON(200, out) 73 67 } 74 68 75 - func (s *Server) HandleComAtprotoAccountDelete(c echo.Context) error { 76 - ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleComAtprotoAccountDelete") 69 + func (s *Server) HandleAppBskyActorGetSuggestions(c echo.Context) error { 70 + ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleAppBskyActorGetSuggestions") 77 71 defer span.End() 78 - var handleErr error 79 - // func (s *Server) handleComAtprotoAccountDelete(ctx context.Context) error 80 - handleErr = s.handleComAtprotoAccountDelete(ctx) 81 - if handleErr != nil { 82 - return handleErr 72 + cursor := c.QueryParam("cursor") 73 + 74 + var limit int 75 + if p := c.QueryParam("limit"); p != "" { 76 + var err error 77 + limit, err = strconv.Atoi(p) 78 + if err != nil { 79 + return err 80 + } 81 + } else { 82 + limit = 50 83 83 } 84 - return nil 85 - } 86 - 87 - func (s *Server) HandleComAtprotoAccountGet(c echo.Context) error { 88 - ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleComAtprotoAccountGet") 89 - defer span.End() 84 + var out *appbskytypes.ActorGetSuggestions_Output 90 85 var handleErr error 91 - // func (s *Server) handleComAtprotoAccountGet(ctx context.Context) error 92 - handleErr = s.handleComAtprotoAccountGet(ctx) 86 + // func (s *Server) handleAppBskyActorGetSuggestions(ctx context.Context,cursor string,limit int) (*appbskytypes.ActorGetSuggestions_Output, error) 87 + out, handleErr = s.handleAppBskyActorGetSuggestions(ctx, cursor, limit) 93 88 if handleErr != nil { 94 89 return handleErr 95 90 } 96 - return nil 91 + return c.JSON(200, out) 97 92 } 98 93 99 - func (s *Server) HandleComAtprotoAccountRequestPasswordReset(c echo.Context) error { 100 - ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleComAtprotoAccountRequestPasswordReset") 94 + func (s *Server) HandleAppBskyActorSearch(c echo.Context) error { 95 + ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleAppBskyActorSearch") 101 96 defer span.End() 97 + before := c.QueryParam("before") 102 98 103 - var body comatprototypes.AccountRequestPasswordReset_Input 104 - if err := c.Bind(&body); err != nil { 105 - return err 99 + var limit int 100 + if p := c.QueryParam("limit"); p != "" { 101 + var err error 102 + limit, err = strconv.Atoi(p) 103 + if err != nil { 104 + return err 105 + } 106 + } else { 107 + limit = 50 106 108 } 109 + term := c.QueryParam("term") 110 + var out *appbskytypes.ActorSearch_Output 107 111 var handleErr error 108 - // func (s *Server) handleComAtprotoAccountRequestPasswordReset(ctx context.Context,body comatprototypes.AccountRequestPasswordReset_Input) error 109 - handleErr = s.handleComAtprotoAccountRequestPasswordReset(ctx, &body) 112 + // func (s *Server) handleAppBskyActorSearch(ctx context.Context,before string,limit int,term string) (*appbskytypes.ActorSearch_Output, error) 113 + out, handleErr = s.handleAppBskyActorSearch(ctx, before, limit, term) 110 114 if handleErr != nil { 111 115 return handleErr 112 116 } 113 - return nil 117 + return c.JSON(200, out) 114 118 } 115 119 116 - func (s *Server) HandleComAtprotoAccountResetPassword(c echo.Context) error { 117 - ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleComAtprotoAccountResetPassword") 120 + func (s *Server) HandleAppBskyActorSearchTypeahead(c echo.Context) error { 121 + ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleAppBskyActorSearchTypeahead") 118 122 defer span.End() 119 123 120 - var body comatprototypes.AccountResetPassword_Input 121 - if err := c.Bind(&body); err != nil { 122 - return err 124 + var limit int 125 + if p := c.QueryParam("limit"); p != "" { 126 + var err error 127 + limit, err = strconv.Atoi(p) 128 + if err != nil { 129 + return err 130 + } 131 + } else { 132 + limit = 50 123 133 } 124 - var handleErr error 125 - // func (s *Server) handleComAtprotoAccountResetPassword(ctx context.Context,body comatprototypes.AccountResetPassword_Input) error 126 - handleErr = s.handleComAtprotoAccountResetPassword(ctx, &body) 127 - if handleErr != nil { 128 - return handleErr 129 - } 130 - return nil 131 - } 132 - 133 - func (s *Server) HandleComAtprotoHandleResolve(c echo.Context) error { 134 - ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleComAtprotoHandleResolve") 135 - defer span.End() 136 - handle := c.QueryParam("handle") 137 - var out *comatprototypes.HandleResolve_Output 134 + term := c.QueryParam("term") 135 + var out *appbskytypes.ActorSearchTypeahead_Output 138 136 var handleErr error 139 - // func (s *Server) handleComAtprotoHandleResolve(ctx context.Context,handle string) (*comatprototypes.HandleResolve_Output, error) 140 - out, handleErr = s.handleComAtprotoHandleResolve(ctx, handle) 137 + // func (s *Server) handleAppBskyActorSearchTypeahead(ctx context.Context,limit int,term string) (*appbskytypes.ActorSearchTypeahead_Output, error) 138 + out, handleErr = s.handleAppBskyActorSearchTypeahead(ctx, limit, term) 141 139 if handleErr != nil { 142 140 return handleErr 143 141 } 144 142 return c.JSON(200, out) 145 143 } 146 144 147 - func (s *Server) HandleComAtprotoRepoBatchWrite(c echo.Context) error { 148 - ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleComAtprotoRepoBatchWrite") 145 + func (s *Server) HandleAppBskyActorUpdateProfile(c echo.Context) error { 146 + ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleAppBskyActorUpdateProfile") 149 147 defer span.End() 150 148 151 - var body comatprototypes.RepoBatchWrite_Input 149 + var body appbskytypes.ActorUpdateProfile_Input 152 150 if err := c.Bind(&body); err != nil { 153 151 return err 154 152 } 153 + var out *appbskytypes.ActorUpdateProfile_Output 155 154 var handleErr error 156 - // func (s *Server) handleComAtprotoRepoBatchWrite(ctx context.Context,body comatprototypes.RepoBatchWrite_Input) error 157 - handleErr = s.handleComAtprotoRepoBatchWrite(ctx, &body) 155 + // func (s *Server) handleAppBskyActorUpdateProfile(ctx context.Context,body appbskytypes.ActorUpdateProfile_Input) (*appbskytypes.ActorUpdateProfile_Output, error) 156 + out, handleErr = s.handleAppBskyActorUpdateProfile(ctx, &body) 158 157 if handleErr != nil { 159 158 return handleErr 160 159 } 161 - return nil 160 + return c.JSON(200, out) 162 161 } 163 162 164 - func (s *Server) HandleComAtprotoRepoCreateRecord(c echo.Context) error { 165 - ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleComAtprotoRepoCreateRecord") 163 + func (s *Server) HandleAppBskyFeedGetAuthorFeed(c echo.Context) error { 164 + ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleAppBskyFeedGetAuthorFeed") 166 165 defer span.End() 166 + author := c.QueryParam("author") 167 + before := c.QueryParam("before") 167 168 168 - var body comatprototypes.RepoCreateRecord_Input 169 - if err := c.Bind(&body); err != nil { 170 - return err 169 + var limit int 170 + if p := c.QueryParam("limit"); p != "" { 171 + var err error 172 + limit, err = strconv.Atoi(p) 173 + if err != nil { 174 + return err 175 + } 176 + } else { 177 + limit = 50 171 178 } 172 - var out *comatprototypes.RepoCreateRecord_Output 179 + var out *appbskytypes.FeedGetAuthorFeed_Output 173 180 var handleErr error 174 - // func (s *Server) handleComAtprotoRepoCreateRecord(ctx context.Context,body comatprototypes.RepoCreateRecord_Input) (*comatprototypes.RepoCreateRecord_Output, error) 175 - out, handleErr = s.handleComAtprotoRepoCreateRecord(ctx, &body) 181 + // func (s *Server) handleAppBskyFeedGetAuthorFeed(ctx context.Context,author string,before string,limit int) (*appbskytypes.FeedGetAuthorFeed_Output, error) 182 + out, handleErr = s.handleAppBskyFeedGetAuthorFeed(ctx, author, before, limit) 176 183 if handleErr != nil { 177 184 return handleErr 178 185 } 179 186 return c.JSON(200, out) 180 187 } 181 188 182 - func (s *Server) HandleComAtprotoRepoDeleteRecord(c echo.Context) error { 183 - ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleComAtprotoRepoDeleteRecord") 189 + func (s *Server) HandleAppBskyFeedGetPostThread(c echo.Context) error { 190 + ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleAppBskyFeedGetPostThread") 184 191 defer span.End() 185 192 186 - var body comatprototypes.RepoDeleteRecord_Input 187 - if err := c.Bind(&body); err != nil { 188 - return err 193 + var depth *int 194 + if p := c.QueryParam("depth"); p != "" { 195 + depth_val, err := strconv.Atoi(p) 196 + if err != nil { 197 + return err 198 + } 199 + depth = &depth_val 189 200 } 201 + uri := c.QueryParam("uri") 202 + var out *appbskytypes.FeedGetPostThread_Output 190 203 var handleErr error 191 - // func (s *Server) handleComAtprotoRepoDeleteRecord(ctx context.Context,body comatprototypes.RepoDeleteRecord_Input) error 192 - handleErr = s.handleComAtprotoRepoDeleteRecord(ctx, &body) 204 + // func (s *Server) handleAppBskyFeedGetPostThread(ctx context.Context,depth *int,uri string) (*appbskytypes.FeedGetPostThread_Output, error) 205 + out, handleErr = s.handleAppBskyFeedGetPostThread(ctx, depth, uri) 193 206 if handleErr != nil { 194 207 return handleErr 195 208 } 196 - return nil 209 + return c.JSON(200, out) 197 210 } 198 211 199 - func (s *Server) HandleComAtprotoRepoDescribe(c echo.Context) error { 200 - ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleComAtprotoRepoDescribe") 212 + func (s *Server) HandleAppBskyFeedGetRepostedBy(c echo.Context) error { 213 + ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleAppBskyFeedGetRepostedBy") 201 214 defer span.End() 202 - user := c.QueryParam("user") 203 - var out *comatprototypes.RepoDescribe_Output 215 + before := c.QueryParam("before") 216 + cid := c.QueryParam("cid") 217 + 218 + var limit int 219 + if p := c.QueryParam("limit"); p != "" { 220 + var err error 221 + limit, err = strconv.Atoi(p) 222 + if err != nil { 223 + return err 224 + } 225 + } else { 226 + limit = 50 227 + } 228 + uri := c.QueryParam("uri") 229 + var out *appbskytypes.FeedGetRepostedBy_Output 204 230 var handleErr error 205 - // func (s *Server) handleComAtprotoRepoDescribe(ctx context.Context,user string) (*comatprototypes.RepoDescribe_Output, error) 206 - out, handleErr = s.handleComAtprotoRepoDescribe(ctx, user) 231 + // func (s *Server) handleAppBskyFeedGetRepostedBy(ctx context.Context,before string,cid string,limit int,uri string) (*appbskytypes.FeedGetRepostedBy_Output, error) 232 + out, handleErr = s.handleAppBskyFeedGetRepostedBy(ctx, before, cid, limit, uri) 207 233 if handleErr != nil { 208 234 return handleErr 209 235 } 210 236 return c.JSON(200, out) 211 237 } 212 238 213 - func (s *Server) HandleComAtprotoRepoGetRecord(c echo.Context) error { 214 - ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleComAtprotoRepoGetRecord") 239 + func (s *Server) HandleAppBskyFeedGetTimeline(c echo.Context) error { 240 + ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleAppBskyFeedGetTimeline") 215 241 defer span.End() 216 - cid := c.QueryParam("cid") 217 - collection := c.QueryParam("collection") 218 - rkey := c.QueryParam("rkey") 219 - user := c.QueryParam("user") 220 - var out *comatprototypes.RepoGetRecord_Output 242 + algorithm := c.QueryParam("algorithm") 243 + before := c.QueryParam("before") 244 + 245 + var limit int 246 + if p := c.QueryParam("limit"); p != "" { 247 + var err error 248 + limit, err = strconv.Atoi(p) 249 + if err != nil { 250 + return err 251 + } 252 + } else { 253 + limit = 50 254 + } 255 + var out *appbskytypes.FeedGetTimeline_Output 221 256 var handleErr error 222 - // func (s *Server) handleComAtprotoRepoGetRecord(ctx context.Context,cid string,collection string,rkey string,user string) (*comatprototypes.RepoGetRecord_Output, error) 223 - out, handleErr = s.handleComAtprotoRepoGetRecord(ctx, cid, collection, rkey, user) 257 + // func (s *Server) handleAppBskyFeedGetTimeline(ctx context.Context,algorithm string,before string,limit int) (*appbskytypes.FeedGetTimeline_Output, error) 258 + out, handleErr = s.handleAppBskyFeedGetTimeline(ctx, algorithm, before, limit) 224 259 if handleErr != nil { 225 260 return handleErr 226 261 } 227 262 return c.JSON(200, out) 228 263 } 229 264 230 - func (s *Server) HandleComAtprotoRepoListRecords(c echo.Context) error { 231 - ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleComAtprotoRepoListRecords") 265 + func (s *Server) HandleAppBskyFeedGetVotes(c echo.Context) error { 266 + ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleAppBskyFeedGetVotes") 232 267 defer span.End() 233 - after := c.QueryParam("after") 234 268 before := c.QueryParam("before") 235 - collection := c.QueryParam("collection") 269 + cid := c.QueryParam("cid") 270 + direction := c.QueryParam("direction") 236 271 237 - limit, err := strconv.Atoi(c.QueryParam("limit")) 238 - if err != nil { 239 - return err 272 + var limit int 273 + if p := c.QueryParam("limit"); p != "" { 274 + var err error 275 + limit, err = strconv.Atoi(p) 276 + if err != nil { 277 + return err 278 + } 279 + } else { 280 + limit = 50 240 281 } 241 - var out *comatprototypes.RepoListRecords_Output 282 + uri := c.QueryParam("uri") 283 + var out *appbskytypes.FeedGetVotes_Output 242 284 var handleErr error 243 - // func (s *Server) handleComAtprotoRepoListRecords(ctx context.Context,after string,before string,collection string,limit int) (*comatprototypes.RepoListRecords_Output, error) 244 - out, handleErr = s.handleComAtprotoRepoListRecords(ctx, after, before, collection, limit) 285 + // func (s *Server) handleAppBskyFeedGetVotes(ctx context.Context,before string,cid string,direction string,limit int,uri string) (*appbskytypes.FeedGetVotes_Output, error) 286 + out, handleErr = s.handleAppBskyFeedGetVotes(ctx, before, cid, direction, limit, uri) 245 287 if handleErr != nil { 246 288 return handleErr 247 289 } 248 290 return c.JSON(200, out) 249 291 } 250 292 251 - func (s *Server) HandleComAtprotoRepoPutRecord(c echo.Context) error { 252 - ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleComAtprotoRepoPutRecord") 293 + func (s *Server) HandleAppBskyFeedSetVote(c echo.Context) error { 294 + ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleAppBskyFeedSetVote") 253 295 defer span.End() 254 296 255 - var body comatprototypes.RepoPutRecord_Input 297 + var body appbskytypes.FeedSetVote_Input 256 298 if err := c.Bind(&body); err != nil { 257 299 return err 258 300 } 259 - var out *comatprototypes.RepoPutRecord_Output 301 + var out *appbskytypes.FeedSetVote_Output 260 302 var handleErr error 261 - // func (s *Server) handleComAtprotoRepoPutRecord(ctx context.Context,body comatprototypes.RepoPutRecord_Input) (*comatprototypes.RepoPutRecord_Output, error) 262 - out, handleErr = s.handleComAtprotoRepoPutRecord(ctx, &body) 303 + // func (s *Server) handleAppBskyFeedSetVote(ctx context.Context,body appbskytypes.FeedSetVote_Input) (*appbskytypes.FeedSetVote_Output, error) 304 + out, handleErr = s.handleAppBskyFeedSetVote(ctx, &body) 263 305 if handleErr != nil { 264 306 return handleErr 265 307 } 266 308 return c.JSON(200, out) 267 309 } 268 310 269 - func (s *Server) HandleComAtprotoServerGetAccountsConfig(c echo.Context) error { 270 - ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleComAtprotoServerGetAccountsConfig") 311 + func (s *Server) HandleAppBskyGraphGetAssertions(c echo.Context) error { 312 + ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleAppBskyGraphGetAssertions") 271 313 defer span.End() 272 - var out *comatprototypes.ServerGetAccountsConfig_Output 314 + assertion := c.QueryParam("assertion") 315 + author := c.QueryParam("author") 316 + before := c.QueryParam("before") 317 + var out *appbskytypes.GraphGetAssertions_Output 273 318 var handleErr error 274 - // func (s *Server) handleComAtprotoServerGetAccountsConfig(ctx context.Context) (*comatprototypes.ServerGetAccountsConfig_Output, error) 275 - out, handleErr = s.handleComAtprotoServerGetAccountsConfig(ctx) 319 + // func (s *Server) handleAppBskyGraphGetAssertions(ctx context.Context,assertion string,author string,before string) (*appbskytypes.GraphGetAssertions_Output, error) 320 + out, handleErr = s.handleAppBskyGraphGetAssertions(ctx, assertion, author, before) 276 321 if handleErr != nil { 277 322 return handleErr 278 323 } 279 324 return c.JSON(200, out) 280 325 } 281 326 282 - func (s *Server) HandleComAtprotoSessionCreate(c echo.Context) error { 283 - ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleComAtprotoSessionCreate") 327 + func (s *Server) HandleAppBskyGraphGetFollowers(c echo.Context) error { 328 + ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleAppBskyGraphGetFollowers") 284 329 defer span.End() 330 + before := c.QueryParam("before") 285 331 286 - var body comatprototypes.SessionCreate_Input 287 - if err := c.Bind(&body); err != nil { 288 - return err 332 + var limit int 333 + if p := c.QueryParam("limit"); p != "" { 334 + var err error 335 + limit, err = strconv.Atoi(p) 336 + if err != nil { 337 + return err 338 + } 339 + } else { 340 + limit = 50 289 341 } 290 - var out *comatprototypes.SessionCreate_Output 342 + user := c.QueryParam("user") 343 + var out *appbskytypes.GraphGetFollowers_Output 291 344 var handleErr error 292 - // func (s *Server) handleComAtprotoSessionCreate(ctx context.Context,body comatprototypes.SessionCreate_Input) (*comatprototypes.SessionCreate_Output, error) 293 - out, handleErr = s.handleComAtprotoSessionCreate(ctx, &body) 345 + // func (s *Server) handleAppBskyGraphGetFollowers(ctx context.Context,before string,limit int,user string) (*appbskytypes.GraphGetFollowers_Output, error) 346 + out, handleErr = s.handleAppBskyGraphGetFollowers(ctx, before, limit, user) 294 347 if handleErr != nil { 295 348 return handleErr 296 349 } 297 350 return c.JSON(200, out) 298 351 } 299 352 300 - func (s *Server) HandleComAtprotoSessionDelete(c echo.Context) error { 301 - ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleComAtprotoSessionDelete") 353 + func (s *Server) HandleAppBskyGraphGetFollows(c echo.Context) error { 354 + ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleAppBskyGraphGetFollows") 302 355 defer span.End() 356 + before := c.QueryParam("before") 357 + 358 + var limit int 359 + if p := c.QueryParam("limit"); p != "" { 360 + var err error 361 + limit, err = strconv.Atoi(p) 362 + if err != nil { 363 + return err 364 + } 365 + } else { 366 + limit = 50 367 + } 368 + user := c.QueryParam("user") 369 + var out *appbskytypes.GraphGetFollows_Output 303 370 var handleErr error 304 - // func (s *Server) handleComAtprotoSessionDelete(ctx context.Context) error 305 - handleErr = s.handleComAtprotoSessionDelete(ctx) 371 + // func (s *Server) handleAppBskyGraphGetFollows(ctx context.Context,before string,limit int,user string) (*appbskytypes.GraphGetFollows_Output, error) 372 + out, handleErr = s.handleAppBskyGraphGetFollows(ctx, before, limit, user) 306 373 if handleErr != nil { 307 374 return handleErr 308 375 } 309 - return nil 376 + return c.JSON(200, out) 310 377 } 311 378 312 - func (s *Server) HandleComAtprotoSessionGet(c echo.Context) error { 313 - ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleComAtprotoSessionGet") 379 + func (s *Server) HandleAppBskyGraphGetMembers(c echo.Context) error { 380 + ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleAppBskyGraphGetMembers") 314 381 defer span.End() 315 - var out *comatprototypes.SessionGet_Output 382 + actor := c.QueryParam("actor") 383 + before := c.QueryParam("before") 384 + 385 + var limit int 386 + if p := c.QueryParam("limit"); p != "" { 387 + var err error 388 + limit, err = strconv.Atoi(p) 389 + if err != nil { 390 + return err 391 + } 392 + } else { 393 + limit = 50 394 + } 395 + var out *appbskytypes.GraphGetMembers_Output 316 396 var handleErr error 317 - // func (s *Server) handleComAtprotoSessionGet(ctx context.Context) (*comatprototypes.SessionGet_Output, error) 318 - out, handleErr = s.handleComAtprotoSessionGet(ctx) 397 + // func (s *Server) handleAppBskyGraphGetMembers(ctx context.Context,actor string,before string,limit int) (*appbskytypes.GraphGetMembers_Output, error) 398 + out, handleErr = s.handleAppBskyGraphGetMembers(ctx, actor, before, limit) 319 399 if handleErr != nil { 320 400 return handleErr 321 401 } 322 402 return c.JSON(200, out) 323 403 } 324 404 325 - func (s *Server) HandleComAtprotoSessionRefresh(c echo.Context) error { 326 - ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleComAtprotoSessionRefresh") 405 + func (s *Server) HandleAppBskyGraphGetMemberships(c echo.Context) error { 406 + ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleAppBskyGraphGetMemberships") 327 407 defer span.End() 328 - var out *comatprototypes.SessionRefresh_Output 408 + actor := c.QueryParam("actor") 409 + before := c.QueryParam("before") 410 + 411 + var limit int 412 + if p := c.QueryParam("limit"); p != "" { 413 + var err error 414 + limit, err = strconv.Atoi(p) 415 + if err != nil { 416 + return err 417 + } 418 + } else { 419 + limit = 50 420 + } 421 + var out *appbskytypes.GraphGetMemberships_Output 329 422 var handleErr error 330 - // func (s *Server) handleComAtprotoSessionRefresh(ctx context.Context) (*comatprototypes.SessionRefresh_Output, error) 331 - out, handleErr = s.handleComAtprotoSessionRefresh(ctx) 423 + // func (s *Server) handleAppBskyGraphGetMemberships(ctx context.Context,actor string,before string,limit int) (*appbskytypes.GraphGetMemberships_Output, error) 424 + out, handleErr = s.handleAppBskyGraphGetMemberships(ctx, actor, before, limit) 332 425 if handleErr != nil { 333 426 return handleErr 334 427 } 335 428 return c.JSON(200, out) 336 429 } 337 430 338 - func (s *Server) HandleComAtprotoSyncGetRepo(c echo.Context) error { 339 - ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleComAtprotoSyncGetRepo") 431 + func (s *Server) HandleAppBskyNotificationGetCount(c echo.Context) error { 432 + ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleAppBskyNotificationGetCount") 340 433 defer span.End() 341 - did := c.QueryParam("did") 342 - from := c.QueryParam("from") 343 - var out io.Reader 434 + var out *appbskytypes.NotificationGetCount_Output 344 435 var handleErr error 345 - // func (s *Server) handleComAtprotoSyncGetRepo(ctx context.Context,did string,from string) (io.Reader, error) 346 - out, handleErr = s.handleComAtprotoSyncGetRepo(ctx, did, from) 436 + // func (s *Server) handleAppBskyNotificationGetCount(ctx context.Context) (*appbskytypes.NotificationGetCount_Output, error) 437 + out, handleErr = s.handleAppBskyNotificationGetCount(ctx) 347 438 if handleErr != nil { 348 439 return handleErr 349 440 } 350 441 return c.JSON(200, out) 351 442 } 352 443 353 - func (s *Server) HandleComAtprotoSyncGetRoot(c echo.Context) error { 354 - ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleComAtprotoSyncGetRoot") 444 + func (s *Server) HandleAppBskyNotificationList(c echo.Context) error { 445 + ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleAppBskyNotificationList") 355 446 defer span.End() 356 - did := c.QueryParam("did") 357 - var out *comatprototypes.SyncGetRoot_Output 447 + before := c.QueryParam("before") 448 + 449 + var limit int 450 + if p := c.QueryParam("limit"); p != "" { 451 + var err error 452 + limit, err = strconv.Atoi(p) 453 + if err != nil { 454 + return err 455 + } 456 + } else { 457 + limit = 50 458 + } 459 + var out *appbskytypes.NotificationList_Output 358 460 var handleErr error 359 - // func (s *Server) handleComAtprotoSyncGetRoot(ctx context.Context,did string) (*comatprototypes.SyncGetRoot_Output, error) 360 - out, handleErr = s.handleComAtprotoSyncGetRoot(ctx, did) 461 + // func (s *Server) handleAppBskyNotificationList(ctx context.Context,before string,limit int) (*appbskytypes.NotificationList_Output, error) 462 + out, handleErr = s.handleAppBskyNotificationList(ctx, before, limit) 361 463 if handleErr != nil { 362 464 return handleErr 363 465 } 364 466 return c.JSON(200, out) 365 467 } 366 468 367 - func (s *Server) HandleComAtprotoSyncUpdateRepo(c echo.Context) error { 368 - ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleComAtprotoSyncUpdateRepo") 469 + func (s *Server) HandleAppBskyNotificationUpdateSeen(c echo.Context) error { 470 + ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleAppBskyNotificationUpdateSeen") 369 471 defer span.End() 370 - body := c.Request().Body 472 + 473 + var body appbskytypes.NotificationUpdateSeen_Input 474 + if err := c.Bind(&body); err != nil { 475 + return err 476 + } 371 477 var handleErr error 372 - // func (s *Server) handleComAtprotoSyncUpdateRepo(ctx context.Context,r io.Reader) error 373 - handleErr = s.handleComAtprotoSyncUpdateRepo(ctx, body) 478 + // func (s *Server) handleAppBskyNotificationUpdateSeen(ctx context.Context,body appbskytypes.NotificationUpdateSeen_Input) error 479 + handleErr = s.handleAppBskyNotificationUpdateSeen(ctx, &body) 374 480 if handleErr != nil { 375 481 return handleErr 376 482 } 377 483 return nil 378 484 } 379 485 380 - func (s *Server) RegisterHandlersAppBsky(e *echo.Echo) error { 381 - e.POST("/xrpc/app.bsky.actor.createScene", s.HandleAppBskyActorCreateScene) 382 - e.GET("/xrpc/app.bsky.actor.getProfile", s.HandleAppBskyActorGetProfile) 383 - e.GET("/xrpc/app.bsky.actor.getSuggestions", s.HandleAppBskyActorGetSuggestions) 384 - e.GET("/xrpc/app.bsky.actor.search", s.HandleAppBskyActorSearch) 385 - e.GET("/xrpc/app.bsky.actor.searchTypeahead", s.HandleAppBskyActorSearchTypeahead) 386 - e.POST("/xrpc/app.bsky.actor.updateProfile", s.HandleAppBskyActorUpdateProfile) 387 - e.GET("/xrpc/app.bsky.feed.getAuthorFeed", s.HandleAppBskyFeedGetAuthorFeed) 388 - e.GET("/xrpc/app.bsky.feed.getPostThread", s.HandleAppBskyFeedGetPostThread) 389 - e.GET("/xrpc/app.bsky.feed.getRepostedBy", s.HandleAppBskyFeedGetRepostedBy) 390 - e.GET("/xrpc/app.bsky.feed.getTimeline", s.HandleAppBskyFeedGetTimeline) 391 - e.GET("/xrpc/app.bsky.feed.getVotes", s.HandleAppBskyFeedGetVotes) 392 - e.POST("/xrpc/app.bsky.feed.setVote", s.HandleAppBskyFeedSetVote) 393 - e.GET("/xrpc/app.bsky.graph.getAssertions", s.HandleAppBskyGraphGetAssertions) 394 - e.GET("/xrpc/app.bsky.graph.getFollowers", s.HandleAppBskyGraphGetFollowers) 395 - e.GET("/xrpc/app.bsky.graph.getFollows", s.HandleAppBskyGraphGetFollows) 396 - e.GET("/xrpc/app.bsky.graph.getMembers", s.HandleAppBskyGraphGetMembers) 397 - e.GET("/xrpc/app.bsky.graph.getMemberships", s.HandleAppBskyGraphGetMemberships) 398 - e.GET("/xrpc/app.bsky.notification.getCount", s.HandleAppBskyNotificationGetCount) 399 - e.GET("/xrpc/app.bsky.notification.list", s.HandleAppBskyNotificationList) 400 - e.POST("/xrpc/app.bsky.notification.updateSeen", s.HandleAppBskyNotificationUpdateSeen) 486 + func (s *Server) RegisterHandlersComAtproto(e *echo.Echo) error { 487 + e.POST("/xrpc/com.atproto.account.create", s.HandleComAtprotoAccountCreate) 488 + e.POST("/xrpc/com.atproto.account.createInviteCode", s.HandleComAtprotoAccountCreateInviteCode) 489 + e.POST("/xrpc/com.atproto.account.delete", s.HandleComAtprotoAccountDelete) 490 + e.GET("/xrpc/com.atproto.account.get", s.HandleComAtprotoAccountGet) 491 + e.POST("/xrpc/com.atproto.account.requestPasswordReset", s.HandleComAtprotoAccountRequestPasswordReset) 492 + e.POST("/xrpc/com.atproto.account.resetPassword", s.HandleComAtprotoAccountResetPassword) 493 + e.GET("/xrpc/com.atproto.handle.resolve", s.HandleComAtprotoHandleResolve) 494 + e.POST("/xrpc/com.atproto.repo.batchWrite", s.HandleComAtprotoRepoBatchWrite) 495 + e.POST("/xrpc/com.atproto.repo.createRecord", s.HandleComAtprotoRepoCreateRecord) 496 + e.POST("/xrpc/com.atproto.repo.deleteRecord", s.HandleComAtprotoRepoDeleteRecord) 497 + e.GET("/xrpc/com.atproto.repo.describe", s.HandleComAtprotoRepoDescribe) 498 + e.GET("/xrpc/com.atproto.repo.getRecord", s.HandleComAtprotoRepoGetRecord) 499 + e.GET("/xrpc/com.atproto.repo.listRecords", s.HandleComAtprotoRepoListRecords) 500 + e.POST("/xrpc/com.atproto.repo.putRecord", s.HandleComAtprotoRepoPutRecord) 501 + e.GET("/xrpc/com.atproto.server.getAccountsConfig", s.HandleComAtprotoServerGetAccountsConfig) 502 + e.POST("/xrpc/com.atproto.session.create", s.HandleComAtprotoSessionCreate) 503 + e.POST("/xrpc/com.atproto.session.delete", s.HandleComAtprotoSessionDelete) 504 + e.GET("/xrpc/com.atproto.session.get", s.HandleComAtprotoSessionGet) 505 + e.POST("/xrpc/com.atproto.session.refresh", s.HandleComAtprotoSessionRefresh) 506 + e.GET("/xrpc/com.atproto.sync.getRepo", s.HandleComAtprotoSyncGetRepo) 507 + e.GET("/xrpc/com.atproto.sync.getRoot", s.HandleComAtprotoSyncGetRoot) 508 + e.POST("/xrpc/com.atproto.sync.updateRepo", s.HandleComAtprotoSyncUpdateRepo) 401 509 return nil 402 510 } 403 511 404 - func (s *Server) HandleAppBskyActorCreateScene(c echo.Context) error { 405 - ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleAppBskyActorCreateScene") 512 + func (s *Server) HandleComAtprotoAccountCreate(c echo.Context) error { 513 + ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleComAtprotoAccountCreate") 406 514 defer span.End() 407 515 408 - var body appbskytypes.ActorCreateScene_Input 516 + var body comatprototypes.AccountCreate_Input 409 517 if err := c.Bind(&body); err != nil { 410 518 return err 411 519 } 412 - var out *appbskytypes.ActorCreateScene_Output 520 + var out *comatprototypes.AccountCreate_Output 413 521 var handleErr error 414 - // func (s *Server) handleAppBskyActorCreateScene(ctx context.Context,body appbskytypes.ActorCreateScene_Input) (*appbskytypes.ActorCreateScene_Output, error) 415 - out, handleErr = s.handleAppBskyActorCreateScene(ctx, &body) 522 + // func (s *Server) handleComAtprotoAccountCreate(ctx context.Context,body comatprototypes.AccountCreate_Input) (*comatprototypes.AccountCreate_Output, error) 523 + out, handleErr = s.handleComAtprotoAccountCreate(ctx, &body) 416 524 if handleErr != nil { 417 525 return handleErr 418 526 } 419 527 return c.JSON(200, out) 420 528 } 421 529 422 - func (s *Server) HandleAppBskyActorGetProfile(c echo.Context) error { 423 - ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleAppBskyActorGetProfile") 530 + func (s *Server) HandleComAtprotoAccountCreateInviteCode(c echo.Context) error { 531 + ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleComAtprotoAccountCreateInviteCode") 424 532 defer span.End() 425 - actor := c.QueryParam("actor") 426 - var out *appbskytypes.ActorGetProfile_Output 533 + 534 + var body comatprototypes.AccountCreateInviteCode_Input 535 + if err := c.Bind(&body); err != nil { 536 + return err 537 + } 538 + var out *comatprototypes.AccountCreateInviteCode_Output 427 539 var handleErr error 428 - // func (s *Server) handleAppBskyActorGetProfile(ctx context.Context,actor string) (*appbskytypes.ActorGetProfile_Output, error) 429 - out, handleErr = s.handleAppBskyActorGetProfile(ctx, actor) 540 + // func (s *Server) handleComAtprotoAccountCreateInviteCode(ctx context.Context,body comatprototypes.AccountCreateInviteCode_Input) (*comatprototypes.AccountCreateInviteCode_Output, error) 541 + out, handleErr = s.handleComAtprotoAccountCreateInviteCode(ctx, &body) 430 542 if handleErr != nil { 431 543 return handleErr 432 544 } 433 545 return c.JSON(200, out) 434 546 } 435 547 436 - func (s *Server) HandleAppBskyActorGetSuggestions(c echo.Context) error { 437 - ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleAppBskyActorGetSuggestions") 548 + func (s *Server) HandleComAtprotoAccountDelete(c echo.Context) error { 549 + ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleComAtprotoAccountDelete") 438 550 defer span.End() 439 - cursor := c.QueryParam("cursor") 551 + var handleErr error 552 + // func (s *Server) handleComAtprotoAccountDelete(ctx context.Context) error 553 + handleErr = s.handleComAtprotoAccountDelete(ctx) 554 + if handleErr != nil { 555 + return handleErr 556 + } 557 + return nil 558 + } 440 559 441 - limit, err := strconv.Atoi(c.QueryParam("limit")) 442 - if err != nil { 443 - return err 444 - } 445 - var out *appbskytypes.ActorGetSuggestions_Output 560 + func (s *Server) HandleComAtprotoAccountGet(c echo.Context) error { 561 + ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleComAtprotoAccountGet") 562 + defer span.End() 446 563 var handleErr error 447 - // func (s *Server) handleAppBskyActorGetSuggestions(ctx context.Context,cursor string,limit int) (*appbskytypes.ActorGetSuggestions_Output, error) 448 - out, handleErr = s.handleAppBskyActorGetSuggestions(ctx, cursor, limit) 564 + // func (s *Server) handleComAtprotoAccountGet(ctx context.Context) error 565 + handleErr = s.handleComAtprotoAccountGet(ctx) 449 566 if handleErr != nil { 450 567 return handleErr 451 568 } 452 - return c.JSON(200, out) 569 + return nil 453 570 } 454 571 455 - func (s *Server) HandleAppBskyActorSearch(c echo.Context) error { 456 - ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleAppBskyActorSearch") 572 + func (s *Server) HandleComAtprotoAccountRequestPasswordReset(c echo.Context) error { 573 + ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleComAtprotoAccountRequestPasswordReset") 457 574 defer span.End() 458 - before := c.QueryParam("before") 459 575 460 - limit, err := strconv.Atoi(c.QueryParam("limit")) 461 - if err != nil { 576 + var body comatprototypes.AccountRequestPasswordReset_Input 577 + if err := c.Bind(&body); err != nil { 462 578 return err 463 579 } 464 - term := c.QueryParam("term") 465 - var out *appbskytypes.ActorSearch_Output 466 580 var handleErr error 467 - // func (s *Server) handleAppBskyActorSearch(ctx context.Context,before string,limit int,term string) (*appbskytypes.ActorSearch_Output, error) 468 - out, handleErr = s.handleAppBskyActorSearch(ctx, before, limit, term) 581 + // func (s *Server) handleComAtprotoAccountRequestPasswordReset(ctx context.Context,body comatprototypes.AccountRequestPasswordReset_Input) error 582 + handleErr = s.handleComAtprotoAccountRequestPasswordReset(ctx, &body) 469 583 if handleErr != nil { 470 584 return handleErr 471 585 } 472 - return c.JSON(200, out) 586 + return nil 473 587 } 474 588 475 - func (s *Server) HandleAppBskyActorSearchTypeahead(c echo.Context) error { 476 - ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleAppBskyActorSearchTypeahead") 589 + func (s *Server) HandleComAtprotoAccountResetPassword(c echo.Context) error { 590 + ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleComAtprotoAccountResetPassword") 477 591 defer span.End() 478 592 479 - limit, err := strconv.Atoi(c.QueryParam("limit")) 480 - if err != nil { 593 + var body comatprototypes.AccountResetPassword_Input 594 + if err := c.Bind(&body); err != nil { 481 595 return err 482 596 } 483 - term := c.QueryParam("term") 484 - var out *appbskytypes.ActorSearchTypeahead_Output 597 + var handleErr error 598 + // func (s *Server) handleComAtprotoAccountResetPassword(ctx context.Context,body comatprototypes.AccountResetPassword_Input) error 599 + handleErr = s.handleComAtprotoAccountResetPassword(ctx, &body) 600 + if handleErr != nil { 601 + return handleErr 602 + } 603 + return nil 604 + } 605 + 606 + func (s *Server) HandleComAtprotoHandleResolve(c echo.Context) error { 607 + ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleComAtprotoHandleResolve") 608 + defer span.End() 609 + handle := c.QueryParam("handle") 610 + var out *comatprototypes.HandleResolve_Output 485 611 var handleErr error 486 - // func (s *Server) handleAppBskyActorSearchTypeahead(ctx context.Context,limit int,term string) (*appbskytypes.ActorSearchTypeahead_Output, error) 487 - out, handleErr = s.handleAppBskyActorSearchTypeahead(ctx, limit, term) 612 + // func (s *Server) handleComAtprotoHandleResolve(ctx context.Context,handle string) (*comatprototypes.HandleResolve_Output, error) 613 + out, handleErr = s.handleComAtprotoHandleResolve(ctx, handle) 488 614 if handleErr != nil { 489 615 return handleErr 490 616 } 491 617 return c.JSON(200, out) 492 618 } 493 619 494 - func (s *Server) HandleAppBskyActorUpdateProfile(c echo.Context) error { 495 - ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleAppBskyActorUpdateProfile") 620 + func (s *Server) HandleComAtprotoRepoBatchWrite(c echo.Context) error { 621 + ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleComAtprotoRepoBatchWrite") 496 622 defer span.End() 497 623 498 - var body appbskytypes.ActorUpdateProfile_Input 624 + var body comatprototypes.RepoBatchWrite_Input 499 625 if err := c.Bind(&body); err != nil { 500 626 return err 501 627 } 502 - var out *appbskytypes.ActorUpdateProfile_Output 503 628 var handleErr error 504 - // func (s *Server) handleAppBskyActorUpdateProfile(ctx context.Context,body appbskytypes.ActorUpdateProfile_Input) (*appbskytypes.ActorUpdateProfile_Output, error) 505 - out, handleErr = s.handleAppBskyActorUpdateProfile(ctx, &body) 629 + // func (s *Server) handleComAtprotoRepoBatchWrite(ctx context.Context,body comatprototypes.RepoBatchWrite_Input) error 630 + handleErr = s.handleComAtprotoRepoBatchWrite(ctx, &body) 506 631 if handleErr != nil { 507 632 return handleErr 508 633 } 509 - return c.JSON(200, out) 634 + return nil 510 635 } 511 636 512 - func (s *Server) HandleAppBskyFeedGetAuthorFeed(c echo.Context) error { 513 - ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleAppBskyFeedGetAuthorFeed") 637 + func (s *Server) HandleComAtprotoRepoCreateRecord(c echo.Context) error { 638 + ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleComAtprotoRepoCreateRecord") 514 639 defer span.End() 515 - author := c.QueryParam("author") 516 - before := c.QueryParam("before") 517 640 518 - limit, err := strconv.Atoi(c.QueryParam("limit")) 519 - if err != nil { 641 + var body comatprototypes.RepoCreateRecord_Input 642 + if err := c.Bind(&body); err != nil { 520 643 return err 521 644 } 522 - var out *appbskytypes.FeedGetAuthorFeed_Output 645 + var out *comatprototypes.RepoCreateRecord_Output 523 646 var handleErr error 524 - // func (s *Server) handleAppBskyFeedGetAuthorFeed(ctx context.Context,author string,before string,limit int) (*appbskytypes.FeedGetAuthorFeed_Output, error) 525 - out, handleErr = s.handleAppBskyFeedGetAuthorFeed(ctx, author, before, limit) 647 + // func (s *Server) handleComAtprotoRepoCreateRecord(ctx context.Context,body comatprototypes.RepoCreateRecord_Input) (*comatprototypes.RepoCreateRecord_Output, error) 648 + out, handleErr = s.handleComAtprotoRepoCreateRecord(ctx, &body) 526 649 if handleErr != nil { 527 650 return handleErr 528 651 } 529 652 return c.JSON(200, out) 530 653 } 531 654 532 - func (s *Server) HandleAppBskyFeedGetPostThread(c echo.Context) error { 533 - ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleAppBskyFeedGetPostThread") 655 + func (s *Server) HandleComAtprotoRepoDeleteRecord(c echo.Context) error { 656 + ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleComAtprotoRepoDeleteRecord") 534 657 defer span.End() 535 658 536 - depth, err := strconv.Atoi(c.QueryParam("depth")) 537 - if err != nil { 659 + var body comatprototypes.RepoDeleteRecord_Input 660 + if err := c.Bind(&body); err != nil { 538 661 return err 539 662 } 540 - uri := c.QueryParam("uri") 541 - var out *appbskytypes.FeedGetPostThread_Output 542 663 var handleErr error 543 - // func (s *Server) handleAppBskyFeedGetPostThread(ctx context.Context,depth int,uri string) (*appbskytypes.FeedGetPostThread_Output, error) 544 - out, handleErr = s.handleAppBskyFeedGetPostThread(ctx, depth, uri) 664 + // func (s *Server) handleComAtprotoRepoDeleteRecord(ctx context.Context,body comatprototypes.RepoDeleteRecord_Input) error 665 + handleErr = s.handleComAtprotoRepoDeleteRecord(ctx, &body) 545 666 if handleErr != nil { 546 667 return handleErr 547 668 } 548 - return c.JSON(200, out) 669 + return nil 549 670 } 550 671 551 - func (s *Server) HandleAppBskyFeedGetRepostedBy(c echo.Context) error { 552 - ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleAppBskyFeedGetRepostedBy") 672 + func (s *Server) HandleComAtprotoRepoDescribe(c echo.Context) error { 673 + ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleComAtprotoRepoDescribe") 553 674 defer span.End() 554 - before := c.QueryParam("before") 555 - cid := c.QueryParam("cid") 556 - 557 - limit, err := strconv.Atoi(c.QueryParam("limit")) 558 - if err != nil { 559 - return err 560 - } 561 - uri := c.QueryParam("uri") 562 - var out *appbskytypes.FeedGetRepostedBy_Output 675 + user := c.QueryParam("user") 676 + var out *comatprototypes.RepoDescribe_Output 563 677 var handleErr error 564 - // func (s *Server) handleAppBskyFeedGetRepostedBy(ctx context.Context,before string,cid string,limit int,uri string) (*appbskytypes.FeedGetRepostedBy_Output, error) 565 - out, handleErr = s.handleAppBskyFeedGetRepostedBy(ctx, before, cid, limit, uri) 678 + // func (s *Server) handleComAtprotoRepoDescribe(ctx context.Context,user string) (*comatprototypes.RepoDescribe_Output, error) 679 + out, handleErr = s.handleComAtprotoRepoDescribe(ctx, user) 566 680 if handleErr != nil { 567 681 return handleErr 568 682 } 569 683 return c.JSON(200, out) 570 684 } 571 685 572 - func (s *Server) HandleAppBskyFeedGetTimeline(c echo.Context) error { 573 - ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleAppBskyFeedGetTimeline") 686 + func (s *Server) HandleComAtprotoRepoGetRecord(c echo.Context) error { 687 + ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleComAtprotoRepoGetRecord") 574 688 defer span.End() 575 - algorithm := c.QueryParam("algorithm") 576 - before := c.QueryParam("before") 577 - 578 - limit, err := strconv.Atoi(c.QueryParam("limit")) 579 - if err != nil { 580 - return err 581 - } 582 - var out *appbskytypes.FeedGetTimeline_Output 689 + cid := c.QueryParam("cid") 690 + collection := c.QueryParam("collection") 691 + rkey := c.QueryParam("rkey") 692 + user := c.QueryParam("user") 693 + var out *comatprototypes.RepoGetRecord_Output 583 694 var handleErr error 584 - // func (s *Server) handleAppBskyFeedGetTimeline(ctx context.Context,algorithm string,before string,limit int) (*appbskytypes.FeedGetTimeline_Output, error) 585 - out, handleErr = s.handleAppBskyFeedGetTimeline(ctx, algorithm, before, limit) 695 + // func (s *Server) handleComAtprotoRepoGetRecord(ctx context.Context,cid string,collection string,rkey string,user string) (*comatprototypes.RepoGetRecord_Output, error) 696 + out, handleErr = s.handleComAtprotoRepoGetRecord(ctx, cid, collection, rkey, user) 586 697 if handleErr != nil { 587 698 return handleErr 588 699 } 589 700 return c.JSON(200, out) 590 701 } 591 702 592 - func (s *Server) HandleAppBskyFeedGetVotes(c echo.Context) error { 593 - ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleAppBskyFeedGetVotes") 703 + func (s *Server) HandleComAtprotoRepoListRecords(c echo.Context) error { 704 + ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleComAtprotoRepoListRecords") 594 705 defer span.End() 706 + after := c.QueryParam("after") 595 707 before := c.QueryParam("before") 596 - cid := c.QueryParam("cid") 597 - direction := c.QueryParam("direction") 708 + collection := c.QueryParam("collection") 598 709 599 - limit, err := strconv.Atoi(c.QueryParam("limit")) 600 - if err != nil { 601 - return err 710 + var limit int 711 + if p := c.QueryParam("limit"); p != "" { 712 + var err error 713 + limit, err = strconv.Atoi(p) 714 + if err != nil { 715 + return err 716 + } 717 + } else { 718 + limit = 50 602 719 } 603 - uri := c.QueryParam("uri") 604 - var out *appbskytypes.FeedGetVotes_Output 720 + var out *comatprototypes.RepoListRecords_Output 605 721 var handleErr error 606 - // func (s *Server) handleAppBskyFeedGetVotes(ctx context.Context,before string,cid string,direction string,limit int,uri string) (*appbskytypes.FeedGetVotes_Output, error) 607 - out, handleErr = s.handleAppBskyFeedGetVotes(ctx, before, cid, direction, limit, uri) 722 + // func (s *Server) handleComAtprotoRepoListRecords(ctx context.Context,after string,before string,collection string,limit int) (*comatprototypes.RepoListRecords_Output, error) 723 + out, handleErr = s.handleComAtprotoRepoListRecords(ctx, after, before, collection, limit) 608 724 if handleErr != nil { 609 725 return handleErr 610 726 } 611 727 return c.JSON(200, out) 612 728 } 613 729 614 - func (s *Server) HandleAppBskyFeedSetVote(c echo.Context) error { 615 - ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleAppBskyFeedSetVote") 730 + func (s *Server) HandleComAtprotoRepoPutRecord(c echo.Context) error { 731 + ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleComAtprotoRepoPutRecord") 616 732 defer span.End() 617 733 618 - var body appbskytypes.FeedSetVote_Input 734 + var body comatprototypes.RepoPutRecord_Input 619 735 if err := c.Bind(&body); err != nil { 620 736 return err 621 737 } 622 - var out *appbskytypes.FeedSetVote_Output 738 + var out *comatprototypes.RepoPutRecord_Output 623 739 var handleErr error 624 - // func (s *Server) handleAppBskyFeedSetVote(ctx context.Context,body appbskytypes.FeedSetVote_Input) (*appbskytypes.FeedSetVote_Output, error) 625 - out, handleErr = s.handleAppBskyFeedSetVote(ctx, &body) 740 + // func (s *Server) handleComAtprotoRepoPutRecord(ctx context.Context,body comatprototypes.RepoPutRecord_Input) (*comatprototypes.RepoPutRecord_Output, error) 741 + out, handleErr = s.handleComAtprotoRepoPutRecord(ctx, &body) 626 742 if handleErr != nil { 627 743 return handleErr 628 744 } 629 745 return c.JSON(200, out) 630 746 } 631 747 632 - func (s *Server) HandleAppBskyGraphGetAssertions(c echo.Context) error { 633 - ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleAppBskyGraphGetAssertions") 748 + func (s *Server) HandleComAtprotoServerGetAccountsConfig(c echo.Context) error { 749 + ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleComAtprotoServerGetAccountsConfig") 634 750 defer span.End() 635 - assertion := c.QueryParam("assertion") 636 - author := c.QueryParam("author") 637 - before := c.QueryParam("before") 638 - var out *appbskytypes.GraphGetAssertions_Output 751 + var out *comatprototypes.ServerGetAccountsConfig_Output 639 752 var handleErr error 640 - // func (s *Server) handleAppBskyGraphGetAssertions(ctx context.Context,assertion string,author string,before string) (*appbskytypes.GraphGetAssertions_Output, error) 641 - out, handleErr = s.handleAppBskyGraphGetAssertions(ctx, assertion, author, before) 753 + // func (s *Server) handleComAtprotoServerGetAccountsConfig(ctx context.Context) (*comatprototypes.ServerGetAccountsConfig_Output, error) 754 + out, handleErr = s.handleComAtprotoServerGetAccountsConfig(ctx) 642 755 if handleErr != nil { 643 756 return handleErr 644 757 } 645 758 return c.JSON(200, out) 646 759 } 647 760 648 - func (s *Server) HandleAppBskyGraphGetFollowers(c echo.Context) error { 649 - ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleAppBskyGraphGetFollowers") 761 + func (s *Server) HandleComAtprotoSessionCreate(c echo.Context) error { 762 + ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleComAtprotoSessionCreate") 650 763 defer span.End() 651 - before := c.QueryParam("before") 652 764 653 - limit, err := strconv.Atoi(c.QueryParam("limit")) 654 - if err != nil { 765 + var body comatprototypes.SessionCreate_Input 766 + if err := c.Bind(&body); err != nil { 655 767 return err 656 768 } 657 - user := c.QueryParam("user") 658 - var out *appbskytypes.GraphGetFollowers_Output 769 + var out *comatprototypes.SessionCreate_Output 659 770 var handleErr error 660 - // func (s *Server) handleAppBskyGraphGetFollowers(ctx context.Context,before string,limit int,user string) (*appbskytypes.GraphGetFollowers_Output, error) 661 - out, handleErr = s.handleAppBskyGraphGetFollowers(ctx, before, limit, user) 771 + // func (s *Server) handleComAtprotoSessionCreate(ctx context.Context,body comatprototypes.SessionCreate_Input) (*comatprototypes.SessionCreate_Output, error) 772 + out, handleErr = s.handleComAtprotoSessionCreate(ctx, &body) 662 773 if handleErr != nil { 663 774 return handleErr 664 775 } 665 776 return c.JSON(200, out) 666 777 } 667 778 668 - func (s *Server) HandleAppBskyGraphGetFollows(c echo.Context) error { 669 - ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleAppBskyGraphGetFollows") 779 + func (s *Server) HandleComAtprotoSessionDelete(c echo.Context) error { 780 + ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleComAtprotoSessionDelete") 670 781 defer span.End() 671 - before := c.QueryParam("before") 672 - 673 - limit, err := strconv.Atoi(c.QueryParam("limit")) 674 - if err != nil { 675 - return err 676 - } 677 - user := c.QueryParam("user") 678 - var out *appbskytypes.GraphGetFollows_Output 679 782 var handleErr error 680 - // func (s *Server) handleAppBskyGraphGetFollows(ctx context.Context,before string,limit int,user string) (*appbskytypes.GraphGetFollows_Output, error) 681 - out, handleErr = s.handleAppBskyGraphGetFollows(ctx, before, limit, user) 783 + // func (s *Server) handleComAtprotoSessionDelete(ctx context.Context) error 784 + handleErr = s.handleComAtprotoSessionDelete(ctx) 682 785 if handleErr != nil { 683 786 return handleErr 684 787 } 685 - return c.JSON(200, out) 788 + return nil 686 789 } 687 790 688 - func (s *Server) HandleAppBskyGraphGetMembers(c echo.Context) error { 689 - ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleAppBskyGraphGetMembers") 791 + func (s *Server) HandleComAtprotoSessionGet(c echo.Context) error { 792 + ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleComAtprotoSessionGet") 690 793 defer span.End() 691 - actor := c.QueryParam("actor") 692 - before := c.QueryParam("before") 693 - 694 - limit, err := strconv.Atoi(c.QueryParam("limit")) 695 - if err != nil { 696 - return err 697 - } 698 - var out *appbskytypes.GraphGetMembers_Output 794 + var out *comatprototypes.SessionGet_Output 699 795 var handleErr error 700 - // func (s *Server) handleAppBskyGraphGetMembers(ctx context.Context,actor string,before string,limit int) (*appbskytypes.GraphGetMembers_Output, error) 701 - out, handleErr = s.handleAppBskyGraphGetMembers(ctx, actor, before, limit) 796 + // func (s *Server) handleComAtprotoSessionGet(ctx context.Context) (*comatprototypes.SessionGet_Output, error) 797 + out, handleErr = s.handleComAtprotoSessionGet(ctx) 702 798 if handleErr != nil { 703 799 return handleErr 704 800 } 705 801 return c.JSON(200, out) 706 802 } 707 803 708 - func (s *Server) HandleAppBskyGraphGetMemberships(c echo.Context) error { 709 - ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleAppBskyGraphGetMemberships") 804 + func (s *Server) HandleComAtprotoSessionRefresh(c echo.Context) error { 805 + ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleComAtprotoSessionRefresh") 710 806 defer span.End() 711 - actor := c.QueryParam("actor") 712 - before := c.QueryParam("before") 713 - 714 - limit, err := strconv.Atoi(c.QueryParam("limit")) 715 - if err != nil { 716 - return err 717 - } 718 - var out *appbskytypes.GraphGetMemberships_Output 807 + var out *comatprototypes.SessionRefresh_Output 719 808 var handleErr error 720 - // func (s *Server) handleAppBskyGraphGetMemberships(ctx context.Context,actor string,before string,limit int) (*appbskytypes.GraphGetMemberships_Output, error) 721 - out, handleErr = s.handleAppBskyGraphGetMemberships(ctx, actor, before, limit) 809 + // func (s *Server) handleComAtprotoSessionRefresh(ctx context.Context) (*comatprototypes.SessionRefresh_Output, error) 810 + out, handleErr = s.handleComAtprotoSessionRefresh(ctx) 722 811 if handleErr != nil { 723 812 return handleErr 724 813 } 725 814 return c.JSON(200, out) 726 815 } 727 816 728 - func (s *Server) HandleAppBskyNotificationGetCount(c echo.Context) error { 729 - ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleAppBskyNotificationGetCount") 817 + func (s *Server) HandleComAtprotoSyncGetRepo(c echo.Context) error { 818 + ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleComAtprotoSyncGetRepo") 730 819 defer span.End() 731 - var out *appbskytypes.NotificationGetCount_Output 820 + did := c.QueryParam("did") 821 + from := c.QueryParam("from") 822 + var out io.Reader 732 823 var handleErr error 733 - // func (s *Server) handleAppBskyNotificationGetCount(ctx context.Context) (*appbskytypes.NotificationGetCount_Output, error) 734 - out, handleErr = s.handleAppBskyNotificationGetCount(ctx) 824 + // func (s *Server) handleComAtprotoSyncGetRepo(ctx context.Context,did string,from string) (io.Reader, error) 825 + out, handleErr = s.handleComAtprotoSyncGetRepo(ctx, did, from) 735 826 if handleErr != nil { 736 827 return handleErr 737 828 } 738 829 return c.JSON(200, out) 739 830 } 740 831 741 - func (s *Server) HandleAppBskyNotificationList(c echo.Context) error { 742 - ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleAppBskyNotificationList") 832 + func (s *Server) HandleComAtprotoSyncGetRoot(c echo.Context) error { 833 + ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleComAtprotoSyncGetRoot") 743 834 defer span.End() 744 - before := c.QueryParam("before") 745 - 746 - limit, err := strconv.Atoi(c.QueryParam("limit")) 747 - if err != nil { 748 - return err 749 - } 750 - var out *appbskytypes.NotificationList_Output 835 + did := c.QueryParam("did") 836 + var out *comatprototypes.SyncGetRoot_Output 751 837 var handleErr error 752 - // func (s *Server) handleAppBskyNotificationList(ctx context.Context,before string,limit int) (*appbskytypes.NotificationList_Output, error) 753 - out, handleErr = s.handleAppBskyNotificationList(ctx, before, limit) 838 + // func (s *Server) handleComAtprotoSyncGetRoot(ctx context.Context,did string) (*comatprototypes.SyncGetRoot_Output, error) 839 + out, handleErr = s.handleComAtprotoSyncGetRoot(ctx, did) 754 840 if handleErr != nil { 755 841 return handleErr 756 842 } 757 843 return c.JSON(200, out) 758 844 } 759 845 760 - func (s *Server) HandleAppBskyNotificationUpdateSeen(c echo.Context) error { 761 - ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleAppBskyNotificationUpdateSeen") 846 + func (s *Server) HandleComAtprotoSyncUpdateRepo(c echo.Context) error { 847 + ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleComAtprotoSyncUpdateRepo") 762 848 defer span.End() 763 - 764 - var body appbskytypes.NotificationUpdateSeen_Input 765 - if err := c.Bind(&body); err != nil { 766 - return err 767 - } 849 + body := c.Request().Body 768 850 var handleErr error 769 - // func (s *Server) handleAppBskyNotificationUpdateSeen(ctx context.Context,body appbskytypes.NotificationUpdateSeen_Input) error 770 - handleErr = s.handleAppBskyNotificationUpdateSeen(ctx, &body) 851 + // func (s *Server) handleComAtprotoSyncUpdateRepo(ctx context.Context,r io.Reader) error 852 + handleErr = s.handleComAtprotoSyncUpdateRepo(ctx, body) 771 853 if handleErr != nil { 772 854 return handleErr 773 855 }
+26
docs/auth.md
··· 1 + # Auth 2 + 3 + The auth system uses two tokens, an access token and a refresh token. 4 + 5 + The access token is a jwt with the following values: 6 + ``` 7 + scope: "com.atproto.access" 8 + sub: <the users DID> 9 + iat: the current time, in unix epoch seconds 10 + exp: the expiry date, usually around an hour, but at least 15 minutes 11 + ``` 12 + 13 + The refresh token is a jwt with the following values: 14 + ``` 15 + scope: "com.atproto.refresh" 16 + sub: <the users DID> 17 + iat: the current time, in unix epoch seconds 18 + exp: the expiry date, usually around a week, must be significantly longer than the access token 19 + jti: a unique identifier for this token 20 + ``` 21 + 22 + The access token is what is used for all requests, however since it expires 23 + quickly, it must be refreshed periodically using the refresh token. 24 + When the refresh token is used, it must be marked as deleted, and the new token then replaces it. 25 + Note: The old access token is not necessarily disabled at that point of refreshing. 26 +
+54 -25
lex/gen.go
··· 67 67 Const any `json:"const"` 68 68 Enum []string `json:"enum"` 69 69 Closed bool `json:"closed"` 70 + 71 + Default any `json:"default"` 72 + Minimum any `json:"minimum"` 73 + Maximum any `json:"maximum"` 70 74 } 71 75 72 76 func (s *Schema) Name() string { ··· 254 258 255 259 if t.Type.record && !strings.Contains(t.Name, "_") { 256 260 id := t.Type.id 257 - if t.Type.defName != "" { 258 - id = id + "#" + t.Type.defName 259 - } 261 + if t.Type.defName != "" { 262 + id = id + "#" + t.Type.defName 263 + } 260 264 fmt.Fprintf(w, "util.RegisterType(%q, %s{})\n", id, t.Name) 261 265 } 262 266 } ··· 631 635 func (s *TypeSchema) WriteHandlerStub(w io.Writer, fname, shortname, impname string) error { 632 636 paramtypes := []string{"ctx context.Context"} 633 637 if s.Type == "query" { 638 + 634 639 if s.Parameters != nil { 640 + var required map[string]bool 641 + if s.Parameters.Required != nil { 642 + required = make(map[string]bool) 643 + for _, r := range s.Required { 644 + required[r] = true 645 + } 646 + } 635 647 orderedMapIter[TypeSchema](s.Parameters.Properties, func(k string, t TypeSchema) error { 636 648 switch t.Type { 637 649 case "string": 638 650 paramtypes = append(paramtypes, k+" string") 639 651 case "integer": 640 - paramtypes = append(paramtypes, k+" int") 652 + if required != nil && !required[k] { 653 + paramtypes = append(paramtypes, k+" *int") 654 + } else { 655 + paramtypes = append(paramtypes, k+" int") 656 + } 641 657 case "number": 642 658 return fmt.Errorf("non-integer numbers currently unsupported") 643 659 default: ··· 683 699 fmt.Fprintf(w, "ctx, span := otel.Tracer(\"server\").Start(c.Request().Context(), %q)\n", "Handle"+fname) 684 700 fmt.Fprintf(w, "defer span.End()\n") 685 701 686 - var required map[string]bool 687 - if s.Required != nil { 688 - for _, r := range s.Required { 689 - required[r] = true 690 - } 691 - } 692 - 693 702 paramtypes := []string{"ctx context.Context"} 694 703 params := []string{"ctx"} 695 704 if s.Type == "query" { 696 705 if s.Parameters != nil { 706 + required := make(map[string]bool) 707 + for _, r := range s.Parameters.Required { 708 + required[r] = true 709 + } 710 + for k, v := range s.Parameters.Properties { 711 + if v.Default != nil { 712 + required[k] = true 713 + } 714 + } 697 715 orderedMapIter[TypeSchema](s.Parameters.Properties, func(k string, t TypeSchema) error { 698 716 switch t.Type { 699 717 case "string": ··· 703 721 case "integer": 704 722 params = append(params, k) 705 723 706 - if required != nil && !required[k] { 707 - paramtypes = append(paramtypes, k+" *int") 708 - fmt.Fprintf(w, ` 724 + if !required[k] { 725 + paramtypes = append(paramtypes, k+" *int") 726 + fmt.Fprintf(w, ` 709 727 var %s *int 710 728 if p := c.QueryParam("%s"); p != "" { 711 - %s_val, err := strconv.Atoi(p) 729 + %s_val, err := strconv.Atoi(p) 730 + if err != nil { 731 + return err 732 + } 733 + %s = &%s_val 734 + } 735 + `, k, k, k, k, k) 736 + } else if t.Default != nil { 737 + paramtypes = append(paramtypes, k+" int") 738 + fmt.Fprintf(w, ` 739 + var %s int 740 + if p := c.QueryParam("%s"); p != "" { 741 + var err error 742 + %s, err = strconv.Atoi(p) 712 743 if err != nil { 713 744 return err 714 745 } 715 - %s = &%s_val 746 + } else { 747 + %s = %d 716 748 } 717 - `, k, k, k, k, k) 749 + `, k, k,k, k, int(t.Default.(float64))) 718 750 } else { 719 - paramtypes = append(paramtypes, k+" int") 720 - fmt.Fprintf(w, ` 751 + 752 + paramtypes = append(paramtypes, k+" int") 753 + fmt.Fprintf(w, ` 721 754 %s, err := strconv.Atoi(c.QueryParam("%s")) 722 755 if err != nil { 723 756 return err 724 757 } 725 758 `, k, k) 726 759 } 727 - 728 760 729 761 case "number": 730 762 return fmt.Errorf("non-integer numbers currently unsupported") ··· 918 950 fmt.Fprintf(w, "\tLexiconTypeID string `json:\"$type\" cborgen:\"$type,const=%s\"`\n", ts.id) 919 951 } 920 952 921 - var required map[string]bool 922 - if ts.Required != nil { 923 - required = make(map[string]bool) 953 + required := make(map[string]bool) 924 954 for _, req := range ts.Required { 925 955 required[req] = true 926 956 } 927 - } 928 957 929 958 for k, v := range ts.Properties { 930 959 goname := strings.Title(k) ··· 935 964 } 936 965 937 966 var ptr string 938 - if required != nil && !required[k] { 967 + if !required[k] { 939 968 if !strings.HasPrefix(tname, "*") && !strings.HasPrefix(tname, "[]") { 940 969 ptr = "*" 941 970 }
+115
lex/util/cbor_gen.go
··· 1 + // Code generated by github.com/whyrusleeping/cbor-gen. DO NOT EDIT. 2 + 3 + package util 4 + 5 + import ( 6 + "fmt" 7 + "io" 8 + "math" 9 + "sort" 10 + 11 + cid "github.com/ipfs/go-cid" 12 + cbg "github.com/whyrusleeping/cbor-gen" 13 + xerrors "golang.org/x/xerrors" 14 + ) 15 + 16 + var _ = xerrors.Errorf 17 + var _ = cid.Undef 18 + var _ = math.E 19 + var _ = sort.Sort 20 + 21 + func (t *CborChecker) MarshalCBOR(w io.Writer) error { 22 + if t == nil { 23 + _, err := w.Write(cbg.CborNull) 24 + return err 25 + } 26 + 27 + cw := cbg.NewCborWriter(w) 28 + 29 + if _, err := cw.Write([]byte{161}); err != nil { 30 + return err 31 + } 32 + 33 + // t.Type (string) (string) 34 + if len("$type") > cbg.MaxLength { 35 + return xerrors.Errorf("Value in field \"$type\" was too long") 36 + } 37 + 38 + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("$type"))); err != nil { 39 + return err 40 + } 41 + if _, err := io.WriteString(w, string("$type")); err != nil { 42 + return err 43 + } 44 + 45 + if len(t.Type) > cbg.MaxLength { 46 + return xerrors.Errorf("Value in field t.Type was too long") 47 + } 48 + 49 + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Type))); err != nil { 50 + return err 51 + } 52 + if _, err := io.WriteString(w, string(t.Type)); err != nil { 53 + return err 54 + } 55 + return nil 56 + } 57 + 58 + func (t *CborChecker) UnmarshalCBOR(r io.Reader) (err error) { 59 + *t = CborChecker{} 60 + 61 + cr := cbg.NewCborReader(r) 62 + 63 + maj, extra, err := cr.ReadHeader() 64 + if err != nil { 65 + return err 66 + } 67 + defer func() { 68 + if err == io.EOF { 69 + err = io.ErrUnexpectedEOF 70 + } 71 + }() 72 + 73 + if maj != cbg.MajMap { 74 + return fmt.Errorf("cbor input should be of type map") 75 + } 76 + 77 + if extra > cbg.MaxLength { 78 + return fmt.Errorf("CborChecker: map struct too large (%d)", extra) 79 + } 80 + 81 + var name string 82 + n := extra 83 + 84 + for i := uint64(0); i < n; i++ { 85 + 86 + { 87 + sval, err := cbg.ReadString(cr) 88 + if err != nil { 89 + return err 90 + } 91 + 92 + name = string(sval) 93 + } 94 + 95 + switch name { 96 + // t.Type (string) (string) 97 + case "$type": 98 + 99 + { 100 + sval, err := cbg.ReadString(cr) 101 + if err != nil { 102 + return err 103 + } 104 + 105 + t.Type = string(sval) 106 + } 107 + 108 + default: 109 + // Field doesn't exist on this type, so ignore it 110 + cbg.ScanForLinks(r, func(cid.Cid) {}) 111 + } 112 + } 113 + 114 + return nil 115 + }
+78
lex/util/decoder.go
··· 1 + package util 2 + 3 + import ( 4 + "bytes" 5 + "encoding/json" 6 + "fmt" 7 + "reflect" 8 + 9 + cbg "github.com/whyrusleeping/cbor-gen" 10 + ) 11 + 12 + var lexTypesMap map[string]reflect.Type 13 + 14 + func init() { 15 + lexTypesMap = make(map[string]reflect.Type) 16 + } 17 + 18 + func RegisterType(id string, val any) { 19 + t := reflect.TypeOf(val) 20 + 21 + if t.Kind() == reflect.Pointer { 22 + t = t.Elem() 23 + } 24 + 25 + if _, ok := lexTypesMap[id]; ok { 26 + panic(fmt.Sprintf("already registered type for %q", id)) 27 + } 28 + 29 + lexTypesMap[id] = t 30 + } 31 + 32 + func JsonDecodeValue(b []byte) (any, error) { 33 + tstr, err := TypeExtract(b) 34 + if err != nil { 35 + return nil, err 36 + } 37 + 38 + t, ok := lexTypesMap[tstr] 39 + if !ok { 40 + return nil, fmt.Errorf("unrecognized type: %q", tstr) 41 + } 42 + 43 + val := reflect.New(t) 44 + 45 + ival := val.Interface() 46 + if err := json.Unmarshal(b, ival); err != nil { 47 + return nil, err 48 + } 49 + 50 + return ival, nil 51 + } 52 + 53 + func CborDecodeValue(b []byte) (any, error) { 54 + tstr, err := CborTypeExtract(b) 55 + if err != nil { 56 + return nil, err 57 + } 58 + 59 + t, ok := lexTypesMap[tstr] 60 + if !ok { 61 + return nil, fmt.Errorf("unrecognized type: %q", tstr) 62 + } 63 + 64 + val := reflect.New(t) 65 + 66 + ival, ok := val.Interface().(cbg.CBORUnmarshaler) 67 + if !ok { 68 + return nil, fmt.Errorf("registered type did not have proper cbor hooks") 69 + } 70 + 71 + if err := ival.UnmarshalCBOR(bytes.NewReader(b)); err != nil { 72 + return nil, err 73 + } 74 + 75 + fmt.Printf("DECODED VALUE: %#v\n", ival) 76 + 77 + return ival, nil 78 + }
+8 -6
repo/repo.go
··· 113 113 return r.bs 114 114 } 115 115 116 - func (r *Repo) CreateRecord(ctx context.Context, nsid string, rec CborMarshaler) (cid.Cid, error) { 116 + func (r *Repo) CreateRecord(ctx context.Context, nsid string, rec CborMarshaler) (cid.Cid, string, error) { 117 117 r.dirty = true 118 118 t, err := r.getMst(ctx) 119 119 if err != nil { 120 - return cid.Undef, fmt.Errorf("failed to get mst: %w", err) 120 + return cid.Undef, "", fmt.Errorf("failed to get mst: %w", err) 121 121 } 122 122 123 123 k, err := r.cst.Put(ctx, rec) 124 124 if err != nil { 125 - return cid.Undef, err 125 + return cid.Undef, "", err 126 126 } 127 127 128 - nmst, err := t.Add(ctx, nsid+"/"+NextTID(), k, -1) 128 + tid := NextTID() 129 + 130 + nmst, err := t.Add(ctx, nsid+"/"+tid, k, -1) 129 131 if err != nil { 130 - return cid.Undef, fmt.Errorf("mst.Add failed: %w", err) 132 + return cid.Undef, "", fmt.Errorf("mst.Add failed: %w", err) 131 133 } 132 134 133 135 r.mst = nmst 134 - return k, nil 136 + return k, tid, nil 135 137 } 136 138 137 139 func (r *Repo) Commit(ctx context.Context) (cid.Cid, error) {
+3 -5
repomgr/repomgr.go
··· 116 116 } 117 117 118 118 func (rm *RepoManager) CreateRecord(ctx context.Context, user uint, collection string, rec cbg.CBORMarshaler) (string, cid.Cid, error) { 119 - ntid := repo.NextTID() 120 - rkey := collection + "/" + ntid 121 119 122 120 unlock := rm.lockUser(user) 123 121 defer unlock() ··· 137 135 return "", cid.Undef, err 138 136 } 139 137 140 - cc, err := r.CreateRecord(ctx, rkey, rec) 138 + cc, tid, err := r.CreateRecord(ctx, collection, rec) 141 139 if err != nil { 142 140 return "", cid.Undef, err 143 141 } ··· 163 161 OldRoot: head, 164 162 NewRoot: nroot, 165 163 Collection: collection, 166 - Rkey: rkey, 164 + Rkey: tid, 167 165 Record: rec, 168 166 RecCid: cc, 169 167 }) 170 168 } 171 169 172 - return rkey, cc, nil 170 + return collection + "/" + tid, cc, nil 173 171 } 174 172 175 173 func (rm *RepoManager) InitNewActor(ctx context.Context, user uint, handle, did, displayname string, declcid, actortype string) error {