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