1// Code generated by cmd/lexgen (see Makefile's lexgen); DO NOT EDIT.
2
3package bsky
4
5// schema: app.bsky.feed.post
6
7import (
8 "bytes"
9 "encoding/json"
10 "fmt"
11 "io"
12
13 comatprototypes "github.com/bluesky-social/indigo/api/atproto"
14 "github.com/bluesky-social/indigo/lex/util"
15 cbg "github.com/whyrusleeping/cbor-gen"
16)
17
18func init() {
19 util.RegisterType("app.bsky.feed.post", &FeedPost{})
20} //
21// RECORDTYPE: FeedPost
22type FeedPost struct {
23 LexiconTypeID string `json:"$type,const=app.bsky.feed.post" cborgen:"$type,const=app.bsky.feed.post"`
24 // createdAt: Client-declared timestamp when this post was originally created.
25 CreatedAt string `json:"createdAt" cborgen:"createdAt"`
26 Embed *FeedPost_Embed `json:"embed,omitempty" cborgen:"embed,omitempty"`
27 // entities: DEPRECATED: replaced by app.bsky.richtext.facet.
28 Entities []*FeedPost_Entity `json:"entities,omitempty" cborgen:"entities,omitempty"`
29 // facets: Annotations of text (mentions, URLs, hashtags, etc)
30 Facets []*RichtextFacet `json:"facets,omitempty" cborgen:"facets,omitempty"`
31 // labels: Self-label values for this post. Effectively content warnings.
32 Labels *FeedPost_Labels `json:"labels,omitempty" cborgen:"labels,omitempty"`
33 // langs: Indicates human language of post primary text content.
34 Langs []string `json:"langs,omitempty" cborgen:"langs,omitempty"`
35 Reply *FeedPost_ReplyRef `json:"reply,omitempty" cborgen:"reply,omitempty"`
36 // tags: Additional hashtags, in addition to any included in post text and facets.
37 Tags []string `json:"tags,omitempty" cborgen:"tags,omitempty"`
38 // text: The primary post content. May be an empty string, if there are embeds.
39 Text string `json:"text" cborgen:"text"`
40}
41
42type FeedPost_Embed struct {
43 EmbedImages *EmbedImages
44 EmbedVideo *EmbedVideo
45 EmbedExternal *EmbedExternal
46 EmbedRecord *EmbedRecord
47 EmbedRecordWithMedia *EmbedRecordWithMedia
48}
49
50func (t *FeedPost_Embed) MarshalJSON() ([]byte, error) {
51 if t.EmbedImages != nil {
52 t.EmbedImages.LexiconTypeID = "app.bsky.embed.images"
53 return json.Marshal(t.EmbedImages)
54 }
55 if t.EmbedVideo != nil {
56 t.EmbedVideo.LexiconTypeID = "app.bsky.embed.video"
57 return json.Marshal(t.EmbedVideo)
58 }
59 if t.EmbedExternal != nil {
60 t.EmbedExternal.LexiconTypeID = "app.bsky.embed.external"
61 return json.Marshal(t.EmbedExternal)
62 }
63 if t.EmbedRecord != nil {
64 t.EmbedRecord.LexiconTypeID = "app.bsky.embed.record"
65 return json.Marshal(t.EmbedRecord)
66 }
67 if t.EmbedRecordWithMedia != nil {
68 t.EmbedRecordWithMedia.LexiconTypeID = "app.bsky.embed.recordWithMedia"
69 return json.Marshal(t.EmbedRecordWithMedia)
70 }
71 return nil, fmt.Errorf("cannot marshal empty enum")
72}
73func (t *FeedPost_Embed) UnmarshalJSON(b []byte) error {
74 typ, err := util.TypeExtract(b)
75 if err != nil {
76 return err
77 }
78
79 switch typ {
80 case "app.bsky.embed.images":
81 t.EmbedImages = new(EmbedImages)
82 return json.Unmarshal(b, t.EmbedImages)
83 case "app.bsky.embed.video":
84 t.EmbedVideo = new(EmbedVideo)
85 return json.Unmarshal(b, t.EmbedVideo)
86 case "app.bsky.embed.external":
87 t.EmbedExternal = new(EmbedExternal)
88 return json.Unmarshal(b, t.EmbedExternal)
89 case "app.bsky.embed.record":
90 t.EmbedRecord = new(EmbedRecord)
91 return json.Unmarshal(b, t.EmbedRecord)
92 case "app.bsky.embed.recordWithMedia":
93 t.EmbedRecordWithMedia = new(EmbedRecordWithMedia)
94 return json.Unmarshal(b, t.EmbedRecordWithMedia)
95
96 default:
97 return nil
98 }
99}
100
101func (t *FeedPost_Embed) MarshalCBOR(w io.Writer) error {
102
103 if t == nil {
104 _, err := w.Write(cbg.CborNull)
105 return err
106 }
107 if t.EmbedImages != nil {
108 return t.EmbedImages.MarshalCBOR(w)
109 }
110 if t.EmbedVideo != nil {
111 return t.EmbedVideo.MarshalCBOR(w)
112 }
113 if t.EmbedExternal != nil {
114 return t.EmbedExternal.MarshalCBOR(w)
115 }
116 if t.EmbedRecord != nil {
117 return t.EmbedRecord.MarshalCBOR(w)
118 }
119 if t.EmbedRecordWithMedia != nil {
120 return t.EmbedRecordWithMedia.MarshalCBOR(w)
121 }
122 return fmt.Errorf("cannot cbor marshal empty enum")
123}
124func (t *FeedPost_Embed) UnmarshalCBOR(r io.Reader) error {
125 typ, b, err := util.CborTypeExtractReader(r)
126 if err != nil {
127 return err
128 }
129
130 switch typ {
131 case "app.bsky.embed.images":
132 t.EmbedImages = new(EmbedImages)
133 return t.EmbedImages.UnmarshalCBOR(bytes.NewReader(b))
134 case "app.bsky.embed.video":
135 t.EmbedVideo = new(EmbedVideo)
136 return t.EmbedVideo.UnmarshalCBOR(bytes.NewReader(b))
137 case "app.bsky.embed.external":
138 t.EmbedExternal = new(EmbedExternal)
139 return t.EmbedExternal.UnmarshalCBOR(bytes.NewReader(b))
140 case "app.bsky.embed.record":
141 t.EmbedRecord = new(EmbedRecord)
142 return t.EmbedRecord.UnmarshalCBOR(bytes.NewReader(b))
143 case "app.bsky.embed.recordWithMedia":
144 t.EmbedRecordWithMedia = new(EmbedRecordWithMedia)
145 return t.EmbedRecordWithMedia.UnmarshalCBOR(bytes.NewReader(b))
146
147 default:
148 return nil
149 }
150}
151
152// FeedPost_Entity is a "entity" in the app.bsky.feed.post schema.
153//
154// Deprecated: use facets instead.
155type FeedPost_Entity struct {
156 Index *FeedPost_TextSlice `json:"index" cborgen:"index"`
157 // type: Expected values are 'mention' and 'link'.
158 Type string `json:"type" cborgen:"type"`
159 Value string `json:"value" cborgen:"value"`
160}
161
162// Self-label values for this post. Effectively content warnings.
163type FeedPost_Labels struct {
164 LabelDefs_SelfLabels *comatprototypes.LabelDefs_SelfLabels
165}
166
167func (t *FeedPost_Labels) MarshalJSON() ([]byte, error) {
168 if t.LabelDefs_SelfLabels != nil {
169 t.LabelDefs_SelfLabels.LexiconTypeID = "com.atproto.label.defs#selfLabels"
170 return json.Marshal(t.LabelDefs_SelfLabels)
171 }
172 return nil, fmt.Errorf("cannot marshal empty enum")
173}
174func (t *FeedPost_Labels) UnmarshalJSON(b []byte) error {
175 typ, err := util.TypeExtract(b)
176 if err != nil {
177 return err
178 }
179
180 switch typ {
181 case "com.atproto.label.defs#selfLabels":
182 t.LabelDefs_SelfLabels = new(comatprototypes.LabelDefs_SelfLabels)
183 return json.Unmarshal(b, t.LabelDefs_SelfLabels)
184
185 default:
186 return nil
187 }
188}
189
190func (t *FeedPost_Labels) MarshalCBOR(w io.Writer) error {
191
192 if t == nil {
193 _, err := w.Write(cbg.CborNull)
194 return err
195 }
196 if t.LabelDefs_SelfLabels != nil {
197 return t.LabelDefs_SelfLabels.MarshalCBOR(w)
198 }
199 return fmt.Errorf("cannot cbor marshal empty enum")
200}
201func (t *FeedPost_Labels) UnmarshalCBOR(r io.Reader) error {
202 typ, b, err := util.CborTypeExtractReader(r)
203 if err != nil {
204 return err
205 }
206
207 switch typ {
208 case "com.atproto.label.defs#selfLabels":
209 t.LabelDefs_SelfLabels = new(comatprototypes.LabelDefs_SelfLabels)
210 return t.LabelDefs_SelfLabels.UnmarshalCBOR(bytes.NewReader(b))
211
212 default:
213 return nil
214 }
215}
216
217// FeedPost_ReplyRef is a "replyRef" in the app.bsky.feed.post schema.
218type FeedPost_ReplyRef struct {
219 Parent *comatprototypes.RepoStrongRef `json:"parent" cborgen:"parent"`
220 Root *comatprototypes.RepoStrongRef `json:"root" cborgen:"root"`
221}
222
223// FeedPost_TextSlice is a "textSlice" in the app.bsky.feed.post schema.
224//
225// Deprecated. Use app.bsky.richtext instead -- A text segment. Start is inclusive, end is exclusive. Indices are for utf16-encoded strings.
226type FeedPost_TextSlice struct {
227 End int64 `json:"end" cborgen:"end"`
228 Start int64 `json:"start" cborgen:"start"`
229}