Live video on the AT Protocol
79
fork

Configure Feed

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

at eli/oatproxy-panic 476 lines 18 kB view raw
1package spxrpc 2 3import ( 4 "io" 5 "strconv" 6 7 comatprototypes "github.com/bluesky-social/indigo/api/atproto" 8 appbskytypes "github.com/bluesky-social/indigo/api/bsky" 9 "github.com/labstack/echo/v4" 10 "go.opentelemetry.io/otel" 11 placestreamtypes "stream.place/streamplace/pkg/streamplace" 12) 13 14func (s *Server) RegisterHandlersAppBsky(e *echo.Echo) error { 15 e.GET("/xrpc/app.bsky.actor.getProfile", s.HandleAppBskyActorGetProfile) 16 e.GET("/xrpc/app.bsky.feed.getFeedSkeleton", s.HandleAppBskyFeedGetFeedSkeleton) 17 return nil 18} 19 20func (s *Server) HandleAppBskyActorGetProfile(c echo.Context) error { 21 ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleAppBskyActorGetProfile") 22 defer span.End() 23 actor := c.QueryParam("actor") 24 var out *appbskytypes.ActorDefs_ProfileViewDetailed 25 var handleErr error 26 // func (s *Server) handleAppBskyActorGetProfile(ctx context.Context,actor string) (*appbskytypes.ActorDefs_ProfileViewDetailed, error) 27 out, handleErr = s.handleAppBskyActorGetProfile(ctx, actor) 28 if handleErr != nil { 29 return handleErr 30 } 31 return c.JSON(200, out) 32} 33 34func (s *Server) HandleAppBskyFeedGetFeedSkeleton(c echo.Context) error { 35 ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleAppBskyFeedGetFeedSkeleton") 36 defer span.End() 37 cursor := c.QueryParam("cursor") 38 feed := c.QueryParam("feed") 39 40 var limit int 41 if p := c.QueryParam("limit"); p != "" { 42 var err error 43 limit, err = strconv.Atoi(p) 44 if err != nil { 45 return err 46 } 47 } else { 48 limit = 50 49 } 50 var out *appbskytypes.FeedGetFeedSkeleton_Output 51 var handleErr error 52 // func (s *Server) handleAppBskyFeedGetFeedSkeleton(ctx context.Context,cursor string,feed string,limit int) (*appbskytypes.FeedGetFeedSkeleton_Output, error) 53 out, handleErr = s.handleAppBskyFeedGetFeedSkeleton(ctx, cursor, feed, limit) 54 if handleErr != nil { 55 return handleErr 56 } 57 return c.JSON(200, out) 58} 59 60func (s *Server) RegisterHandlersChatBsky(e *echo.Echo) error { 61 return nil 62} 63 64func (s *Server) RegisterHandlersComAtproto(e *echo.Echo) error { 65 e.POST("/xrpc/com.atproto.identity.refreshIdentity", s.HandleComAtprotoIdentityRefreshIdentity) 66 e.GET("/xrpc/com.atproto.identity.resolveHandle", s.HandleComAtprotoIdentityResolveHandle) 67 e.POST("/xrpc/com.atproto.moderation.createReport", s.HandleComAtprotoModerationCreateReport) 68 e.GET("/xrpc/com.atproto.repo.describeRepo", s.HandleComAtprotoRepoDescribeRepo) 69 e.GET("/xrpc/com.atproto.repo.getRecord", s.HandleComAtprotoRepoGetRecord) 70 e.GET("/xrpc/com.atproto.repo.listRecords", s.HandleComAtprotoRepoListRecords) 71 e.POST("/xrpc/com.atproto.repo.uploadBlob", s.HandleComAtprotoRepoUploadBlob) 72 e.GET("/xrpc/com.atproto.server.describeServer", s.HandleComAtprotoServerDescribeServer) 73 e.GET("/xrpc/com.atproto.sync.getRecord", s.HandleComAtprotoSyncGetRecord) 74 e.GET("/xrpc/com.atproto.sync.listRepos", s.HandleComAtprotoSyncListRepos) 75 return nil 76} 77 78func (s *Server) HandleComAtprotoIdentityRefreshIdentity(c echo.Context) error { 79 ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleComAtprotoIdentityRefreshIdentity") 80 defer span.End() 81 82 var body comatprototypes.IdentityRefreshIdentity_Input 83 if err := c.Bind(&body); err != nil { 84 return err 85 } 86 var out *comatprototypes.IdentityDefs_IdentityInfo 87 var handleErr error 88 // func (s *Server) handleComAtprotoIdentityRefreshIdentity(ctx context.Context,body *comatprototypes.IdentityRefreshIdentity_Input) (*comatprototypes.IdentityDefs_IdentityInfo, error) 89 out, handleErr = s.handleComAtprotoIdentityRefreshIdentity(ctx, &body) 90 if handleErr != nil { 91 return handleErr 92 } 93 return c.JSON(200, out) 94} 95 96func (s *Server) HandleComAtprotoIdentityResolveHandle(c echo.Context) error { 97 ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleComAtprotoIdentityResolveHandle") 98 defer span.End() 99 handle := c.QueryParam("handle") 100 var out *comatprototypes.IdentityResolveHandle_Output 101 var handleErr error 102 // func (s *Server) handleComAtprotoIdentityResolveHandle(ctx context.Context,handle string) (*comatprototypes.IdentityResolveHandle_Output, error) 103 out, handleErr = s.handleComAtprotoIdentityResolveHandle(ctx, handle) 104 if handleErr != nil { 105 return handleErr 106 } 107 return c.JSON(200, out) 108} 109 110func (s *Server) HandleComAtprotoModerationCreateReport(c echo.Context) error { 111 ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleComAtprotoModerationCreateReport") 112 defer span.End() 113 114 var body comatprototypes.ModerationCreateReport_Input 115 if err := c.Bind(&body); err != nil { 116 return err 117 } 118 var out *comatprototypes.ModerationCreateReport_Output 119 var handleErr error 120 // func (s *Server) handleComAtprotoModerationCreateReport(ctx context.Context,body *comatprototypes.ModerationCreateReport_Input) (*comatprototypes.ModerationCreateReport_Output, error) 121 out, handleErr = s.handleComAtprotoModerationCreateReport(ctx, &body) 122 if handleErr != nil { 123 return handleErr 124 } 125 return c.JSON(200, out) 126} 127 128func (s *Server) HandleComAtprotoRepoDescribeRepo(c echo.Context) error { 129 ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleComAtprotoRepoDescribeRepo") 130 defer span.End() 131 repo := c.QueryParam("repo") 132 var out *comatprototypes.RepoDescribeRepo_Output 133 var handleErr error 134 // func (s *Server) handleComAtprotoRepoDescribeRepo(ctx context.Context,repo string) (*comatprototypes.RepoDescribeRepo_Output, error) 135 out, handleErr = s.handleComAtprotoRepoDescribeRepo(ctx, repo) 136 if handleErr != nil { 137 return handleErr 138 } 139 return c.JSON(200, out) 140} 141 142func (s *Server) HandleComAtprotoRepoGetRecord(c echo.Context) error { 143 ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleComAtprotoRepoGetRecord") 144 defer span.End() 145 cid := c.QueryParam("cid") 146 collection := c.QueryParam("collection") 147 repo := c.QueryParam("repo") 148 rkey := c.QueryParam("rkey") 149 var out *comatprototypes.RepoGetRecord_Output 150 var handleErr error 151 // func (s *Server) handleComAtprotoRepoGetRecord(ctx context.Context,cid string,collection string,repo string,rkey string) (*comatprototypes.RepoGetRecord_Output, error) 152 out, handleErr = s.handleComAtprotoRepoGetRecord(ctx, cid, collection, repo, rkey) 153 if handleErr != nil { 154 return handleErr 155 } 156 return c.JSON(200, out) 157} 158 159func (s *Server) HandleComAtprotoRepoListRecords(c echo.Context) error { 160 ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleComAtprotoRepoListRecords") 161 defer span.End() 162 collection := c.QueryParam("collection") 163 cursor := c.QueryParam("cursor") 164 165 var limit int 166 if p := c.QueryParam("limit"); p != "" { 167 var err error 168 limit, err = strconv.Atoi(p) 169 if err != nil { 170 return err 171 } 172 } else { 173 limit = 50 174 } 175 repo := c.QueryParam("repo") 176 177 var reverse *bool 178 if p := c.QueryParam("reverse"); p != "" { 179 reverse_val, err := strconv.ParseBool(p) 180 if err != nil { 181 return err 182 } 183 reverse = &reverse_val 184 } 185 var out *comatprototypes.RepoListRecords_Output 186 var handleErr error 187 // func (s *Server) handleComAtprotoRepoListRecords(ctx context.Context,collection string,cursor string,limit int,repo string,reverse *bool) (*comatprototypes.RepoListRecords_Output, error) 188 out, handleErr = s.handleComAtprotoRepoListRecords(ctx, collection, cursor, limit, repo, reverse) 189 if handleErr != nil { 190 return handleErr 191 } 192 return c.JSON(200, out) 193} 194 195func (s *Server) HandleComAtprotoRepoUploadBlob(c echo.Context) error { 196 ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleComAtprotoRepoUploadBlob") 197 defer span.End() 198 body := c.Request().Body 199 contentType := c.Request().Header.Get("Content-Type") 200 var out *comatprototypes.RepoUploadBlob_Output 201 var handleErr error 202 // func (s *Server) handleComAtprotoRepoUploadBlob(ctx context.Context,r io.Reader,contentType string) (*comatprototypes.RepoUploadBlob_Output, error) 203 out, handleErr = s.handleComAtprotoRepoUploadBlob(ctx, body, contentType) 204 if handleErr != nil { 205 return handleErr 206 } 207 return c.JSON(200, out) 208} 209 210func (s *Server) HandleComAtprotoServerDescribeServer(c echo.Context) error { 211 ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleComAtprotoServerDescribeServer") 212 defer span.End() 213 var out *comatprototypes.ServerDescribeServer_Output 214 var handleErr error 215 // func (s *Server) handleComAtprotoServerDescribeServer(ctx context.Context) (*comatprototypes.ServerDescribeServer_Output, error) 216 out, handleErr = s.handleComAtprotoServerDescribeServer(ctx) 217 if handleErr != nil { 218 return handleErr 219 } 220 return c.JSON(200, out) 221} 222 223func (s *Server) HandleComAtprotoSyncGetRecord(c echo.Context) error { 224 ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleComAtprotoSyncGetRecord") 225 defer span.End() 226 collection := c.QueryParam("collection") 227 did := c.QueryParam("did") 228 rkey := c.QueryParam("rkey") 229 var out io.Reader 230 var handleErr error 231 // func (s *Server) handleComAtprotoSyncGetRecord(ctx context.Context,collection string,did string,rkey string) (io.Reader, error) 232 out, handleErr = s.handleComAtprotoSyncGetRecord(ctx, collection, did, rkey) 233 if handleErr != nil { 234 return handleErr 235 } 236 return c.Stream(200, "application/vnd.ipld.car", out) 237} 238 239func (s *Server) HandleComAtprotoSyncListRepos(c echo.Context) error { 240 ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleComAtprotoSyncListRepos") 241 defer span.End() 242 cursor := c.QueryParam("cursor") 243 244 var limit int 245 if p := c.QueryParam("limit"); p != "" { 246 var err error 247 limit, err = strconv.Atoi(p) 248 if err != nil { 249 return err 250 } 251 } else { 252 limit = 500 253 } 254 var out *comatprototypes.SyncListRepos_Output 255 var handleErr error 256 // func (s *Server) handleComAtprotoSyncListRepos(ctx context.Context,cursor string,limit int) (*comatprototypes.SyncListRepos_Output, error) 257 out, handleErr = s.handleComAtprotoSyncListRepos(ctx, cursor, limit) 258 if handleErr != nil { 259 return handleErr 260 } 261 return c.JSON(200, out) 262} 263 264func (s *Server) RegisterHandlersPlaceStream(e *echo.Echo) error { 265 e.GET("/xrpc/place.stream.broadcast.getBroadcaster", s.HandlePlaceStreamBroadcastGetBroadcaster) 266 e.GET("/xrpc/place.stream.graph.getFollowingUser", s.HandlePlaceStreamGraphGetFollowingUser) 267 e.GET("/xrpc/place.stream.live.getLiveUsers", s.HandlePlaceStreamLiveGetLiveUsers) 268 e.GET("/xrpc/place.stream.live.getProfileCard", s.HandlePlaceStreamLiveGetProfileCard) 269 e.GET("/xrpc/place.stream.live.getSegments", s.HandlePlaceStreamLiveGetSegments) 270 e.POST("/xrpc/place.stream.server.createWebhook", s.HandlePlaceStreamServerCreateWebhook) 271 e.POST("/xrpc/place.stream.server.deleteWebhook", s.HandlePlaceStreamServerDeleteWebhook) 272 e.GET("/xrpc/place.stream.server.getWebhook", s.HandlePlaceStreamServerGetWebhook) 273 e.GET("/xrpc/place.stream.server.listWebhooks", s.HandlePlaceStreamServerListWebhooks) 274 e.POST("/xrpc/place.stream.server.updateWebhook", s.HandlePlaceStreamServerUpdateWebhook) 275 return nil 276} 277 278func (s *Server) HandlePlaceStreamBroadcastGetBroadcaster(c echo.Context) error { 279 ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandlePlaceStreamBroadcastGetBroadcaster") 280 defer span.End() 281 var out *placestreamtypes.BroadcastGetBroadcaster_Output 282 var handleErr error 283 // func (s *Server) handlePlaceStreamBroadcastGetBroadcaster(ctx context.Context) (*placestreamtypes.BroadcastGetBroadcaster_Output, error) 284 out, handleErr = s.handlePlaceStreamBroadcastGetBroadcaster(ctx) 285 if handleErr != nil { 286 return handleErr 287 } 288 return c.JSON(200, out) 289} 290 291func (s *Server) HandlePlaceStreamGraphGetFollowingUser(c echo.Context) error { 292 ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandlePlaceStreamGraphGetFollowingUser") 293 defer span.End() 294 subjectDID := c.QueryParam("subjectDID") 295 userDID := c.QueryParam("userDID") 296 var out *placestreamtypes.GraphGetFollowingUser_Output 297 var handleErr error 298 // func (s *Server) handlePlaceStreamGraphGetFollowingUser(ctx context.Context,subjectDID string,userDID string) (*placestreamtypes.GraphGetFollowingUser_Output, error) 299 out, handleErr = s.handlePlaceStreamGraphGetFollowingUser(ctx, subjectDID, userDID) 300 if handleErr != nil { 301 return handleErr 302 } 303 return c.JSON(200, out) 304} 305 306func (s *Server) HandlePlaceStreamLiveGetLiveUsers(c echo.Context) error { 307 ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandlePlaceStreamLiveGetLiveUsers") 308 defer span.End() 309 before := c.QueryParam("before") 310 311 var limit int 312 if p := c.QueryParam("limit"); p != "" { 313 var err error 314 limit, err = strconv.Atoi(p) 315 if err != nil { 316 return err 317 } 318 } else { 319 limit = 50 320 } 321 var out *placestreamtypes.LiveGetLiveUsers_Output 322 var handleErr error 323 // func (s *Server) handlePlaceStreamLiveGetLiveUsers(ctx context.Context,before string,limit int) (*placestreamtypes.LiveGetLiveUsers_Output, error) 324 out, handleErr = s.handlePlaceStreamLiveGetLiveUsers(ctx, before, limit) 325 if handleErr != nil { 326 return handleErr 327 } 328 return c.JSON(200, out) 329} 330 331func (s *Server) HandlePlaceStreamLiveGetProfileCard(c echo.Context) error { 332 ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandlePlaceStreamLiveGetProfileCard") 333 defer span.End() 334 id := c.QueryParam("id") 335 var out io.Reader 336 var handleErr error 337 // func (s *Server) handlePlaceStreamLiveGetProfileCard(ctx context.Context,id string) (io.Reader, error) 338 out, handleErr = s.handlePlaceStreamLiveGetProfileCard(ctx, id) 339 if handleErr != nil { 340 return handleErr 341 } 342 return c.Stream(200, "application/octet-stream", out) 343} 344 345func (s *Server) HandlePlaceStreamLiveGetSegments(c echo.Context) error { 346 ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandlePlaceStreamLiveGetSegments") 347 defer span.End() 348 before := c.QueryParam("before") 349 350 var limit int 351 if p := c.QueryParam("limit"); p != "" { 352 var err error 353 limit, err = strconv.Atoi(p) 354 if err != nil { 355 return err 356 } 357 } else { 358 limit = 50 359 } 360 userDID := c.QueryParam("userDID") 361 var out *placestreamtypes.LiveGetSegments_Output 362 var handleErr error 363 // func (s *Server) handlePlaceStreamLiveGetSegments(ctx context.Context,before string,limit int,userDID string) (*placestreamtypes.LiveGetSegments_Output, error) 364 out, handleErr = s.handlePlaceStreamLiveGetSegments(ctx, before, limit, userDID) 365 if handleErr != nil { 366 return handleErr 367 } 368 return c.JSON(200, out) 369} 370 371func (s *Server) HandlePlaceStreamServerCreateWebhook(c echo.Context) error { 372 ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandlePlaceStreamServerCreateWebhook") 373 defer span.End() 374 375 var body placestreamtypes.ServerCreateWebhook_Input 376 if err := c.Bind(&body); err != nil { 377 return err 378 } 379 var out *placestreamtypes.ServerCreateWebhook_Output 380 var handleErr error 381 // func (s *Server) handlePlaceStreamServerCreateWebhook(ctx context.Context,body *placestreamtypes.ServerCreateWebhook_Input) (*placestreamtypes.ServerCreateWebhook_Output, error) 382 out, handleErr = s.handlePlaceStreamServerCreateWebhook(ctx, &body) 383 if handleErr != nil { 384 return handleErr 385 } 386 return c.JSON(200, out) 387} 388 389func (s *Server) HandlePlaceStreamServerDeleteWebhook(c echo.Context) error { 390 ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandlePlaceStreamServerDeleteWebhook") 391 defer span.End() 392 393 var body placestreamtypes.ServerDeleteWebhook_Input 394 if err := c.Bind(&body); err != nil { 395 return err 396 } 397 var out *placestreamtypes.ServerDeleteWebhook_Output 398 var handleErr error 399 // func (s *Server) handlePlaceStreamServerDeleteWebhook(ctx context.Context,body *placestreamtypes.ServerDeleteWebhook_Input) (*placestreamtypes.ServerDeleteWebhook_Output, error) 400 out, handleErr = s.handlePlaceStreamServerDeleteWebhook(ctx, &body) 401 if handleErr != nil { 402 return handleErr 403 } 404 return c.JSON(200, out) 405} 406 407func (s *Server) HandlePlaceStreamServerGetWebhook(c echo.Context) error { 408 ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandlePlaceStreamServerGetWebhook") 409 defer span.End() 410 id := c.QueryParam("id") 411 var out *placestreamtypes.ServerGetWebhook_Output 412 var handleErr error 413 // func (s *Server) handlePlaceStreamServerGetWebhook(ctx context.Context,id string) (*placestreamtypes.ServerGetWebhook_Output, error) 414 out, handleErr = s.handlePlaceStreamServerGetWebhook(ctx, id) 415 if handleErr != nil { 416 return handleErr 417 } 418 return c.JSON(200, out) 419} 420 421func (s *Server) HandlePlaceStreamServerListWebhooks(c echo.Context) error { 422 ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandlePlaceStreamServerListWebhooks") 423 defer span.End() 424 425 var active *bool 426 if p := c.QueryParam("active"); p != "" { 427 active_val, err := strconv.ParseBool(p) 428 if err != nil { 429 return err 430 } 431 active = &active_val 432 } 433 cursor := c.QueryParam("cursor") 434 event := c.QueryParam("event") 435 436 var limit int 437 if p := c.QueryParam("limit"); p != "" { 438 var err error 439 limit, err = strconv.Atoi(p) 440 if err != nil { 441 return err 442 } 443 } else { 444 limit = 50 445 } 446 var out *placestreamtypes.ServerListWebhooks_Output 447 var handleErr error 448 // func (s *Server) handlePlaceStreamServerListWebhooks(ctx context.Context,active *bool,cursor string,event string,limit int) (*placestreamtypes.ServerListWebhooks_Output, error) 449 out, handleErr = s.handlePlaceStreamServerListWebhooks(ctx, active, cursor, event, limit) 450 if handleErr != nil { 451 return handleErr 452 } 453 return c.JSON(200, out) 454} 455 456func (s *Server) HandlePlaceStreamServerUpdateWebhook(c echo.Context) error { 457 ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandlePlaceStreamServerUpdateWebhook") 458 defer span.End() 459 460 var body placestreamtypes.ServerUpdateWebhook_Input 461 if err := c.Bind(&body); err != nil { 462 return err 463 } 464 var out *placestreamtypes.ServerUpdateWebhook_Output 465 var handleErr error 466 // func (s *Server) handlePlaceStreamServerUpdateWebhook(ctx context.Context,body *placestreamtypes.ServerUpdateWebhook_Input) (*placestreamtypes.ServerUpdateWebhook_Output, error) 467 out, handleErr = s.handlePlaceStreamServerUpdateWebhook(ctx, &body) 468 if handleErr != nil { 469 return handleErr 470 } 471 return c.JSON(200, out) 472} 473 474func (s *Server) RegisterHandlersToolsOzone(e *echo.Echo) error { 475 return nil 476}