Live video on the AT Protocol
79
fork

Configure Feed

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

at eli/further-gitlab-ci 173 lines 6.2 kB view raw
1package spxrpc 2 3import ( 4 "strconv" 5 6 comatprototypes "github.com/bluesky-social/indigo/api/atproto" 7 appbskytypes "github.com/bluesky-social/indigo/api/bsky" 8 "github.com/labstack/echo/v4" 9 "go.opentelemetry.io/otel" 10 placestreamtypes "stream.place/streamplace/pkg/streamplace" 11) 12 13func (s *Server) RegisterHandlersAppBsky(e *echo.Echo) error { 14 e.GET("/xrpc/app.bsky.actor.getProfile", s.HandleAppBskyActorGetProfile) 15 e.GET("/xrpc/app.bsky.feed.getFeedSkeleton", s.HandleAppBskyFeedGetFeedSkeleton) 16 return nil 17} 18 19func (s *Server) HandleAppBskyActorGetProfile(c echo.Context) error { 20 ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleAppBskyActorGetProfile") 21 defer span.End() 22 actor := c.QueryParam("actor") 23 var out *appbskytypes.ActorDefs_ProfileViewDetailed 24 var handleErr error 25 // func (s *Server) handleAppBskyActorGetProfile(ctx context.Context,actor string) (*appbskytypes.ActorDefs_ProfileViewDetailed, error) 26 out, handleErr = s.handleAppBskyActorGetProfile(ctx, actor) 27 if handleErr != nil { 28 return handleErr 29 } 30 return c.JSON(200, out) 31} 32 33func (s *Server) HandleAppBskyFeedGetFeedSkeleton(c echo.Context) error { 34 ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleAppBskyFeedGetFeedSkeleton") 35 defer span.End() 36 cursor := c.QueryParam("cursor") 37 feed := c.QueryParam("feed") 38 39 var limit int 40 if p := c.QueryParam("limit"); p != "" { 41 var err error 42 limit, err = strconv.Atoi(p) 43 if err != nil { 44 return err 45 } 46 } else { 47 limit = 50 48 } 49 var out *appbskytypes.FeedGetFeedSkeleton_Output 50 var handleErr error 51 // func (s *Server) handleAppBskyFeedGetFeedSkeleton(ctx context.Context,cursor string,feed string,limit int) (*appbskytypes.FeedGetFeedSkeleton_Output, error) 52 out, handleErr = s.handleAppBskyFeedGetFeedSkeleton(ctx, cursor, feed, limit) 53 if handleErr != nil { 54 return handleErr 55 } 56 return c.JSON(200, out) 57} 58 59func (s *Server) RegisterHandlersChatBsky(e *echo.Echo) error { 60 return nil 61} 62 63func (s *Server) RegisterHandlersComAtproto(e *echo.Echo) error { 64 e.GET("/xrpc/com.atproto.identity.resolveHandle", s.HandleComAtprotoIdentityResolveHandle) 65 e.POST("/xrpc/com.atproto.repo.uploadBlob", s.HandleComAtprotoRepoUploadBlob) 66 return nil 67} 68 69func (s *Server) HandleComAtprotoIdentityResolveHandle(c echo.Context) error { 70 ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleComAtprotoIdentityResolveHandle") 71 defer span.End() 72 handle := c.QueryParam("handle") 73 var out *comatprototypes.IdentityResolveHandle_Output 74 var handleErr error 75 // func (s *Server) handleComAtprotoIdentityResolveHandle(ctx context.Context,handle string) (*comatprototypes.IdentityResolveHandle_Output, error) 76 out, handleErr = s.handleComAtprotoIdentityResolveHandle(ctx, handle) 77 if handleErr != nil { 78 return handleErr 79 } 80 return c.JSON(200, out) 81} 82 83func (s *Server) HandleComAtprotoRepoUploadBlob(c echo.Context) error { 84 ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandleComAtprotoRepoUploadBlob") 85 defer span.End() 86 body := c.Request().Body 87 contentType := c.Request().Header.Get("Content-Type") 88 var out *comatprototypes.RepoUploadBlob_Output 89 var handleErr error 90 // func (s *Server) handleComAtprotoRepoUploadBlob(ctx context.Context,r io.Reader,contentType string) (*comatprototypes.RepoUploadBlob_Output, error) 91 out, handleErr = s.handleComAtprotoRepoUploadBlob(ctx, body, contentType) 92 if handleErr != nil { 93 return handleErr 94 } 95 return c.JSON(200, out) 96} 97 98func (s *Server) RegisterHandlersPlaceStream(e *echo.Echo) error { 99 e.GET("/xrpc/place.stream.graph.getFollowingUser", s.HandlePlaceStreamGraphGetFollowingUser) 100 e.GET("/xrpc/place.stream.live.getLiveUsers", s.HandlePlaceStreamLiveGetLiveUsers) 101 e.GET("/xrpc/place.stream.live.getSegments", s.HandlePlaceStreamLiveGetSegments) 102 return nil 103} 104 105func (s *Server) HandlePlaceStreamGraphGetFollowingUser(c echo.Context) error { 106 ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandlePlaceStreamGraphGetFollowingUser") 107 defer span.End() 108 subjectDID := c.QueryParam("subjectDID") 109 userDID := c.QueryParam("userDID") 110 var out *placestreamtypes.GraphGetFollowingUser_Output 111 var handleErr error 112 // func (s *Server) handlePlaceStreamGraphGetFollowingUser(ctx context.Context,subjectDID string,userDID string) (*placestreamtypes.GraphGetFollowingUser_Output, error) 113 out, handleErr = s.handlePlaceStreamGraphGetFollowingUser(ctx, subjectDID, userDID) 114 if handleErr != nil { 115 return handleErr 116 } 117 return c.JSON(200, out) 118} 119 120func (s *Server) HandlePlaceStreamLiveGetLiveUsers(c echo.Context) error { 121 ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandlePlaceStreamLiveGetLiveUsers") 122 defer span.End() 123 before := c.QueryParam("before") 124 125 var limit int 126 if p := c.QueryParam("limit"); p != "" { 127 var err error 128 limit, err = strconv.Atoi(p) 129 if err != nil { 130 return err 131 } 132 } else { 133 limit = 50 134 } 135 var out *placestreamtypes.LiveGetLiveUsers_Output 136 var handleErr error 137 // func (s *Server) handlePlaceStreamLiveGetLiveUsers(ctx context.Context,before string,limit int) (*placestreamtypes.LiveGetLiveUsers_Output, error) 138 out, handleErr = s.handlePlaceStreamLiveGetLiveUsers(ctx, before, limit) 139 if handleErr != nil { 140 return handleErr 141 } 142 return c.JSON(200, out) 143} 144 145func (s *Server) HandlePlaceStreamLiveGetSegments(c echo.Context) error { 146 ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandlePlaceStreamLiveGetSegments") 147 defer span.End() 148 before := c.QueryParam("before") 149 150 var limit int 151 if p := c.QueryParam("limit"); p != "" { 152 var err error 153 limit, err = strconv.Atoi(p) 154 if err != nil { 155 return err 156 } 157 } else { 158 limit = 50 159 } 160 userDID := c.QueryParam("userDID") 161 var out *placestreamtypes.LiveGetSegments_Output 162 var handleErr error 163 // func (s *Server) handlePlaceStreamLiveGetSegments(ctx context.Context,before string,limit int,userDID string) (*placestreamtypes.LiveGetSegments_Output, error) 164 out, handleErr = s.handlePlaceStreamLiveGetSegments(ctx, before, limit, userDID) 165 if handleErr != nil { 166 return handleErr 167 } 168 return c.JSON(200, out) 169} 170 171func (s *Server) RegisterHandlersToolsOzone(e *echo.Echo) error { 172 return nil 173}