fork of indigo with slightly nicer lexgen
at main 5.4 kB view raw
1// Code generated by cmd/lexgen (see Makefile's lexgen); DO NOT EDIT. 2 3package bsky 4 5// schema: app.bsky.unspecced.getPostThreadV2 6 7import ( 8 "context" 9 "encoding/json" 10 "fmt" 11 12 "github.com/bluesky-social/indigo/lex/util" 13) 14 15// UnspeccedGetPostThreadV2_Output is the output of a app.bsky.unspecced.getPostThreadV2 call. 16type UnspeccedGetPostThreadV2_Output struct { 17 // hasOtherReplies: Whether this thread has additional replies. If true, a call can be made to the `getPostThreadOtherV2` endpoint to retrieve them. 18 HasOtherReplies bool `json:"hasOtherReplies" cborgen:"hasOtherReplies"` 19 // thread: A flat list of thread items. The depth of each item is indicated by the depth property inside the item. 20 Thread []*UnspeccedGetPostThreadV2_ThreadItem `json:"thread" cborgen:"thread"` 21 Threadgate *FeedDefs_ThreadgateView `json:"threadgate,omitempty" cborgen:"threadgate,omitempty"` 22} 23 24// UnspeccedGetPostThreadV2_ThreadItem is a "threadItem" in the app.bsky.unspecced.getPostThreadV2 schema. 25type UnspeccedGetPostThreadV2_ThreadItem struct { 26 // depth: The nesting level of this item in the thread. Depth 0 means the anchor item. Items above have negative depths, items below have positive depths. 27 Depth int64 `json:"depth" cborgen:"depth"` 28 Uri string `json:"uri" cborgen:"uri"` 29 Value *UnspeccedGetPostThreadV2_ThreadItem_Value `json:"value" cborgen:"value"` 30} 31 32type UnspeccedGetPostThreadV2_ThreadItem_Value struct { 33 UnspeccedDefs_ThreadItemPost *UnspeccedDefs_ThreadItemPost 34 UnspeccedDefs_ThreadItemNoUnauthenticated *UnspeccedDefs_ThreadItemNoUnauthenticated 35 UnspeccedDefs_ThreadItemNotFound *UnspeccedDefs_ThreadItemNotFound 36 UnspeccedDefs_ThreadItemBlocked *UnspeccedDefs_ThreadItemBlocked 37} 38 39func (t *UnspeccedGetPostThreadV2_ThreadItem_Value) MarshalJSON() ([]byte, error) { 40 if t.UnspeccedDefs_ThreadItemPost != nil { 41 t.UnspeccedDefs_ThreadItemPost.LexiconTypeID = "app.bsky.unspecced.defs#threadItemPost" 42 return json.Marshal(t.UnspeccedDefs_ThreadItemPost) 43 } 44 if t.UnspeccedDefs_ThreadItemNoUnauthenticated != nil { 45 t.UnspeccedDefs_ThreadItemNoUnauthenticated.LexiconTypeID = "app.bsky.unspecced.defs#threadItemNoUnauthenticated" 46 return json.Marshal(t.UnspeccedDefs_ThreadItemNoUnauthenticated) 47 } 48 if t.UnspeccedDefs_ThreadItemNotFound != nil { 49 t.UnspeccedDefs_ThreadItemNotFound.LexiconTypeID = "app.bsky.unspecced.defs#threadItemNotFound" 50 return json.Marshal(t.UnspeccedDefs_ThreadItemNotFound) 51 } 52 if t.UnspeccedDefs_ThreadItemBlocked != nil { 53 t.UnspeccedDefs_ThreadItemBlocked.LexiconTypeID = "app.bsky.unspecced.defs#threadItemBlocked" 54 return json.Marshal(t.UnspeccedDefs_ThreadItemBlocked) 55 } 56 return nil, fmt.Errorf("cannot marshal empty enum") 57} 58func (t *UnspeccedGetPostThreadV2_ThreadItem_Value) UnmarshalJSON(b []byte) error { 59 typ, err := util.TypeExtract(b) 60 if err != nil { 61 return err 62 } 63 64 switch typ { 65 case "app.bsky.unspecced.defs#threadItemPost": 66 t.UnspeccedDefs_ThreadItemPost = new(UnspeccedDefs_ThreadItemPost) 67 return json.Unmarshal(b, t.UnspeccedDefs_ThreadItemPost) 68 case "app.bsky.unspecced.defs#threadItemNoUnauthenticated": 69 t.UnspeccedDefs_ThreadItemNoUnauthenticated = new(UnspeccedDefs_ThreadItemNoUnauthenticated) 70 return json.Unmarshal(b, t.UnspeccedDefs_ThreadItemNoUnauthenticated) 71 case "app.bsky.unspecced.defs#threadItemNotFound": 72 t.UnspeccedDefs_ThreadItemNotFound = new(UnspeccedDefs_ThreadItemNotFound) 73 return json.Unmarshal(b, t.UnspeccedDefs_ThreadItemNotFound) 74 case "app.bsky.unspecced.defs#threadItemBlocked": 75 t.UnspeccedDefs_ThreadItemBlocked = new(UnspeccedDefs_ThreadItemBlocked) 76 return json.Unmarshal(b, t.UnspeccedDefs_ThreadItemBlocked) 77 78 default: 79 return nil 80 } 81} 82 83// UnspeccedGetPostThreadV2 calls the XRPC method "app.bsky.unspecced.getPostThreadV2". 84// 85// above: Whether to include parents above the anchor. 86// anchor: Reference (AT-URI) to post record. This is the anchor post, and the thread will be built around it. It can be any post in the tree, not necessarily a root post. 87// below: How many levels of replies to include below the anchor. 88// branchingFactor: Maximum of replies to include at each level of the thread, except for the direct replies to the anchor, which are (NOTE: currently, during unspecced phase) all returned (NOTE: later they might be paginated). 89// prioritizeFollowedUsers: Whether to prioritize posts from followed users. It only has effect when the user is authenticated. 90// sort: Sorting for the thread replies. 91func UnspeccedGetPostThreadV2(ctx context.Context, c util.LexClient, above bool, anchor string, below int64, branchingFactor int64, prioritizeFollowedUsers bool, sort string) (*UnspeccedGetPostThreadV2_Output, error) { 92 var out UnspeccedGetPostThreadV2_Output 93 94 params := map[string]interface{}{} 95 if above { 96 params["above"] = above 97 } 98 params["anchor"] = anchor 99 if below != 0 { 100 params["below"] = below 101 } 102 if branchingFactor != 0 { 103 params["branchingFactor"] = branchingFactor 104 } 105 if prioritizeFollowedUsers { 106 params["prioritizeFollowedUsers"] = prioritizeFollowedUsers 107 } 108 if sort != "" { 109 params["sort"] = sort 110 } 111 if err := c.LexDo(ctx, util.Query, "", "app.bsky.unspecced.getPostThreadV2", params, nil, &out); err != nil { 112 return nil, err 113 } 114 115 return &out, nil 116}