···1010 "go.opentelemetry.io/otel"
1111)
12121313-func (s *Server) RegisterHandlersComAtproto(e *echo.Echo) error {
1414- e.POST("/xrpc/com.atproto.account.create", s.HandleComAtprotoAccountCreate)
1515- e.POST("/xrpc/com.atproto.account.createInviteCode", s.HandleComAtprotoAccountCreateInviteCode)
1616- e.POST("/xrpc/com.atproto.account.delete", s.HandleComAtprotoAccountDelete)
1717- e.GET("/xrpc/com.atproto.account.get", s.HandleComAtprotoAccountGet)
1818- e.POST("/xrpc/com.atproto.account.requestPasswordReset", s.HandleComAtprotoAccountRequestPasswordReset)
1919- e.POST("/xrpc/com.atproto.account.resetPassword", s.HandleComAtprotoAccountResetPassword)
2020- e.GET("/xrpc/com.atproto.handle.resolve", s.HandleComAtprotoHandleResolve)
2121- e.POST("/xrpc/com.atproto.repo.batchWrite", s.HandleComAtprotoRepoBatchWrite)
2222- e.POST("/xrpc/com.atproto.repo.createRecord", s.HandleComAtprotoRepoCreateRecord)
2323- e.POST("/xrpc/com.atproto.repo.deleteRecord", s.HandleComAtprotoRepoDeleteRecord)
2424- e.GET("/xrpc/com.atproto.repo.describe", s.HandleComAtprotoRepoDescribe)
2525- e.GET("/xrpc/com.atproto.repo.getRecord", s.HandleComAtprotoRepoGetRecord)
2626- e.GET("/xrpc/com.atproto.repo.listRecords", s.HandleComAtprotoRepoListRecords)
2727- e.POST("/xrpc/com.atproto.repo.putRecord", s.HandleComAtprotoRepoPutRecord)
2828- e.GET("/xrpc/com.atproto.server.getAccountsConfig", s.HandleComAtprotoServerGetAccountsConfig)
2929- e.POST("/xrpc/com.atproto.session.create", s.HandleComAtprotoSessionCreate)
3030- e.POST("/xrpc/com.atproto.session.delete", s.HandleComAtprotoSessionDelete)
3131- e.GET("/xrpc/com.atproto.session.get", s.HandleComAtprotoSessionGet)
3232- e.POST("/xrpc/com.atproto.session.refresh", s.HandleComAtprotoSessionRefresh)
3333- e.GET("/xrpc/com.atproto.sync.getRepo", s.HandleComAtprotoSyncGetRepo)
3434- e.GET("/xrpc/com.atproto.sync.getRoot", s.HandleComAtprotoSyncGetRoot)
3535- e.POST("/xrpc/com.atproto.sync.updateRepo", s.HandleComAtprotoSyncUpdateRepo)
1313+func (s *Server) RegisterHandlersAppBsky(e *echo.Echo) error {
1414+ e.POST("/xrpc/app.bsky.actor.createScene", s.HandleAppBskyActorCreateScene)
1515+ e.GET("/xrpc/app.bsky.actor.getProfile", s.HandleAppBskyActorGetProfile)
1616+ e.GET("/xrpc/app.bsky.actor.getSuggestions", s.HandleAppBskyActorGetSuggestions)
1717+ e.GET("/xrpc/app.bsky.actor.search", s.HandleAppBskyActorSearch)
1818+ e.GET("/xrpc/app.bsky.actor.searchTypeahead", s.HandleAppBskyActorSearchTypeahead)
1919+ e.POST("/xrpc/app.bsky.actor.updateProfile", s.HandleAppBskyActorUpdateProfile)
2020+ e.GET("/xrpc/app.bsky.feed.getAuthorFeed", s.HandleAppBskyFeedGetAuthorFeed)
2121+ e.GET("/xrpc/app.bsky.feed.getPostThread", s.HandleAppBskyFeedGetPostThread)
2222+ e.GET("/xrpc/app.bsky.feed.getRepostedBy", s.HandleAppBskyFeedGetRepostedBy)
2323+ e.GET("/xrpc/app.bsky.feed.getTimeline", s.HandleAppBskyFeedGetTimeline)
2424+ e.GET("/xrpc/app.bsky.feed.getVotes", s.HandleAppBskyFeedGetVotes)
2525+ e.POST("/xrpc/app.bsky.feed.setVote", s.HandleAppBskyFeedSetVote)
2626+ e.GET("/xrpc/app.bsky.graph.getAssertions", s.HandleAppBskyGraphGetAssertions)
2727+ e.GET("/xrpc/app.bsky.graph.getFollowers", s.HandleAppBskyGraphGetFollowers)
2828+ e.GET("/xrpc/app.bsky.graph.getFollows", s.HandleAppBskyGraphGetFollows)
2929+ e.GET("/xrpc/app.bsky.graph.getMembers", s.HandleAppBskyGraphGetMembers)
3030+ e.GET("/xrpc/app.bsky.graph.getMemberships", s.HandleAppBskyGraphGetMemberships)
3131+ e.GET("/xrpc/app.bsky.notification.getCount", s.HandleAppBskyNotificationGetCount)
3232+ e.GET("/xrpc/app.bsky.notification.list", s.HandleAppBskyNotificationList)
3333+ e.POST("/xrpc/app.bsky.notification.updateSeen", s.HandleAppBskyNotificationUpdateSeen)
3634 return nil
3735}
38363939-func (s *Server) HandleComAtprotoAccountCreate(c echo.Context) error {
4040- ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleComAtprotoAccountCreate")
3737+func (s *Server) HandleAppBskyActorCreateScene(c echo.Context) error {
3838+ ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleAppBskyActorCreateScene")
4139 defer span.End()
42404343- var body comatprototypes.AccountCreate_Input
4141+ var body appbskytypes.ActorCreateScene_Input
4442 if err := c.Bind(&body); err != nil {
4543 return err
4644 }
4747- var out *comatprototypes.AccountCreate_Output
4545+ var out *appbskytypes.ActorCreateScene_Output
4846 var handleErr error
4949- // func (s *Server) handleComAtprotoAccountCreate(ctx context.Context,body comatprototypes.AccountCreate_Input) (*comatprototypes.AccountCreate_Output, error)
5050- out, handleErr = s.handleComAtprotoAccountCreate(ctx, &body)
4747+ // func (s *Server) handleAppBskyActorCreateScene(ctx context.Context,body appbskytypes.ActorCreateScene_Input) (*appbskytypes.ActorCreateScene_Output, error)
4848+ out, handleErr = s.handleAppBskyActorCreateScene(ctx, &body)
5149 if handleErr != nil {
5250 return handleErr
5351 }
5452 return c.JSON(200, out)
5553}
56545757-func (s *Server) HandleComAtprotoAccountCreateInviteCode(c echo.Context) error {
5858- ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleComAtprotoAccountCreateInviteCode")
5555+func (s *Server) HandleAppBskyActorGetProfile(c echo.Context) error {
5656+ ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleAppBskyActorGetProfile")
5957 defer span.End()
6060-6161- var body comatprototypes.AccountCreateInviteCode_Input
6262- if err := c.Bind(&body); err != nil {
6363- return err
6464- }
6565- var out *comatprototypes.AccountCreateInviteCode_Output
5858+ actor := c.QueryParam("actor")
5959+ var out *appbskytypes.ActorGetProfile_Output
6660 var handleErr error
6767- // func (s *Server) handleComAtprotoAccountCreateInviteCode(ctx context.Context,body comatprototypes.AccountCreateInviteCode_Input) (*comatprototypes.AccountCreateInviteCode_Output, error)
6868- out, handleErr = s.handleComAtprotoAccountCreateInviteCode(ctx, &body)
6161+ // func (s *Server) handleAppBskyActorGetProfile(ctx context.Context,actor string) (*appbskytypes.ActorGetProfile_Output, error)
6262+ out, handleErr = s.handleAppBskyActorGetProfile(ctx, actor)
6963 if handleErr != nil {
7064 return handleErr
7165 }
7266 return c.JSON(200, out)
7367}
74687575-func (s *Server) HandleComAtprotoAccountDelete(c echo.Context) error {
7676- ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleComAtprotoAccountDelete")
6969+func (s *Server) HandleAppBskyActorGetSuggestions(c echo.Context) error {
7070+ ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleAppBskyActorGetSuggestions")
7771 defer span.End()
7878- var handleErr error
7979- // func (s *Server) handleComAtprotoAccountDelete(ctx context.Context) error
8080- handleErr = s.handleComAtprotoAccountDelete(ctx)
8181- if handleErr != nil {
8282- return handleErr
7272+ cursor := c.QueryParam("cursor")
7373+7474+ var limit int
7575+ if p := c.QueryParam("limit"); p != "" {
7676+ var err error
7777+ limit, err = strconv.Atoi(p)
7878+ if err != nil {
7979+ return err
8080+ }
8181+ } else {
8282+ limit = 50
8383 }
8484- return nil
8585-}
8686-8787-func (s *Server) HandleComAtprotoAccountGet(c echo.Context) error {
8888- ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleComAtprotoAccountGet")
8989- defer span.End()
8484+ var out *appbskytypes.ActorGetSuggestions_Output
9085 var handleErr error
9191- // func (s *Server) handleComAtprotoAccountGet(ctx context.Context) error
9292- handleErr = s.handleComAtprotoAccountGet(ctx)
8686+ // func (s *Server) handleAppBskyActorGetSuggestions(ctx context.Context,cursor string,limit int) (*appbskytypes.ActorGetSuggestions_Output, error)
8787+ out, handleErr = s.handleAppBskyActorGetSuggestions(ctx, cursor, limit)
9388 if handleErr != nil {
9489 return handleErr
9590 }
9696- return nil
9191+ return c.JSON(200, out)
9792}
98939999-func (s *Server) HandleComAtprotoAccountRequestPasswordReset(c echo.Context) error {
100100- ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleComAtprotoAccountRequestPasswordReset")
9494+func (s *Server) HandleAppBskyActorSearch(c echo.Context) error {
9595+ ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleAppBskyActorSearch")
10196 defer span.End()
9797+ before := c.QueryParam("before")
10298103103- var body comatprototypes.AccountRequestPasswordReset_Input
104104- if err := c.Bind(&body); err != nil {
105105- return err
9999+ var limit int
100100+ if p := c.QueryParam("limit"); p != "" {
101101+ var err error
102102+ limit, err = strconv.Atoi(p)
103103+ if err != nil {
104104+ return err
105105+ }
106106+ } else {
107107+ limit = 50
106108 }
109109+ term := c.QueryParam("term")
110110+ var out *appbskytypes.ActorSearch_Output
107111 var handleErr error
108108- // func (s *Server) handleComAtprotoAccountRequestPasswordReset(ctx context.Context,body comatprototypes.AccountRequestPasswordReset_Input) error
109109- handleErr = s.handleComAtprotoAccountRequestPasswordReset(ctx, &body)
112112+ // func (s *Server) handleAppBskyActorSearch(ctx context.Context,before string,limit int,term string) (*appbskytypes.ActorSearch_Output, error)
113113+ out, handleErr = s.handleAppBskyActorSearch(ctx, before, limit, term)
110114 if handleErr != nil {
111115 return handleErr
112116 }
113113- return nil
117117+ return c.JSON(200, out)
114118}
115119116116-func (s *Server) HandleComAtprotoAccountResetPassword(c echo.Context) error {
117117- ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleComAtprotoAccountResetPassword")
120120+func (s *Server) HandleAppBskyActorSearchTypeahead(c echo.Context) error {
121121+ ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleAppBskyActorSearchTypeahead")
118122 defer span.End()
119123120120- var body comatprototypes.AccountResetPassword_Input
121121- if err := c.Bind(&body); err != nil {
122122- return err
124124+ var limit int
125125+ if p := c.QueryParam("limit"); p != "" {
126126+ var err error
127127+ limit, err = strconv.Atoi(p)
128128+ if err != nil {
129129+ return err
130130+ }
131131+ } else {
132132+ limit = 50
123133 }
124124- var handleErr error
125125- // func (s *Server) handleComAtprotoAccountResetPassword(ctx context.Context,body comatprototypes.AccountResetPassword_Input) error
126126- handleErr = s.handleComAtprotoAccountResetPassword(ctx, &body)
127127- if handleErr != nil {
128128- return handleErr
129129- }
130130- return nil
131131-}
132132-133133-func (s *Server) HandleComAtprotoHandleResolve(c echo.Context) error {
134134- ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleComAtprotoHandleResolve")
135135- defer span.End()
136136- handle := c.QueryParam("handle")
137137- var out *comatprototypes.HandleResolve_Output
134134+ term := c.QueryParam("term")
135135+ var out *appbskytypes.ActorSearchTypeahead_Output
138136 var handleErr error
139139- // func (s *Server) handleComAtprotoHandleResolve(ctx context.Context,handle string) (*comatprototypes.HandleResolve_Output, error)
140140- out, handleErr = s.handleComAtprotoHandleResolve(ctx, handle)
137137+ // func (s *Server) handleAppBskyActorSearchTypeahead(ctx context.Context,limit int,term string) (*appbskytypes.ActorSearchTypeahead_Output, error)
138138+ out, handleErr = s.handleAppBskyActorSearchTypeahead(ctx, limit, term)
141139 if handleErr != nil {
142140 return handleErr
143141 }
144142 return c.JSON(200, out)
145143}
146144147147-func (s *Server) HandleComAtprotoRepoBatchWrite(c echo.Context) error {
148148- ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleComAtprotoRepoBatchWrite")
145145+func (s *Server) HandleAppBskyActorUpdateProfile(c echo.Context) error {
146146+ ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleAppBskyActorUpdateProfile")
149147 defer span.End()
150148151151- var body comatprototypes.RepoBatchWrite_Input
149149+ var body appbskytypes.ActorUpdateProfile_Input
152150 if err := c.Bind(&body); err != nil {
153151 return err
154152 }
153153+ var out *appbskytypes.ActorUpdateProfile_Output
155154 var handleErr error
156156- // func (s *Server) handleComAtprotoRepoBatchWrite(ctx context.Context,body comatprototypes.RepoBatchWrite_Input) error
157157- handleErr = s.handleComAtprotoRepoBatchWrite(ctx, &body)
155155+ // func (s *Server) handleAppBskyActorUpdateProfile(ctx context.Context,body appbskytypes.ActorUpdateProfile_Input) (*appbskytypes.ActorUpdateProfile_Output, error)
156156+ out, handleErr = s.handleAppBskyActorUpdateProfile(ctx, &body)
158157 if handleErr != nil {
159158 return handleErr
160159 }
161161- return nil
160160+ return c.JSON(200, out)
162161}
163162164164-func (s *Server) HandleComAtprotoRepoCreateRecord(c echo.Context) error {
165165- ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleComAtprotoRepoCreateRecord")
163163+func (s *Server) HandleAppBskyFeedGetAuthorFeed(c echo.Context) error {
164164+ ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleAppBskyFeedGetAuthorFeed")
166165 defer span.End()
166166+ author := c.QueryParam("author")
167167+ before := c.QueryParam("before")
167168168168- var body comatprototypes.RepoCreateRecord_Input
169169- if err := c.Bind(&body); err != nil {
170170- return err
169169+ var limit int
170170+ if p := c.QueryParam("limit"); p != "" {
171171+ var err error
172172+ limit, err = strconv.Atoi(p)
173173+ if err != nil {
174174+ return err
175175+ }
176176+ } else {
177177+ limit = 50
171178 }
172172- var out *comatprototypes.RepoCreateRecord_Output
179179+ var out *appbskytypes.FeedGetAuthorFeed_Output
173180 var handleErr error
174174- // func (s *Server) handleComAtprotoRepoCreateRecord(ctx context.Context,body comatprototypes.RepoCreateRecord_Input) (*comatprototypes.RepoCreateRecord_Output, error)
175175- out, handleErr = s.handleComAtprotoRepoCreateRecord(ctx, &body)
181181+ // func (s *Server) handleAppBskyFeedGetAuthorFeed(ctx context.Context,author string,before string,limit int) (*appbskytypes.FeedGetAuthorFeed_Output, error)
182182+ out, handleErr = s.handleAppBskyFeedGetAuthorFeed(ctx, author, before, limit)
176183 if handleErr != nil {
177184 return handleErr
178185 }
179186 return c.JSON(200, out)
180187}
181188182182-func (s *Server) HandleComAtprotoRepoDeleteRecord(c echo.Context) error {
183183- ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleComAtprotoRepoDeleteRecord")
189189+func (s *Server) HandleAppBskyFeedGetPostThread(c echo.Context) error {
190190+ ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleAppBskyFeedGetPostThread")
184191 defer span.End()
185192186186- var body comatprototypes.RepoDeleteRecord_Input
187187- if err := c.Bind(&body); err != nil {
188188- return err
193193+ var depth *int
194194+ if p := c.QueryParam("depth"); p != "" {
195195+ depth_val, err := strconv.Atoi(p)
196196+ if err != nil {
197197+ return err
198198+ }
199199+ depth = &depth_val
189200 }
201201+ uri := c.QueryParam("uri")
202202+ var out *appbskytypes.FeedGetPostThread_Output
190203 var handleErr error
191191- // func (s *Server) handleComAtprotoRepoDeleteRecord(ctx context.Context,body comatprototypes.RepoDeleteRecord_Input) error
192192- handleErr = s.handleComAtprotoRepoDeleteRecord(ctx, &body)
204204+ // func (s *Server) handleAppBskyFeedGetPostThread(ctx context.Context,depth *int,uri string) (*appbskytypes.FeedGetPostThread_Output, error)
205205+ out, handleErr = s.handleAppBskyFeedGetPostThread(ctx, depth, uri)
193206 if handleErr != nil {
194207 return handleErr
195208 }
196196- return nil
209209+ return c.JSON(200, out)
197210}
198211199199-func (s *Server) HandleComAtprotoRepoDescribe(c echo.Context) error {
200200- ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleComAtprotoRepoDescribe")
212212+func (s *Server) HandleAppBskyFeedGetRepostedBy(c echo.Context) error {
213213+ ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleAppBskyFeedGetRepostedBy")
201214 defer span.End()
202202- user := c.QueryParam("user")
203203- var out *comatprototypes.RepoDescribe_Output
215215+ before := c.QueryParam("before")
216216+ cid := c.QueryParam("cid")
217217+218218+ var limit int
219219+ if p := c.QueryParam("limit"); p != "" {
220220+ var err error
221221+ limit, err = strconv.Atoi(p)
222222+ if err != nil {
223223+ return err
224224+ }
225225+ } else {
226226+ limit = 50
227227+ }
228228+ uri := c.QueryParam("uri")
229229+ var out *appbskytypes.FeedGetRepostedBy_Output
204230 var handleErr error
205205- // func (s *Server) handleComAtprotoRepoDescribe(ctx context.Context,user string) (*comatprototypes.RepoDescribe_Output, error)
206206- out, handleErr = s.handleComAtprotoRepoDescribe(ctx, user)
231231+ // func (s *Server) handleAppBskyFeedGetRepostedBy(ctx context.Context,before string,cid string,limit int,uri string) (*appbskytypes.FeedGetRepostedBy_Output, error)
232232+ out, handleErr = s.handleAppBskyFeedGetRepostedBy(ctx, before, cid, limit, uri)
207233 if handleErr != nil {
208234 return handleErr
209235 }
210236 return c.JSON(200, out)
211237}
212238213213-func (s *Server) HandleComAtprotoRepoGetRecord(c echo.Context) error {
214214- ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleComAtprotoRepoGetRecord")
239239+func (s *Server) HandleAppBskyFeedGetTimeline(c echo.Context) error {
240240+ ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleAppBskyFeedGetTimeline")
215241 defer span.End()
216216- cid := c.QueryParam("cid")
217217- collection := c.QueryParam("collection")
218218- rkey := c.QueryParam("rkey")
219219- user := c.QueryParam("user")
220220- var out *comatprototypes.RepoGetRecord_Output
242242+ algorithm := c.QueryParam("algorithm")
243243+ before := c.QueryParam("before")
244244+245245+ var limit int
246246+ if p := c.QueryParam("limit"); p != "" {
247247+ var err error
248248+ limit, err = strconv.Atoi(p)
249249+ if err != nil {
250250+ return err
251251+ }
252252+ } else {
253253+ limit = 50
254254+ }
255255+ var out *appbskytypes.FeedGetTimeline_Output
221256 var handleErr error
222222- // func (s *Server) handleComAtprotoRepoGetRecord(ctx context.Context,cid string,collection string,rkey string,user string) (*comatprototypes.RepoGetRecord_Output, error)
223223- out, handleErr = s.handleComAtprotoRepoGetRecord(ctx, cid, collection, rkey, user)
257257+ // func (s *Server) handleAppBskyFeedGetTimeline(ctx context.Context,algorithm string,before string,limit int) (*appbskytypes.FeedGetTimeline_Output, error)
258258+ out, handleErr = s.handleAppBskyFeedGetTimeline(ctx, algorithm, before, limit)
224259 if handleErr != nil {
225260 return handleErr
226261 }
227262 return c.JSON(200, out)
228263}
229264230230-func (s *Server) HandleComAtprotoRepoListRecords(c echo.Context) error {
231231- ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleComAtprotoRepoListRecords")
265265+func (s *Server) HandleAppBskyFeedGetVotes(c echo.Context) error {
266266+ ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleAppBskyFeedGetVotes")
232267 defer span.End()
233233- after := c.QueryParam("after")
234268 before := c.QueryParam("before")
235235- collection := c.QueryParam("collection")
269269+ cid := c.QueryParam("cid")
270270+ direction := c.QueryParam("direction")
236271237237- limit, err := strconv.Atoi(c.QueryParam("limit"))
238238- if err != nil {
239239- return err
272272+ var limit int
273273+ if p := c.QueryParam("limit"); p != "" {
274274+ var err error
275275+ limit, err = strconv.Atoi(p)
276276+ if err != nil {
277277+ return err
278278+ }
279279+ } else {
280280+ limit = 50
240281 }
241241- var out *comatprototypes.RepoListRecords_Output
282282+ uri := c.QueryParam("uri")
283283+ var out *appbskytypes.FeedGetVotes_Output
242284 var handleErr error
243243- // func (s *Server) handleComAtprotoRepoListRecords(ctx context.Context,after string,before string,collection string,limit int) (*comatprototypes.RepoListRecords_Output, error)
244244- out, handleErr = s.handleComAtprotoRepoListRecords(ctx, after, before, collection, limit)
285285+ // func (s *Server) handleAppBskyFeedGetVotes(ctx context.Context,before string,cid string,direction string,limit int,uri string) (*appbskytypes.FeedGetVotes_Output, error)
286286+ out, handleErr = s.handleAppBskyFeedGetVotes(ctx, before, cid, direction, limit, uri)
245287 if handleErr != nil {
246288 return handleErr
247289 }
248290 return c.JSON(200, out)
249291}
250292251251-func (s *Server) HandleComAtprotoRepoPutRecord(c echo.Context) error {
252252- ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleComAtprotoRepoPutRecord")
293293+func (s *Server) HandleAppBskyFeedSetVote(c echo.Context) error {
294294+ ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleAppBskyFeedSetVote")
253295 defer span.End()
254296255255- var body comatprototypes.RepoPutRecord_Input
297297+ var body appbskytypes.FeedSetVote_Input
256298 if err := c.Bind(&body); err != nil {
257299 return err
258300 }
259259- var out *comatprototypes.RepoPutRecord_Output
301301+ var out *appbskytypes.FeedSetVote_Output
260302 var handleErr error
261261- // func (s *Server) handleComAtprotoRepoPutRecord(ctx context.Context,body comatprototypes.RepoPutRecord_Input) (*comatprototypes.RepoPutRecord_Output, error)
262262- out, handleErr = s.handleComAtprotoRepoPutRecord(ctx, &body)
303303+ // func (s *Server) handleAppBskyFeedSetVote(ctx context.Context,body appbskytypes.FeedSetVote_Input) (*appbskytypes.FeedSetVote_Output, error)
304304+ out, handleErr = s.handleAppBskyFeedSetVote(ctx, &body)
263305 if handleErr != nil {
264306 return handleErr
265307 }
266308 return c.JSON(200, out)
267309}
268310269269-func (s *Server) HandleComAtprotoServerGetAccountsConfig(c echo.Context) error {
270270- ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleComAtprotoServerGetAccountsConfig")
311311+func (s *Server) HandleAppBskyGraphGetAssertions(c echo.Context) error {
312312+ ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleAppBskyGraphGetAssertions")
271313 defer span.End()
272272- var out *comatprototypes.ServerGetAccountsConfig_Output
314314+ assertion := c.QueryParam("assertion")
315315+ author := c.QueryParam("author")
316316+ before := c.QueryParam("before")
317317+ var out *appbskytypes.GraphGetAssertions_Output
273318 var handleErr error
274274- // func (s *Server) handleComAtprotoServerGetAccountsConfig(ctx context.Context) (*comatprototypes.ServerGetAccountsConfig_Output, error)
275275- out, handleErr = s.handleComAtprotoServerGetAccountsConfig(ctx)
319319+ // func (s *Server) handleAppBskyGraphGetAssertions(ctx context.Context,assertion string,author string,before string) (*appbskytypes.GraphGetAssertions_Output, error)
320320+ out, handleErr = s.handleAppBskyGraphGetAssertions(ctx, assertion, author, before)
276321 if handleErr != nil {
277322 return handleErr
278323 }
279324 return c.JSON(200, out)
280325}
281326282282-func (s *Server) HandleComAtprotoSessionCreate(c echo.Context) error {
283283- ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleComAtprotoSessionCreate")
327327+func (s *Server) HandleAppBskyGraphGetFollowers(c echo.Context) error {
328328+ ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleAppBskyGraphGetFollowers")
284329 defer span.End()
330330+ before := c.QueryParam("before")
285331286286- var body comatprototypes.SessionCreate_Input
287287- if err := c.Bind(&body); err != nil {
288288- return err
332332+ var limit int
333333+ if p := c.QueryParam("limit"); p != "" {
334334+ var err error
335335+ limit, err = strconv.Atoi(p)
336336+ if err != nil {
337337+ return err
338338+ }
339339+ } else {
340340+ limit = 50
289341 }
290290- var out *comatprototypes.SessionCreate_Output
342342+ user := c.QueryParam("user")
343343+ var out *appbskytypes.GraphGetFollowers_Output
291344 var handleErr error
292292- // func (s *Server) handleComAtprotoSessionCreate(ctx context.Context,body comatprototypes.SessionCreate_Input) (*comatprototypes.SessionCreate_Output, error)
293293- out, handleErr = s.handleComAtprotoSessionCreate(ctx, &body)
345345+ // func (s *Server) handleAppBskyGraphGetFollowers(ctx context.Context,before string,limit int,user string) (*appbskytypes.GraphGetFollowers_Output, error)
346346+ out, handleErr = s.handleAppBskyGraphGetFollowers(ctx, before, limit, user)
294347 if handleErr != nil {
295348 return handleErr
296349 }
297350 return c.JSON(200, out)
298351}
299352300300-func (s *Server) HandleComAtprotoSessionDelete(c echo.Context) error {
301301- ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleComAtprotoSessionDelete")
353353+func (s *Server) HandleAppBskyGraphGetFollows(c echo.Context) error {
354354+ ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleAppBskyGraphGetFollows")
302355 defer span.End()
356356+ before := c.QueryParam("before")
357357+358358+ var limit int
359359+ if p := c.QueryParam("limit"); p != "" {
360360+ var err error
361361+ limit, err = strconv.Atoi(p)
362362+ if err != nil {
363363+ return err
364364+ }
365365+ } else {
366366+ limit = 50
367367+ }
368368+ user := c.QueryParam("user")
369369+ var out *appbskytypes.GraphGetFollows_Output
303370 var handleErr error
304304- // func (s *Server) handleComAtprotoSessionDelete(ctx context.Context) error
305305- handleErr = s.handleComAtprotoSessionDelete(ctx)
371371+ // func (s *Server) handleAppBskyGraphGetFollows(ctx context.Context,before string,limit int,user string) (*appbskytypes.GraphGetFollows_Output, error)
372372+ out, handleErr = s.handleAppBskyGraphGetFollows(ctx, before, limit, user)
306373 if handleErr != nil {
307374 return handleErr
308375 }
309309- return nil
376376+ return c.JSON(200, out)
310377}
311378312312-func (s *Server) HandleComAtprotoSessionGet(c echo.Context) error {
313313- ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleComAtprotoSessionGet")
379379+func (s *Server) HandleAppBskyGraphGetMembers(c echo.Context) error {
380380+ ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleAppBskyGraphGetMembers")
314381 defer span.End()
315315- var out *comatprototypes.SessionGet_Output
382382+ actor := c.QueryParam("actor")
383383+ before := c.QueryParam("before")
384384+385385+ var limit int
386386+ if p := c.QueryParam("limit"); p != "" {
387387+ var err error
388388+ limit, err = strconv.Atoi(p)
389389+ if err != nil {
390390+ return err
391391+ }
392392+ } else {
393393+ limit = 50
394394+ }
395395+ var out *appbskytypes.GraphGetMembers_Output
316396 var handleErr error
317317- // func (s *Server) handleComAtprotoSessionGet(ctx context.Context) (*comatprototypes.SessionGet_Output, error)
318318- out, handleErr = s.handleComAtprotoSessionGet(ctx)
397397+ // func (s *Server) handleAppBskyGraphGetMembers(ctx context.Context,actor string,before string,limit int) (*appbskytypes.GraphGetMembers_Output, error)
398398+ out, handleErr = s.handleAppBskyGraphGetMembers(ctx, actor, before, limit)
319399 if handleErr != nil {
320400 return handleErr
321401 }
322402 return c.JSON(200, out)
323403}
324404325325-func (s *Server) HandleComAtprotoSessionRefresh(c echo.Context) error {
326326- ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleComAtprotoSessionRefresh")
405405+func (s *Server) HandleAppBskyGraphGetMemberships(c echo.Context) error {
406406+ ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleAppBskyGraphGetMemberships")
327407 defer span.End()
328328- var out *comatprototypes.SessionRefresh_Output
408408+ actor := c.QueryParam("actor")
409409+ before := c.QueryParam("before")
410410+411411+ var limit int
412412+ if p := c.QueryParam("limit"); p != "" {
413413+ var err error
414414+ limit, err = strconv.Atoi(p)
415415+ if err != nil {
416416+ return err
417417+ }
418418+ } else {
419419+ limit = 50
420420+ }
421421+ var out *appbskytypes.GraphGetMemberships_Output
329422 var handleErr error
330330- // func (s *Server) handleComAtprotoSessionRefresh(ctx context.Context) (*comatprototypes.SessionRefresh_Output, error)
331331- out, handleErr = s.handleComAtprotoSessionRefresh(ctx)
423423+ // func (s *Server) handleAppBskyGraphGetMemberships(ctx context.Context,actor string,before string,limit int) (*appbskytypes.GraphGetMemberships_Output, error)
424424+ out, handleErr = s.handleAppBskyGraphGetMemberships(ctx, actor, before, limit)
332425 if handleErr != nil {
333426 return handleErr
334427 }
335428 return c.JSON(200, out)
336429}
337430338338-func (s *Server) HandleComAtprotoSyncGetRepo(c echo.Context) error {
339339- ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleComAtprotoSyncGetRepo")
431431+func (s *Server) HandleAppBskyNotificationGetCount(c echo.Context) error {
432432+ ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleAppBskyNotificationGetCount")
340433 defer span.End()
341341- did := c.QueryParam("did")
342342- from := c.QueryParam("from")
343343- var out io.Reader
434434+ var out *appbskytypes.NotificationGetCount_Output
344435 var handleErr error
345345- // func (s *Server) handleComAtprotoSyncGetRepo(ctx context.Context,did string,from string) (io.Reader, error)
346346- out, handleErr = s.handleComAtprotoSyncGetRepo(ctx, did, from)
436436+ // func (s *Server) handleAppBskyNotificationGetCount(ctx context.Context) (*appbskytypes.NotificationGetCount_Output, error)
437437+ out, handleErr = s.handleAppBskyNotificationGetCount(ctx)
347438 if handleErr != nil {
348439 return handleErr
349440 }
350441 return c.JSON(200, out)
351442}
352443353353-func (s *Server) HandleComAtprotoSyncGetRoot(c echo.Context) error {
354354- ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleComAtprotoSyncGetRoot")
444444+func (s *Server) HandleAppBskyNotificationList(c echo.Context) error {
445445+ ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleAppBskyNotificationList")
355446 defer span.End()
356356- did := c.QueryParam("did")
357357- var out *comatprototypes.SyncGetRoot_Output
447447+ before := c.QueryParam("before")
448448+449449+ var limit int
450450+ if p := c.QueryParam("limit"); p != "" {
451451+ var err error
452452+ limit, err = strconv.Atoi(p)
453453+ if err != nil {
454454+ return err
455455+ }
456456+ } else {
457457+ limit = 50
458458+ }
459459+ var out *appbskytypes.NotificationList_Output
358460 var handleErr error
359359- // func (s *Server) handleComAtprotoSyncGetRoot(ctx context.Context,did string) (*comatprototypes.SyncGetRoot_Output, error)
360360- out, handleErr = s.handleComAtprotoSyncGetRoot(ctx, did)
461461+ // func (s *Server) handleAppBskyNotificationList(ctx context.Context,before string,limit int) (*appbskytypes.NotificationList_Output, error)
462462+ out, handleErr = s.handleAppBskyNotificationList(ctx, before, limit)
361463 if handleErr != nil {
362464 return handleErr
363465 }
364466 return c.JSON(200, out)
365467}
366468367367-func (s *Server) HandleComAtprotoSyncUpdateRepo(c echo.Context) error {
368368- ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleComAtprotoSyncUpdateRepo")
469469+func (s *Server) HandleAppBskyNotificationUpdateSeen(c echo.Context) error {
470470+ ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleAppBskyNotificationUpdateSeen")
369471 defer span.End()
370370- body := c.Request().Body
472472+473473+ var body appbskytypes.NotificationUpdateSeen_Input
474474+ if err := c.Bind(&body); err != nil {
475475+ return err
476476+ }
371477 var handleErr error
372372- // func (s *Server) handleComAtprotoSyncUpdateRepo(ctx context.Context,r io.Reader) error
373373- handleErr = s.handleComAtprotoSyncUpdateRepo(ctx, body)
478478+ // func (s *Server) handleAppBskyNotificationUpdateSeen(ctx context.Context,body appbskytypes.NotificationUpdateSeen_Input) error
479479+ handleErr = s.handleAppBskyNotificationUpdateSeen(ctx, &body)
374480 if handleErr != nil {
375481 return handleErr
376482 }
377483 return nil
378484}
379485380380-func (s *Server) RegisterHandlersAppBsky(e *echo.Echo) error {
381381- e.POST("/xrpc/app.bsky.actor.createScene", s.HandleAppBskyActorCreateScene)
382382- e.GET("/xrpc/app.bsky.actor.getProfile", s.HandleAppBskyActorGetProfile)
383383- e.GET("/xrpc/app.bsky.actor.getSuggestions", s.HandleAppBskyActorGetSuggestions)
384384- e.GET("/xrpc/app.bsky.actor.search", s.HandleAppBskyActorSearch)
385385- e.GET("/xrpc/app.bsky.actor.searchTypeahead", s.HandleAppBskyActorSearchTypeahead)
386386- e.POST("/xrpc/app.bsky.actor.updateProfile", s.HandleAppBskyActorUpdateProfile)
387387- e.GET("/xrpc/app.bsky.feed.getAuthorFeed", s.HandleAppBskyFeedGetAuthorFeed)
388388- e.GET("/xrpc/app.bsky.feed.getPostThread", s.HandleAppBskyFeedGetPostThread)
389389- e.GET("/xrpc/app.bsky.feed.getRepostedBy", s.HandleAppBskyFeedGetRepostedBy)
390390- e.GET("/xrpc/app.bsky.feed.getTimeline", s.HandleAppBskyFeedGetTimeline)
391391- e.GET("/xrpc/app.bsky.feed.getVotes", s.HandleAppBskyFeedGetVotes)
392392- e.POST("/xrpc/app.bsky.feed.setVote", s.HandleAppBskyFeedSetVote)
393393- e.GET("/xrpc/app.bsky.graph.getAssertions", s.HandleAppBskyGraphGetAssertions)
394394- e.GET("/xrpc/app.bsky.graph.getFollowers", s.HandleAppBskyGraphGetFollowers)
395395- e.GET("/xrpc/app.bsky.graph.getFollows", s.HandleAppBskyGraphGetFollows)
396396- e.GET("/xrpc/app.bsky.graph.getMembers", s.HandleAppBskyGraphGetMembers)
397397- e.GET("/xrpc/app.bsky.graph.getMemberships", s.HandleAppBskyGraphGetMemberships)
398398- e.GET("/xrpc/app.bsky.notification.getCount", s.HandleAppBskyNotificationGetCount)
399399- e.GET("/xrpc/app.bsky.notification.list", s.HandleAppBskyNotificationList)
400400- e.POST("/xrpc/app.bsky.notification.updateSeen", s.HandleAppBskyNotificationUpdateSeen)
486486+func (s *Server) RegisterHandlersComAtproto(e *echo.Echo) error {
487487+ e.POST("/xrpc/com.atproto.account.create", s.HandleComAtprotoAccountCreate)
488488+ e.POST("/xrpc/com.atproto.account.createInviteCode", s.HandleComAtprotoAccountCreateInviteCode)
489489+ e.POST("/xrpc/com.atproto.account.delete", s.HandleComAtprotoAccountDelete)
490490+ e.GET("/xrpc/com.atproto.account.get", s.HandleComAtprotoAccountGet)
491491+ e.POST("/xrpc/com.atproto.account.requestPasswordReset", s.HandleComAtprotoAccountRequestPasswordReset)
492492+ e.POST("/xrpc/com.atproto.account.resetPassword", s.HandleComAtprotoAccountResetPassword)
493493+ e.GET("/xrpc/com.atproto.handle.resolve", s.HandleComAtprotoHandleResolve)
494494+ e.POST("/xrpc/com.atproto.repo.batchWrite", s.HandleComAtprotoRepoBatchWrite)
495495+ e.POST("/xrpc/com.atproto.repo.createRecord", s.HandleComAtprotoRepoCreateRecord)
496496+ e.POST("/xrpc/com.atproto.repo.deleteRecord", s.HandleComAtprotoRepoDeleteRecord)
497497+ e.GET("/xrpc/com.atproto.repo.describe", s.HandleComAtprotoRepoDescribe)
498498+ e.GET("/xrpc/com.atproto.repo.getRecord", s.HandleComAtprotoRepoGetRecord)
499499+ e.GET("/xrpc/com.atproto.repo.listRecords", s.HandleComAtprotoRepoListRecords)
500500+ e.POST("/xrpc/com.atproto.repo.putRecord", s.HandleComAtprotoRepoPutRecord)
501501+ e.GET("/xrpc/com.atproto.server.getAccountsConfig", s.HandleComAtprotoServerGetAccountsConfig)
502502+ e.POST("/xrpc/com.atproto.session.create", s.HandleComAtprotoSessionCreate)
503503+ e.POST("/xrpc/com.atproto.session.delete", s.HandleComAtprotoSessionDelete)
504504+ e.GET("/xrpc/com.atproto.session.get", s.HandleComAtprotoSessionGet)
505505+ e.POST("/xrpc/com.atproto.session.refresh", s.HandleComAtprotoSessionRefresh)
506506+ e.GET("/xrpc/com.atproto.sync.getRepo", s.HandleComAtprotoSyncGetRepo)
507507+ e.GET("/xrpc/com.atproto.sync.getRoot", s.HandleComAtprotoSyncGetRoot)
508508+ e.POST("/xrpc/com.atproto.sync.updateRepo", s.HandleComAtprotoSyncUpdateRepo)
401509 return nil
402510}
403511404404-func (s *Server) HandleAppBskyActorCreateScene(c echo.Context) error {
405405- ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleAppBskyActorCreateScene")
512512+func (s *Server) HandleComAtprotoAccountCreate(c echo.Context) error {
513513+ ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleComAtprotoAccountCreate")
406514 defer span.End()
407515408408- var body appbskytypes.ActorCreateScene_Input
516516+ var body comatprototypes.AccountCreate_Input
409517 if err := c.Bind(&body); err != nil {
410518 return err
411519 }
412412- var out *appbskytypes.ActorCreateScene_Output
520520+ var out *comatprototypes.AccountCreate_Output
413521 var handleErr error
414414- // func (s *Server) handleAppBskyActorCreateScene(ctx context.Context,body appbskytypes.ActorCreateScene_Input) (*appbskytypes.ActorCreateScene_Output, error)
415415- out, handleErr = s.handleAppBskyActorCreateScene(ctx, &body)
522522+ // func (s *Server) handleComAtprotoAccountCreate(ctx context.Context,body comatprototypes.AccountCreate_Input) (*comatprototypes.AccountCreate_Output, error)
523523+ out, handleErr = s.handleComAtprotoAccountCreate(ctx, &body)
416524 if handleErr != nil {
417525 return handleErr
418526 }
419527 return c.JSON(200, out)
420528}
421529422422-func (s *Server) HandleAppBskyActorGetProfile(c echo.Context) error {
423423- ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleAppBskyActorGetProfile")
530530+func (s *Server) HandleComAtprotoAccountCreateInviteCode(c echo.Context) error {
531531+ ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleComAtprotoAccountCreateInviteCode")
424532 defer span.End()
425425- actor := c.QueryParam("actor")
426426- var out *appbskytypes.ActorGetProfile_Output
533533+534534+ var body comatprototypes.AccountCreateInviteCode_Input
535535+ if err := c.Bind(&body); err != nil {
536536+ return err
537537+ }
538538+ var out *comatprototypes.AccountCreateInviteCode_Output
427539 var handleErr error
428428- // func (s *Server) handleAppBskyActorGetProfile(ctx context.Context,actor string) (*appbskytypes.ActorGetProfile_Output, error)
429429- out, handleErr = s.handleAppBskyActorGetProfile(ctx, actor)
540540+ // func (s *Server) handleComAtprotoAccountCreateInviteCode(ctx context.Context,body comatprototypes.AccountCreateInviteCode_Input) (*comatprototypes.AccountCreateInviteCode_Output, error)
541541+ out, handleErr = s.handleComAtprotoAccountCreateInviteCode(ctx, &body)
430542 if handleErr != nil {
431543 return handleErr
432544 }
433545 return c.JSON(200, out)
434546}
435547436436-func (s *Server) HandleAppBskyActorGetSuggestions(c echo.Context) error {
437437- ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleAppBskyActorGetSuggestions")
548548+func (s *Server) HandleComAtprotoAccountDelete(c echo.Context) error {
549549+ ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleComAtprotoAccountDelete")
438550 defer span.End()
439439- cursor := c.QueryParam("cursor")
551551+ var handleErr error
552552+ // func (s *Server) handleComAtprotoAccountDelete(ctx context.Context) error
553553+ handleErr = s.handleComAtprotoAccountDelete(ctx)
554554+ if handleErr != nil {
555555+ return handleErr
556556+ }
557557+ return nil
558558+}
440559441441- limit, err := strconv.Atoi(c.QueryParam("limit"))
442442- if err != nil {
443443- return err
444444- }
445445- var out *appbskytypes.ActorGetSuggestions_Output
560560+func (s *Server) HandleComAtprotoAccountGet(c echo.Context) error {
561561+ ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleComAtprotoAccountGet")
562562+ defer span.End()
446563 var handleErr error
447447- // func (s *Server) handleAppBskyActorGetSuggestions(ctx context.Context,cursor string,limit int) (*appbskytypes.ActorGetSuggestions_Output, error)
448448- out, handleErr = s.handleAppBskyActorGetSuggestions(ctx, cursor, limit)
564564+ // func (s *Server) handleComAtprotoAccountGet(ctx context.Context) error
565565+ handleErr = s.handleComAtprotoAccountGet(ctx)
449566 if handleErr != nil {
450567 return handleErr
451568 }
452452- return c.JSON(200, out)
569569+ return nil
453570}
454571455455-func (s *Server) HandleAppBskyActorSearch(c echo.Context) error {
456456- ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleAppBskyActorSearch")
572572+func (s *Server) HandleComAtprotoAccountRequestPasswordReset(c echo.Context) error {
573573+ ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleComAtprotoAccountRequestPasswordReset")
457574 defer span.End()
458458- before := c.QueryParam("before")
459575460460- limit, err := strconv.Atoi(c.QueryParam("limit"))
461461- if err != nil {
576576+ var body comatprototypes.AccountRequestPasswordReset_Input
577577+ if err := c.Bind(&body); err != nil {
462578 return err
463579 }
464464- term := c.QueryParam("term")
465465- var out *appbskytypes.ActorSearch_Output
466580 var handleErr error
467467- // func (s *Server) handleAppBskyActorSearch(ctx context.Context,before string,limit int,term string) (*appbskytypes.ActorSearch_Output, error)
468468- out, handleErr = s.handleAppBskyActorSearch(ctx, before, limit, term)
581581+ // func (s *Server) handleComAtprotoAccountRequestPasswordReset(ctx context.Context,body comatprototypes.AccountRequestPasswordReset_Input) error
582582+ handleErr = s.handleComAtprotoAccountRequestPasswordReset(ctx, &body)
469583 if handleErr != nil {
470584 return handleErr
471585 }
472472- return c.JSON(200, out)
586586+ return nil
473587}
474588475475-func (s *Server) HandleAppBskyActorSearchTypeahead(c echo.Context) error {
476476- ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleAppBskyActorSearchTypeahead")
589589+func (s *Server) HandleComAtprotoAccountResetPassword(c echo.Context) error {
590590+ ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleComAtprotoAccountResetPassword")
477591 defer span.End()
478592479479- limit, err := strconv.Atoi(c.QueryParam("limit"))
480480- if err != nil {
593593+ var body comatprototypes.AccountResetPassword_Input
594594+ if err := c.Bind(&body); err != nil {
481595 return err
482596 }
483483- term := c.QueryParam("term")
484484- var out *appbskytypes.ActorSearchTypeahead_Output
597597+ var handleErr error
598598+ // func (s *Server) handleComAtprotoAccountResetPassword(ctx context.Context,body comatprototypes.AccountResetPassword_Input) error
599599+ handleErr = s.handleComAtprotoAccountResetPassword(ctx, &body)
600600+ if handleErr != nil {
601601+ return handleErr
602602+ }
603603+ return nil
604604+}
605605+606606+func (s *Server) HandleComAtprotoHandleResolve(c echo.Context) error {
607607+ ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleComAtprotoHandleResolve")
608608+ defer span.End()
609609+ handle := c.QueryParam("handle")
610610+ var out *comatprototypes.HandleResolve_Output
485611 var handleErr error
486486- // func (s *Server) handleAppBskyActorSearchTypeahead(ctx context.Context,limit int,term string) (*appbskytypes.ActorSearchTypeahead_Output, error)
487487- out, handleErr = s.handleAppBskyActorSearchTypeahead(ctx, limit, term)
612612+ // func (s *Server) handleComAtprotoHandleResolve(ctx context.Context,handle string) (*comatprototypes.HandleResolve_Output, error)
613613+ out, handleErr = s.handleComAtprotoHandleResolve(ctx, handle)
488614 if handleErr != nil {
489615 return handleErr
490616 }
491617 return c.JSON(200, out)
492618}
493619494494-func (s *Server) HandleAppBskyActorUpdateProfile(c echo.Context) error {
495495- ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleAppBskyActorUpdateProfile")
620620+func (s *Server) HandleComAtprotoRepoBatchWrite(c echo.Context) error {
621621+ ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleComAtprotoRepoBatchWrite")
496622 defer span.End()
497623498498- var body appbskytypes.ActorUpdateProfile_Input
624624+ var body comatprototypes.RepoBatchWrite_Input
499625 if err := c.Bind(&body); err != nil {
500626 return err
501627 }
502502- var out *appbskytypes.ActorUpdateProfile_Output
503628 var handleErr error
504504- // func (s *Server) handleAppBskyActorUpdateProfile(ctx context.Context,body appbskytypes.ActorUpdateProfile_Input) (*appbskytypes.ActorUpdateProfile_Output, error)
505505- out, handleErr = s.handleAppBskyActorUpdateProfile(ctx, &body)
629629+ // func (s *Server) handleComAtprotoRepoBatchWrite(ctx context.Context,body comatprototypes.RepoBatchWrite_Input) error
630630+ handleErr = s.handleComAtprotoRepoBatchWrite(ctx, &body)
506631 if handleErr != nil {
507632 return handleErr
508633 }
509509- return c.JSON(200, out)
634634+ return nil
510635}
511636512512-func (s *Server) HandleAppBskyFeedGetAuthorFeed(c echo.Context) error {
513513- ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleAppBskyFeedGetAuthorFeed")
637637+func (s *Server) HandleComAtprotoRepoCreateRecord(c echo.Context) error {
638638+ ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleComAtprotoRepoCreateRecord")
514639 defer span.End()
515515- author := c.QueryParam("author")
516516- before := c.QueryParam("before")
517640518518- limit, err := strconv.Atoi(c.QueryParam("limit"))
519519- if err != nil {
641641+ var body comatprototypes.RepoCreateRecord_Input
642642+ if err := c.Bind(&body); err != nil {
520643 return err
521644 }
522522- var out *appbskytypes.FeedGetAuthorFeed_Output
645645+ var out *comatprototypes.RepoCreateRecord_Output
523646 var handleErr error
524524- // func (s *Server) handleAppBskyFeedGetAuthorFeed(ctx context.Context,author string,before string,limit int) (*appbskytypes.FeedGetAuthorFeed_Output, error)
525525- out, handleErr = s.handleAppBskyFeedGetAuthorFeed(ctx, author, before, limit)
647647+ // func (s *Server) handleComAtprotoRepoCreateRecord(ctx context.Context,body comatprototypes.RepoCreateRecord_Input) (*comatprototypes.RepoCreateRecord_Output, error)
648648+ out, handleErr = s.handleComAtprotoRepoCreateRecord(ctx, &body)
526649 if handleErr != nil {
527650 return handleErr
528651 }
529652 return c.JSON(200, out)
530653}
531654532532-func (s *Server) HandleAppBskyFeedGetPostThread(c echo.Context) error {
533533- ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleAppBskyFeedGetPostThread")
655655+func (s *Server) HandleComAtprotoRepoDeleteRecord(c echo.Context) error {
656656+ ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleComAtprotoRepoDeleteRecord")
534657 defer span.End()
535658536536- depth, err := strconv.Atoi(c.QueryParam("depth"))
537537- if err != nil {
659659+ var body comatprototypes.RepoDeleteRecord_Input
660660+ if err := c.Bind(&body); err != nil {
538661 return err
539662 }
540540- uri := c.QueryParam("uri")
541541- var out *appbskytypes.FeedGetPostThread_Output
542663 var handleErr error
543543- // func (s *Server) handleAppBskyFeedGetPostThread(ctx context.Context,depth int,uri string) (*appbskytypes.FeedGetPostThread_Output, error)
544544- out, handleErr = s.handleAppBskyFeedGetPostThread(ctx, depth, uri)
664664+ // func (s *Server) handleComAtprotoRepoDeleteRecord(ctx context.Context,body comatprototypes.RepoDeleteRecord_Input) error
665665+ handleErr = s.handleComAtprotoRepoDeleteRecord(ctx, &body)
545666 if handleErr != nil {
546667 return handleErr
547668 }
548548- return c.JSON(200, out)
669669+ return nil
549670}
550671551551-func (s *Server) HandleAppBskyFeedGetRepostedBy(c echo.Context) error {
552552- ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleAppBskyFeedGetRepostedBy")
672672+func (s *Server) HandleComAtprotoRepoDescribe(c echo.Context) error {
673673+ ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleComAtprotoRepoDescribe")
553674 defer span.End()
554554- before := c.QueryParam("before")
555555- cid := c.QueryParam("cid")
556556-557557- limit, err := strconv.Atoi(c.QueryParam("limit"))
558558- if err != nil {
559559- return err
560560- }
561561- uri := c.QueryParam("uri")
562562- var out *appbskytypes.FeedGetRepostedBy_Output
675675+ user := c.QueryParam("user")
676676+ var out *comatprototypes.RepoDescribe_Output
563677 var handleErr error
564564- // func (s *Server) handleAppBskyFeedGetRepostedBy(ctx context.Context,before string,cid string,limit int,uri string) (*appbskytypes.FeedGetRepostedBy_Output, error)
565565- out, handleErr = s.handleAppBskyFeedGetRepostedBy(ctx, before, cid, limit, uri)
678678+ // func (s *Server) handleComAtprotoRepoDescribe(ctx context.Context,user string) (*comatprototypes.RepoDescribe_Output, error)
679679+ out, handleErr = s.handleComAtprotoRepoDescribe(ctx, user)
566680 if handleErr != nil {
567681 return handleErr
568682 }
569683 return c.JSON(200, out)
570684}
571685572572-func (s *Server) HandleAppBskyFeedGetTimeline(c echo.Context) error {
573573- ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleAppBskyFeedGetTimeline")
686686+func (s *Server) HandleComAtprotoRepoGetRecord(c echo.Context) error {
687687+ ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleComAtprotoRepoGetRecord")
574688 defer span.End()
575575- algorithm := c.QueryParam("algorithm")
576576- before := c.QueryParam("before")
577577-578578- limit, err := strconv.Atoi(c.QueryParam("limit"))
579579- if err != nil {
580580- return err
581581- }
582582- var out *appbskytypes.FeedGetTimeline_Output
689689+ cid := c.QueryParam("cid")
690690+ collection := c.QueryParam("collection")
691691+ rkey := c.QueryParam("rkey")
692692+ user := c.QueryParam("user")
693693+ var out *comatprototypes.RepoGetRecord_Output
583694 var handleErr error
584584- // func (s *Server) handleAppBskyFeedGetTimeline(ctx context.Context,algorithm string,before string,limit int) (*appbskytypes.FeedGetTimeline_Output, error)
585585- out, handleErr = s.handleAppBskyFeedGetTimeline(ctx, algorithm, before, limit)
695695+ // func (s *Server) handleComAtprotoRepoGetRecord(ctx context.Context,cid string,collection string,rkey string,user string) (*comatprototypes.RepoGetRecord_Output, error)
696696+ out, handleErr = s.handleComAtprotoRepoGetRecord(ctx, cid, collection, rkey, user)
586697 if handleErr != nil {
587698 return handleErr
588699 }
589700 return c.JSON(200, out)
590701}
591702592592-func (s *Server) HandleAppBskyFeedGetVotes(c echo.Context) error {
593593- ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleAppBskyFeedGetVotes")
703703+func (s *Server) HandleComAtprotoRepoListRecords(c echo.Context) error {
704704+ ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleComAtprotoRepoListRecords")
594705 defer span.End()
706706+ after := c.QueryParam("after")
595707 before := c.QueryParam("before")
596596- cid := c.QueryParam("cid")
597597- direction := c.QueryParam("direction")
708708+ collection := c.QueryParam("collection")
598709599599- limit, err := strconv.Atoi(c.QueryParam("limit"))
600600- if err != nil {
601601- return err
710710+ var limit int
711711+ if p := c.QueryParam("limit"); p != "" {
712712+ var err error
713713+ limit, err = strconv.Atoi(p)
714714+ if err != nil {
715715+ return err
716716+ }
717717+ } else {
718718+ limit = 50
602719 }
603603- uri := c.QueryParam("uri")
604604- var out *appbskytypes.FeedGetVotes_Output
720720+ var out *comatprototypes.RepoListRecords_Output
605721 var handleErr error
606606- // func (s *Server) handleAppBskyFeedGetVotes(ctx context.Context,before string,cid string,direction string,limit int,uri string) (*appbskytypes.FeedGetVotes_Output, error)
607607- out, handleErr = s.handleAppBskyFeedGetVotes(ctx, before, cid, direction, limit, uri)
722722+ // func (s *Server) handleComAtprotoRepoListRecords(ctx context.Context,after string,before string,collection string,limit int) (*comatprototypes.RepoListRecords_Output, error)
723723+ out, handleErr = s.handleComAtprotoRepoListRecords(ctx, after, before, collection, limit)
608724 if handleErr != nil {
609725 return handleErr
610726 }
611727 return c.JSON(200, out)
612728}
613729614614-func (s *Server) HandleAppBskyFeedSetVote(c echo.Context) error {
615615- ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleAppBskyFeedSetVote")
730730+func (s *Server) HandleComAtprotoRepoPutRecord(c echo.Context) error {
731731+ ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleComAtprotoRepoPutRecord")
616732 defer span.End()
617733618618- var body appbskytypes.FeedSetVote_Input
734734+ var body comatprototypes.RepoPutRecord_Input
619735 if err := c.Bind(&body); err != nil {
620736 return err
621737 }
622622- var out *appbskytypes.FeedSetVote_Output
738738+ var out *comatprototypes.RepoPutRecord_Output
623739 var handleErr error
624624- // func (s *Server) handleAppBskyFeedSetVote(ctx context.Context,body appbskytypes.FeedSetVote_Input) (*appbskytypes.FeedSetVote_Output, error)
625625- out, handleErr = s.handleAppBskyFeedSetVote(ctx, &body)
740740+ // func (s *Server) handleComAtprotoRepoPutRecord(ctx context.Context,body comatprototypes.RepoPutRecord_Input) (*comatprototypes.RepoPutRecord_Output, error)
741741+ out, handleErr = s.handleComAtprotoRepoPutRecord(ctx, &body)
626742 if handleErr != nil {
627743 return handleErr
628744 }
629745 return c.JSON(200, out)
630746}
631747632632-func (s *Server) HandleAppBskyGraphGetAssertions(c echo.Context) error {
633633- ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleAppBskyGraphGetAssertions")
748748+func (s *Server) HandleComAtprotoServerGetAccountsConfig(c echo.Context) error {
749749+ ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleComAtprotoServerGetAccountsConfig")
634750 defer span.End()
635635- assertion := c.QueryParam("assertion")
636636- author := c.QueryParam("author")
637637- before := c.QueryParam("before")
638638- var out *appbskytypes.GraphGetAssertions_Output
751751+ var out *comatprototypes.ServerGetAccountsConfig_Output
639752 var handleErr error
640640- // func (s *Server) handleAppBskyGraphGetAssertions(ctx context.Context,assertion string,author string,before string) (*appbskytypes.GraphGetAssertions_Output, error)
641641- out, handleErr = s.handleAppBskyGraphGetAssertions(ctx, assertion, author, before)
753753+ // func (s *Server) handleComAtprotoServerGetAccountsConfig(ctx context.Context) (*comatprototypes.ServerGetAccountsConfig_Output, error)
754754+ out, handleErr = s.handleComAtprotoServerGetAccountsConfig(ctx)
642755 if handleErr != nil {
643756 return handleErr
644757 }
645758 return c.JSON(200, out)
646759}
647760648648-func (s *Server) HandleAppBskyGraphGetFollowers(c echo.Context) error {
649649- ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleAppBskyGraphGetFollowers")
761761+func (s *Server) HandleComAtprotoSessionCreate(c echo.Context) error {
762762+ ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleComAtprotoSessionCreate")
650763 defer span.End()
651651- before := c.QueryParam("before")
652764653653- limit, err := strconv.Atoi(c.QueryParam("limit"))
654654- if err != nil {
765765+ var body comatprototypes.SessionCreate_Input
766766+ if err := c.Bind(&body); err != nil {
655767 return err
656768 }
657657- user := c.QueryParam("user")
658658- var out *appbskytypes.GraphGetFollowers_Output
769769+ var out *comatprototypes.SessionCreate_Output
659770 var handleErr error
660660- // func (s *Server) handleAppBskyGraphGetFollowers(ctx context.Context,before string,limit int,user string) (*appbskytypes.GraphGetFollowers_Output, error)
661661- out, handleErr = s.handleAppBskyGraphGetFollowers(ctx, before, limit, user)
771771+ // func (s *Server) handleComAtprotoSessionCreate(ctx context.Context,body comatprototypes.SessionCreate_Input) (*comatprototypes.SessionCreate_Output, error)
772772+ out, handleErr = s.handleComAtprotoSessionCreate(ctx, &body)
662773 if handleErr != nil {
663774 return handleErr
664775 }
665776 return c.JSON(200, out)
666777}
667778668668-func (s *Server) HandleAppBskyGraphGetFollows(c echo.Context) error {
669669- ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleAppBskyGraphGetFollows")
779779+func (s *Server) HandleComAtprotoSessionDelete(c echo.Context) error {
780780+ ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleComAtprotoSessionDelete")
670781 defer span.End()
671671- before := c.QueryParam("before")
672672-673673- limit, err := strconv.Atoi(c.QueryParam("limit"))
674674- if err != nil {
675675- return err
676676- }
677677- user := c.QueryParam("user")
678678- var out *appbskytypes.GraphGetFollows_Output
679782 var handleErr error
680680- // func (s *Server) handleAppBskyGraphGetFollows(ctx context.Context,before string,limit int,user string) (*appbskytypes.GraphGetFollows_Output, error)
681681- out, handleErr = s.handleAppBskyGraphGetFollows(ctx, before, limit, user)
783783+ // func (s *Server) handleComAtprotoSessionDelete(ctx context.Context) error
784784+ handleErr = s.handleComAtprotoSessionDelete(ctx)
682785 if handleErr != nil {
683786 return handleErr
684787 }
685685- return c.JSON(200, out)
788788+ return nil
686789}
687790688688-func (s *Server) HandleAppBskyGraphGetMembers(c echo.Context) error {
689689- ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleAppBskyGraphGetMembers")
791791+func (s *Server) HandleComAtprotoSessionGet(c echo.Context) error {
792792+ ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleComAtprotoSessionGet")
690793 defer span.End()
691691- actor := c.QueryParam("actor")
692692- before := c.QueryParam("before")
693693-694694- limit, err := strconv.Atoi(c.QueryParam("limit"))
695695- if err != nil {
696696- return err
697697- }
698698- var out *appbskytypes.GraphGetMembers_Output
794794+ var out *comatprototypes.SessionGet_Output
699795 var handleErr error
700700- // func (s *Server) handleAppBskyGraphGetMembers(ctx context.Context,actor string,before string,limit int) (*appbskytypes.GraphGetMembers_Output, error)
701701- out, handleErr = s.handleAppBskyGraphGetMembers(ctx, actor, before, limit)
796796+ // func (s *Server) handleComAtprotoSessionGet(ctx context.Context) (*comatprototypes.SessionGet_Output, error)
797797+ out, handleErr = s.handleComAtprotoSessionGet(ctx)
702798 if handleErr != nil {
703799 return handleErr
704800 }
705801 return c.JSON(200, out)
706802}
707803708708-func (s *Server) HandleAppBskyGraphGetMemberships(c echo.Context) error {
709709- ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleAppBskyGraphGetMemberships")
804804+func (s *Server) HandleComAtprotoSessionRefresh(c echo.Context) error {
805805+ ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleComAtprotoSessionRefresh")
710806 defer span.End()
711711- actor := c.QueryParam("actor")
712712- before := c.QueryParam("before")
713713-714714- limit, err := strconv.Atoi(c.QueryParam("limit"))
715715- if err != nil {
716716- return err
717717- }
718718- var out *appbskytypes.GraphGetMemberships_Output
807807+ var out *comatprototypes.SessionRefresh_Output
719808 var handleErr error
720720- // func (s *Server) handleAppBskyGraphGetMemberships(ctx context.Context,actor string,before string,limit int) (*appbskytypes.GraphGetMemberships_Output, error)
721721- out, handleErr = s.handleAppBskyGraphGetMemberships(ctx, actor, before, limit)
809809+ // func (s *Server) handleComAtprotoSessionRefresh(ctx context.Context) (*comatprototypes.SessionRefresh_Output, error)
810810+ out, handleErr = s.handleComAtprotoSessionRefresh(ctx)
722811 if handleErr != nil {
723812 return handleErr
724813 }
725814 return c.JSON(200, out)
726815}
727816728728-func (s *Server) HandleAppBskyNotificationGetCount(c echo.Context) error {
729729- ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleAppBskyNotificationGetCount")
817817+func (s *Server) HandleComAtprotoSyncGetRepo(c echo.Context) error {
818818+ ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleComAtprotoSyncGetRepo")
730819 defer span.End()
731731- var out *appbskytypes.NotificationGetCount_Output
820820+ did := c.QueryParam("did")
821821+ from := c.QueryParam("from")
822822+ var out io.Reader
732823 var handleErr error
733733- // func (s *Server) handleAppBskyNotificationGetCount(ctx context.Context) (*appbskytypes.NotificationGetCount_Output, error)
734734- out, handleErr = s.handleAppBskyNotificationGetCount(ctx)
824824+ // func (s *Server) handleComAtprotoSyncGetRepo(ctx context.Context,did string,from string) (io.Reader, error)
825825+ out, handleErr = s.handleComAtprotoSyncGetRepo(ctx, did, from)
735826 if handleErr != nil {
736827 return handleErr
737828 }
738829 return c.JSON(200, out)
739830}
740831741741-func (s *Server) HandleAppBskyNotificationList(c echo.Context) error {
742742- ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleAppBskyNotificationList")
832832+func (s *Server) HandleComAtprotoSyncGetRoot(c echo.Context) error {
833833+ ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleComAtprotoSyncGetRoot")
743834 defer span.End()
744744- before := c.QueryParam("before")
745745-746746- limit, err := strconv.Atoi(c.QueryParam("limit"))
747747- if err != nil {
748748- return err
749749- }
750750- var out *appbskytypes.NotificationList_Output
835835+ did := c.QueryParam("did")
836836+ var out *comatprototypes.SyncGetRoot_Output
751837 var handleErr error
752752- // func (s *Server) handleAppBskyNotificationList(ctx context.Context,before string,limit int) (*appbskytypes.NotificationList_Output, error)
753753- out, handleErr = s.handleAppBskyNotificationList(ctx, before, limit)
838838+ // func (s *Server) handleComAtprotoSyncGetRoot(ctx context.Context,did string) (*comatprototypes.SyncGetRoot_Output, error)
839839+ out, handleErr = s.handleComAtprotoSyncGetRoot(ctx, did)
754840 if handleErr != nil {
755841 return handleErr
756842 }
757843 return c.JSON(200, out)
758844}
759845760760-func (s *Server) HandleAppBskyNotificationUpdateSeen(c echo.Context) error {
761761- ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleAppBskyNotificationUpdateSeen")
846846+func (s *Server) HandleComAtprotoSyncUpdateRepo(c echo.Context) error {
847847+ ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleComAtprotoSyncUpdateRepo")
762848 defer span.End()
763763-764764- var body appbskytypes.NotificationUpdateSeen_Input
765765- if err := c.Bind(&body); err != nil {
766766- return err
767767- }
849849+ body := c.Request().Body
768850 var handleErr error
769769- // func (s *Server) handleAppBskyNotificationUpdateSeen(ctx context.Context,body appbskytypes.NotificationUpdateSeen_Input) error
770770- handleErr = s.handleAppBskyNotificationUpdateSeen(ctx, &body)
851851+ // func (s *Server) handleComAtprotoSyncUpdateRepo(ctx context.Context,r io.Reader) error
852852+ handleErr = s.handleComAtprotoSyncUpdateRepo(ctx, body)
771853 if handleErr != nil {
772854 return handleErr
773855 }
+26
docs/auth.md
···11+# Auth
22+33+The auth system uses two tokens, an access token and a refresh token.
44+55+The access token is a jwt with the following values:
66+```
77+scope: "com.atproto.access"
88+sub: <the users DID>
99+iat: the current time, in unix epoch seconds
1010+exp: the expiry date, usually around an hour, but at least 15 minutes
1111+```
1212+1313+The refresh token is a jwt with the following values:
1414+```
1515+scope: "com.atproto.refresh"
1616+sub: <the users DID>
1717+iat: the current time, in unix epoch seconds
1818+exp: the expiry date, usually around a week, must be significantly longer than the access token
1919+jti: a unique identifier for this token
2020+```
2121+2222+The access token is what is used for all requests, however since it expires
2323+quickly, it must be refreshed periodically using the refresh token.
2424+When the refresh token is used, it must be marked as deleted, and the new token then replaces it.
2525+Note: The old access token is not necessarily disabled at that point of refreshing.
2626+
+54-25
lex/gen.go
···6767 Const any `json:"const"`
6868 Enum []string `json:"enum"`
6969 Closed bool `json:"closed"`
7070+7171+ Default any `json:"default"`
7272+ Minimum any `json:"minimum"`
7373+ Maximum any `json:"maximum"`
7074}
71757276func (s *Schema) Name() string {
···254258255259 if t.Type.record && !strings.Contains(t.Name, "_") {
256260 id := t.Type.id
257257- if t.Type.defName != "" {
258258- id = id + "#" + t.Type.defName
259259- }
261261+ if t.Type.defName != "" {
262262+ id = id + "#" + t.Type.defName
263263+ }
260264 fmt.Fprintf(w, "util.RegisterType(%q, %s{})\n", id, t.Name)
261265 }
262266 }
···631635func (s *TypeSchema) WriteHandlerStub(w io.Writer, fname, shortname, impname string) error {
632636 paramtypes := []string{"ctx context.Context"}
633637 if s.Type == "query" {
638638+634639 if s.Parameters != nil {
640640+ var required map[string]bool
641641+ if s.Parameters.Required != nil {
642642+ required = make(map[string]bool)
643643+ for _, r := range s.Required {
644644+ required[r] = true
645645+ }
646646+ }
635647 orderedMapIter[TypeSchema](s.Parameters.Properties, func(k string, t TypeSchema) error {
636648 switch t.Type {
637649 case "string":
638650 paramtypes = append(paramtypes, k+" string")
639651 case "integer":
640640- paramtypes = append(paramtypes, k+" int")
652652+ if required != nil && !required[k] {
653653+ paramtypes = append(paramtypes, k+" *int")
654654+ } else {
655655+ paramtypes = append(paramtypes, k+" int")
656656+ }
641657 case "number":
642658 return fmt.Errorf("non-integer numbers currently unsupported")
643659 default:
···683699 fmt.Fprintf(w, "ctx, span := otel.Tracer(\"server\").Start(c.Request().Context(), %q)\n", "Handle"+fname)
684700 fmt.Fprintf(w, "defer span.End()\n")
685701686686- var required map[string]bool
687687- if s.Required != nil {
688688- for _, r := range s.Required {
689689- required[r] = true
690690- }
691691- }
692692-693702 paramtypes := []string{"ctx context.Context"}
694703 params := []string{"ctx"}
695704 if s.Type == "query" {
696705 if s.Parameters != nil {
706706+ required := make(map[string]bool)
707707+ for _, r := range s.Parameters.Required {
708708+ required[r] = true
709709+ }
710710+ for k, v := range s.Parameters.Properties {
711711+ if v.Default != nil {
712712+ required[k] = true
713713+ }
714714+ }
697715 orderedMapIter[TypeSchema](s.Parameters.Properties, func(k string, t TypeSchema) error {
698716 switch t.Type {
699717 case "string":
···703721 case "integer":
704722 params = append(params, k)
705723706706- if required != nil && !required[k] {
707707- paramtypes = append(paramtypes, k+" *int")
708708- fmt.Fprintf(w, `
724724+ if !required[k] {
725725+ paramtypes = append(paramtypes, k+" *int")
726726+ fmt.Fprintf(w, `
709727var %s *int
710728if p := c.QueryParam("%s"); p != "" {
711711-%s_val, err := strconv.Atoi(p)
729729+ %s_val, err := strconv.Atoi(p)
730730+ if err != nil {
731731+ return err
732732+ }
733733+ %s = &%s_val
734734+}
735735+`, k, k, k, k, k)
736736+ } else if t.Default != nil {
737737+ paramtypes = append(paramtypes, k+" int")
738738+ fmt.Fprintf(w, `
739739+var %s int
740740+if p := c.QueryParam("%s"); p != "" {
741741+var err error
742742+%s, err = strconv.Atoi(p)
712743if err != nil {
713744 return err
714745}
715715- %s = &%s_val
746746+} else {
747747+ %s = %d
716748}
717717-`, k, k, k, k, k)
749749+`, k, k,k, k, int(t.Default.(float64)))
718750 } else {
719719- paramtypes = append(paramtypes, k+" int")
720720- fmt.Fprintf(w, `
751751+752752+ paramtypes = append(paramtypes, k+" int")
753753+ fmt.Fprintf(w, `
721754%s, err := strconv.Atoi(c.QueryParam("%s"))
722755if err != nil {
723756 return err
724757}
725758`, k, k)
726759 }
727727-728760729761 case "number":
730762 return fmt.Errorf("non-integer numbers currently unsupported")
···918950 fmt.Fprintf(w, "\tLexiconTypeID string `json:\"$type\" cborgen:\"$type,const=%s\"`\n", ts.id)
919951 }
920952921921- var required map[string]bool
922922- if ts.Required != nil {
923923- required = make(map[string]bool)
953953+ required := make(map[string]bool)
924954 for _, req := range ts.Required {
925955 required[req] = true
926956 }
927927- }
928957929958 for k, v := range ts.Properties {
930959 goname := strings.Title(k)
···935964 }
936965937966 var ptr string
938938- if required != nil && !required[k] {
967967+ if !required[k] {
939968 if !strings.HasPrefix(tname, "*") && !strings.HasPrefix(tname, "[]") {
940969 ptr = "*"
941970 }
+115
lex/util/cbor_gen.go
···11+// Code generated by github.com/whyrusleeping/cbor-gen. DO NOT EDIT.
22+33+package util
44+55+import (
66+ "fmt"
77+ "io"
88+ "math"
99+ "sort"
1010+1111+ cid "github.com/ipfs/go-cid"
1212+ cbg "github.com/whyrusleeping/cbor-gen"
1313+ xerrors "golang.org/x/xerrors"
1414+)
1515+1616+var _ = xerrors.Errorf
1717+var _ = cid.Undef
1818+var _ = math.E
1919+var _ = sort.Sort
2020+2121+func (t *CborChecker) MarshalCBOR(w io.Writer) error {
2222+ if t == nil {
2323+ _, err := w.Write(cbg.CborNull)
2424+ return err
2525+ }
2626+2727+ cw := cbg.NewCborWriter(w)
2828+2929+ if _, err := cw.Write([]byte{161}); err != nil {
3030+ return err
3131+ }
3232+3333+ // t.Type (string) (string)
3434+ if len("$type") > cbg.MaxLength {
3535+ return xerrors.Errorf("Value in field \"$type\" was too long")
3636+ }
3737+3838+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("$type"))); err != nil {
3939+ return err
4040+ }
4141+ if _, err := io.WriteString(w, string("$type")); err != nil {
4242+ return err
4343+ }
4444+4545+ if len(t.Type) > cbg.MaxLength {
4646+ return xerrors.Errorf("Value in field t.Type was too long")
4747+ }
4848+4949+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Type))); err != nil {
5050+ return err
5151+ }
5252+ if _, err := io.WriteString(w, string(t.Type)); err != nil {
5353+ return err
5454+ }
5555+ return nil
5656+}
5757+5858+func (t *CborChecker) UnmarshalCBOR(r io.Reader) (err error) {
5959+ *t = CborChecker{}
6060+6161+ cr := cbg.NewCborReader(r)
6262+6363+ maj, extra, err := cr.ReadHeader()
6464+ if err != nil {
6565+ return err
6666+ }
6767+ defer func() {
6868+ if err == io.EOF {
6969+ err = io.ErrUnexpectedEOF
7070+ }
7171+ }()
7272+7373+ if maj != cbg.MajMap {
7474+ return fmt.Errorf("cbor input should be of type map")
7575+ }
7676+7777+ if extra > cbg.MaxLength {
7878+ return fmt.Errorf("CborChecker: map struct too large (%d)", extra)
7979+ }
8080+8181+ var name string
8282+ n := extra
8383+8484+ for i := uint64(0); i < n; i++ {
8585+8686+ {
8787+ sval, err := cbg.ReadString(cr)
8888+ if err != nil {
8989+ return err
9090+ }
9191+9292+ name = string(sval)
9393+ }
9494+9595+ switch name {
9696+ // t.Type (string) (string)
9797+ case "$type":
9898+9999+ {
100100+ sval, err := cbg.ReadString(cr)
101101+ if err != nil {
102102+ return err
103103+ }
104104+105105+ t.Type = string(sval)
106106+ }
107107+108108+ default:
109109+ // Field doesn't exist on this type, so ignore it
110110+ cbg.ScanForLinks(r, func(cid.Cid) {})
111111+ }
112112+ }
113113+114114+ return nil
115115+}
+78
lex/util/decoder.go
···11+package util
22+33+import (
44+ "bytes"
55+ "encoding/json"
66+ "fmt"
77+ "reflect"
88+99+ cbg "github.com/whyrusleeping/cbor-gen"
1010+)
1111+1212+var lexTypesMap map[string]reflect.Type
1313+1414+func init() {
1515+ lexTypesMap = make(map[string]reflect.Type)
1616+}
1717+1818+func RegisterType(id string, val any) {
1919+ t := reflect.TypeOf(val)
2020+2121+ if t.Kind() == reflect.Pointer {
2222+ t = t.Elem()
2323+ }
2424+2525+ if _, ok := lexTypesMap[id]; ok {
2626+ panic(fmt.Sprintf("already registered type for %q", id))
2727+ }
2828+2929+ lexTypesMap[id] = t
3030+}
3131+3232+func JsonDecodeValue(b []byte) (any, error) {
3333+ tstr, err := TypeExtract(b)
3434+ if err != nil {
3535+ return nil, err
3636+ }
3737+3838+ t, ok := lexTypesMap[tstr]
3939+ if !ok {
4040+ return nil, fmt.Errorf("unrecognized type: %q", tstr)
4141+ }
4242+4343+ val := reflect.New(t)
4444+4545+ ival := val.Interface()
4646+ if err := json.Unmarshal(b, ival); err != nil {
4747+ return nil, err
4848+ }
4949+5050+ return ival, nil
5151+}
5252+5353+func CborDecodeValue(b []byte) (any, error) {
5454+ tstr, err := CborTypeExtract(b)
5555+ if err != nil {
5656+ return nil, err
5757+ }
5858+5959+ t, ok := lexTypesMap[tstr]
6060+ if !ok {
6161+ return nil, fmt.Errorf("unrecognized type: %q", tstr)
6262+ }
6363+6464+ val := reflect.New(t)
6565+6666+ ival, ok := val.Interface().(cbg.CBORUnmarshaler)
6767+ if !ok {
6868+ return nil, fmt.Errorf("registered type did not have proper cbor hooks")
6969+ }
7070+7171+ if err := ival.UnmarshalCBOR(bytes.NewReader(b)); err != nil {
7272+ return nil, err
7373+ }
7474+7575+ fmt.Printf("DECODED VALUE: %#v\n", ival)
7676+7777+ return ival, nil
7878+}