Live video on the AT Protocol

lexicons: add getFollowingUser query

authored by

Eli Mallon and committed by 10xcrazy.horse 938218f4 2c5634e2

+169
+74
js/docs/src/content/docs/lex-reference/graph/place-stream-graph-getfollowinguser.md
··· 1 + --- 2 + title: place.stream.graph.getFollowingUser 3 + description: Reference for the place.stream.graph.getFollowingUser lexicon 4 + --- 5 + 6 + **Lexicon Version:** 1 7 + 8 + ## Definitions 9 + 10 + <a name="main"></a> 11 + 12 + ### `main` 13 + 14 + **Type:** `query` 15 + 16 + Get whether or not you're following a user. 17 + 18 + **Parameters:** 19 + 20 + | Name | Type | Req'd | Description | Constraints | 21 + | ------------ | -------- | ----- | ---------------------------------------------------------- | ------------- | 22 + | `subjectDID` | `string` | ✅ | The DID of the user you want to check if you're following. | Format: `did` | 23 + 24 + **Output:** 25 + 26 + - **Encoding:** `application/json` 27 + - **Schema:** 28 + 29 + **Schema Type:** `object` 30 + 31 + | Name | Type | Req'd | Description | Constraints | 32 + | -------- | -------------------------------------------------------------------------------------------------------------------------------------- | ----- | ----------- | ----------- | 33 + | `follow` | [`com.atproto.repo.strongRef`](https://github.com/bluesky-social/atproto/tree/main/lexicons/com/atproto/repo/strongref.json#undefined) | ❌ | | | 34 + 35 + --- 36 + 37 + ## Lexicon Source 38 + 39 + ```json 40 + { 41 + "lexicon": 1, 42 + "id": "place.stream.graph.getFollowingUser", 43 + "defs": { 44 + "main": { 45 + "type": "query", 46 + "description": "Get whether or not you're following a user.", 47 + "parameters": { 48 + "type": "params", 49 + "required": ["subjectDID"], 50 + "properties": { 51 + "subjectDID": { 52 + "type": "string", 53 + "format": "did", 54 + "description": "The DID of the user you want to check if you're following." 55 + } 56 + } 57 + }, 58 + "output": { 59 + "encoding": "application/json", 60 + "schema": { 61 + "type": "object", 62 + "required": [], 63 + "properties": { 64 + "follow": { 65 + "type": "ref", 66 + "ref": "com.atproto.repo.strongRef" 67 + } 68 + } 69 + } 70 + } 71 + } 72 + } 73 + } 74 + ```
+34
lexicons/place/stream/graph/getFollowingUser.json
··· 1 + { 2 + "lexicon": 1, 3 + "id": "place.stream.graph.getFollowingUser", 4 + "defs": { 5 + "main": { 6 + "type": "query", 7 + "description": "Get whether or not you're following a user.", 8 + "parameters": { 9 + "type": "params", 10 + "required": ["subjectDID"], 11 + "properties": { 12 + "subjectDID": { 13 + "type": "string", 14 + "format": "did", 15 + "description": "The DID of the user you want to check if you're following." 16 + } 17 + } 18 + }, 19 + "output": { 20 + "encoding": "application/json", 21 + "schema": { 22 + "type": "object", 23 + "required": [], 24 + "properties": { 25 + "follow": { 26 + "type": "ref", 27 + "ref": "com.atproto.repo.strongRef" 28 + } 29 + } 30 + } 31 + } 32 + } 33 + } 34 + }
+12
pkg/spxrpc/graph.go
··· 1 + package spxrpc 2 + 3 + import ( 4 + "context" 5 + 6 + placestreamtypes "stream.place/streamplace/pkg/streamplace" 7 + ) 8 + 9 + func (s *Server) handlePlaceStreamGraphGetFollowingUser(ctx context.Context, subjectDID string) (*placestreamtypes.GraphGetFollowingUser_Output, error) { 10 + // this is where following check needs to be implemented 11 + return nil, nil 12 + }
+16
pkg/spxrpc/stubs.go
··· 6 6 appbskytypes "github.com/bluesky-social/indigo/api/bsky" 7 7 "github.com/labstack/echo/v4" 8 8 "go.opentelemetry.io/otel" 9 + placestreamtypes "stream.place/streamplace/pkg/streamplace" 9 10 ) 10 11 11 12 func (s *Server) RegisterHandlersAppBsky(e *echo.Echo) error { ··· 48 49 } 49 50 50 51 func (s *Server) RegisterHandlersPlaceStream(e *echo.Echo) error { 52 + e.GET("/xrpc/place.stream.graph.getFollowingUser", s.HandlePlaceStreamGraphGetFollowingUser) 51 53 return nil 54 + } 55 + 56 + func (s *Server) HandlePlaceStreamGraphGetFollowingUser(c echo.Context) error { 57 + ctx, span := otel.Tracer("server").Start(c.Request().Context(), "HandlePlaceStreamGraphGetFollowingUser") 58 + defer span.End() 59 + subjectDID := c.QueryParam("subjectDID") 60 + var out *placestreamtypes.GraphGetFollowingUser_Output 61 + var handleErr error 62 + // func (s *Server) handlePlaceStreamGraphGetFollowingUser(ctx context.Context,subjectDID string) (*placestreamtypes.GraphGetFollowingUser_Output, error) 63 + out, handleErr = s.handlePlaceStreamGraphGetFollowingUser(ctx, subjectDID) 64 + if handleErr != nil { 65 + return handleErr 66 + } 67 + return c.JSON(200, out) 52 68 } 53 69 54 70 func (s *Server) RegisterHandlersToolsOzone(e *echo.Echo) error {
+33
pkg/streamplace/graphgetFollowingUser.go
··· 1 + // Code generated by cmd/lexgen (see Makefile's lexgen); DO NOT EDIT. 2 + 3 + package streamplace 4 + 5 + // schema: place.stream.graph.getFollowingUser 6 + 7 + import ( 8 + "context" 9 + 10 + comatprototypes "github.com/bluesky-social/indigo/api/atproto" 11 + "github.com/bluesky-social/indigo/xrpc" 12 + ) 13 + 14 + // GraphGetFollowingUser_Output is the output of a place.stream.graph.getFollowingUser call. 15 + type GraphGetFollowingUser_Output struct { 16 + Follow *comatprototypes.RepoStrongRef `json:"follow,omitempty" cborgen:"follow,omitempty"` 17 + } 18 + 19 + // GraphGetFollowingUser calls the XRPC method "place.stream.graph.getFollowingUser". 20 + // 21 + // subjectDID: The DID of the user you want to check if you're following. 22 + func GraphGetFollowingUser(ctx context.Context, c *xrpc.Client, subjectDID string) (*GraphGetFollowingUser_Output, error) { 23 + var out GraphGetFollowingUser_Output 24 + 25 + params := map[string]interface{}{ 26 + "subjectDID": subjectDID, 27 + } 28 + if err := c.Do(ctx, xrpc.Query, "", "place.stream.graph.getFollowingUser", params, nil, &out); err != nil { 29 + return nil, err 30 + } 31 + 32 + return &out, nil 33 + }