A fork of https://github.com/teal-fm/piper
1// Code generated by cmd/lexgen (see Makefile's lexgen); DO NOT EDIT.
2
3package bsky
4
5// schema: app.bsky.feed.threadgate
6
7import (
8 "bytes"
9 "encoding/json"
10 "fmt"
11 "io"
12
13 "github.com/bluesky-social/indigo/lex/util"
14 cbg "github.com/whyrusleeping/cbor-gen"
15)
16
17func init() {
18 util.RegisterType("app.bsky.feed.threadgate", &FeedThreadgate{})
19} //
20// RECORDTYPE: FeedThreadgate
21type FeedThreadgate struct {
22 LexiconTypeID string `json:"$type,const=app.bsky.feed.threadgate" cborgen:"$type,const=app.bsky.feed.threadgate"`
23 // allow: List of rules defining who can reply to this post. If value is an empty array, no one can reply. If value is undefined, anyone can reply.
24 Allow []*FeedThreadgate_Allow_Elem `json:"allow,omitempty" cborgen:"allow,omitempty"`
25 CreatedAt string `json:"createdAt" cborgen:"createdAt"`
26 // hiddenReplies: List of hidden reply URIs.
27 HiddenReplies []string `json:"hiddenReplies,omitempty" cborgen:"hiddenReplies,omitempty"`
28 // post: Reference (AT-URI) to the post record.
29 Post string `json:"post" cborgen:"post"`
30}
31
32type FeedThreadgate_Allow_Elem struct {
33 FeedThreadgate_MentionRule *FeedThreadgate_MentionRule
34 FeedThreadgate_FollowerRule *FeedThreadgate_FollowerRule
35 FeedThreadgate_FollowingRule *FeedThreadgate_FollowingRule
36 FeedThreadgate_ListRule *FeedThreadgate_ListRule
37}
38
39func (t *FeedThreadgate_Allow_Elem) MarshalJSON() ([]byte, error) {
40 if t.FeedThreadgate_MentionRule != nil {
41 t.FeedThreadgate_MentionRule.LexiconTypeID = "app.bsky.feed.threadgate#mentionRule"
42 return json.Marshal(t.FeedThreadgate_MentionRule)
43 }
44 if t.FeedThreadgate_FollowerRule != nil {
45 t.FeedThreadgate_FollowerRule.LexiconTypeID = "app.bsky.feed.threadgate#followerRule"
46 return json.Marshal(t.FeedThreadgate_FollowerRule)
47 }
48 if t.FeedThreadgate_FollowingRule != nil {
49 t.FeedThreadgate_FollowingRule.LexiconTypeID = "app.bsky.feed.threadgate#followingRule"
50 return json.Marshal(t.FeedThreadgate_FollowingRule)
51 }
52 if t.FeedThreadgate_ListRule != nil {
53 t.FeedThreadgate_ListRule.LexiconTypeID = "app.bsky.feed.threadgate#listRule"
54 return json.Marshal(t.FeedThreadgate_ListRule)
55 }
56 return nil, fmt.Errorf("cannot marshal empty enum")
57}
58func (t *FeedThreadgate_Allow_Elem) 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.feed.threadgate#mentionRule":
66 t.FeedThreadgate_MentionRule = new(FeedThreadgate_MentionRule)
67 return json.Unmarshal(b, t.FeedThreadgate_MentionRule)
68 case "app.bsky.feed.threadgate#followerRule":
69 t.FeedThreadgate_FollowerRule = new(FeedThreadgate_FollowerRule)
70 return json.Unmarshal(b, t.FeedThreadgate_FollowerRule)
71 case "app.bsky.feed.threadgate#followingRule":
72 t.FeedThreadgate_FollowingRule = new(FeedThreadgate_FollowingRule)
73 return json.Unmarshal(b, t.FeedThreadgate_FollowingRule)
74 case "app.bsky.feed.threadgate#listRule":
75 t.FeedThreadgate_ListRule = new(FeedThreadgate_ListRule)
76 return json.Unmarshal(b, t.FeedThreadgate_ListRule)
77
78 default:
79 return nil
80 }
81}
82
83func (t *FeedThreadgate_Allow_Elem) MarshalCBOR(w io.Writer) error {
84
85 if t == nil {
86 _, err := w.Write(cbg.CborNull)
87 return err
88 }
89 if t.FeedThreadgate_MentionRule != nil {
90 return t.FeedThreadgate_MentionRule.MarshalCBOR(w)
91 }
92 if t.FeedThreadgate_FollowerRule != nil {
93 return t.FeedThreadgate_FollowerRule.MarshalCBOR(w)
94 }
95 if t.FeedThreadgate_FollowingRule != nil {
96 return t.FeedThreadgate_FollowingRule.MarshalCBOR(w)
97 }
98 if t.FeedThreadgate_ListRule != nil {
99 return t.FeedThreadgate_ListRule.MarshalCBOR(w)
100 }
101 return fmt.Errorf("cannot cbor marshal empty enum")
102}
103func (t *FeedThreadgate_Allow_Elem) UnmarshalCBOR(r io.Reader) error {
104 typ, b, err := util.CborTypeExtractReader(r)
105 if err != nil {
106 return err
107 }
108
109 switch typ {
110 case "app.bsky.feed.threadgate#mentionRule":
111 t.FeedThreadgate_MentionRule = new(FeedThreadgate_MentionRule)
112 return t.FeedThreadgate_MentionRule.UnmarshalCBOR(bytes.NewReader(b))
113 case "app.bsky.feed.threadgate#followerRule":
114 t.FeedThreadgate_FollowerRule = new(FeedThreadgate_FollowerRule)
115 return t.FeedThreadgate_FollowerRule.UnmarshalCBOR(bytes.NewReader(b))
116 case "app.bsky.feed.threadgate#followingRule":
117 t.FeedThreadgate_FollowingRule = new(FeedThreadgate_FollowingRule)
118 return t.FeedThreadgate_FollowingRule.UnmarshalCBOR(bytes.NewReader(b))
119 case "app.bsky.feed.threadgate#listRule":
120 t.FeedThreadgate_ListRule = new(FeedThreadgate_ListRule)
121 return t.FeedThreadgate_ListRule.UnmarshalCBOR(bytes.NewReader(b))
122
123 default:
124 return nil
125 }
126}
127
128// FeedThreadgate_FollowerRule is a "followerRule" in the app.bsky.feed.threadgate schema.
129//
130// Allow replies from actors who follow you.
131//
132// RECORDTYPE: FeedThreadgate_FollowerRule
133type FeedThreadgate_FollowerRule struct {
134 LexiconTypeID string `json:"$type,const=app.bsky.feed.threadgate#followerRule" cborgen:"$type,const=app.bsky.feed.threadgate#followerRule"`
135}
136
137// FeedThreadgate_FollowingRule is a "followingRule" in the app.bsky.feed.threadgate schema.
138//
139// Allow replies from actors you follow.
140//
141// RECORDTYPE: FeedThreadgate_FollowingRule
142type FeedThreadgate_FollowingRule struct {
143 LexiconTypeID string `json:"$type,const=app.bsky.feed.threadgate#followingRule" cborgen:"$type,const=app.bsky.feed.threadgate#followingRule"`
144}
145
146// FeedThreadgate_ListRule is a "listRule" in the app.bsky.feed.threadgate schema.
147//
148// Allow replies from actors on a list.
149//
150// RECORDTYPE: FeedThreadgate_ListRule
151type FeedThreadgate_ListRule struct {
152 LexiconTypeID string `json:"$type,const=app.bsky.feed.threadgate#listRule" cborgen:"$type,const=app.bsky.feed.threadgate#listRule"`
153 List string `json:"list" cborgen:"list"`
154}
155
156// FeedThreadgate_MentionRule is a "mentionRule" in the app.bsky.feed.threadgate schema.
157//
158// Allow replies from actors mentioned in your post.
159//
160// RECORDTYPE: FeedThreadgate_MentionRule
161type FeedThreadgate_MentionRule struct {
162 LexiconTypeID string `json:"$type,const=app.bsky.feed.threadgate#mentionRule" cborgen:"$type,const=app.bsky.feed.threadgate#mentionRule"`
163}