1// Code generated by cmd/lexgen (see Makefile's lexgen); DO NOT EDIT.
2
3package bsky
4
5// schema: app.bsky.feed.postgate
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.postgate", &FeedPostgate{})
19} //
20// RECORDTYPE: FeedPostgate
21type FeedPostgate struct {
22 LexiconTypeID string `json:"$type,const=app.bsky.feed.postgate" cborgen:"$type,const=app.bsky.feed.postgate"`
23 CreatedAt string `json:"createdAt" cborgen:"createdAt"`
24 // detachedEmbeddingUris: List of AT-URIs embedding this post that the author has detached from.
25 DetachedEmbeddingUris []string `json:"detachedEmbeddingUris,omitempty" cborgen:"detachedEmbeddingUris,omitempty"`
26 // embeddingRules: List of rules defining who can embed this post. If value is an empty array or is undefined, no particular rules apply and anyone can embed.
27 EmbeddingRules []*FeedPostgate_EmbeddingRules_Elem `json:"embeddingRules,omitempty" cborgen:"embeddingRules,omitempty"`
28 // post: Reference (AT-URI) to the post record.
29 Post string `json:"post" cborgen:"post"`
30}
31
32// FeedPostgate_DisableRule is a "disableRule" in the app.bsky.feed.postgate schema.
33//
34// Disables embedding of this post.
35//
36// RECORDTYPE: FeedPostgate_DisableRule
37type FeedPostgate_DisableRule struct {
38 LexiconTypeID string `json:"$type,const=app.bsky.feed.postgate#disableRule" cborgen:"$type,const=app.bsky.feed.postgate#disableRule"`
39}
40
41type FeedPostgate_EmbeddingRules_Elem struct {
42 FeedPostgate_DisableRule *FeedPostgate_DisableRule
43}
44
45func (t *FeedPostgate_EmbeddingRules_Elem) MarshalJSON() ([]byte, error) {
46 if t.FeedPostgate_DisableRule != nil {
47 t.FeedPostgate_DisableRule.LexiconTypeID = "app.bsky.feed.postgate#disableRule"
48 return json.Marshal(t.FeedPostgate_DisableRule)
49 }
50 return nil, fmt.Errorf("cannot marshal empty enum")
51}
52func (t *FeedPostgate_EmbeddingRules_Elem) UnmarshalJSON(b []byte) error {
53 typ, err := util.TypeExtract(b)
54 if err != nil {
55 return err
56 }
57
58 switch typ {
59 case "app.bsky.feed.postgate#disableRule":
60 t.FeedPostgate_DisableRule = new(FeedPostgate_DisableRule)
61 return json.Unmarshal(b, t.FeedPostgate_DisableRule)
62
63 default:
64 return nil
65 }
66}
67
68func (t *FeedPostgate_EmbeddingRules_Elem) MarshalCBOR(w io.Writer) error {
69
70 if t == nil {
71 _, err := w.Write(cbg.CborNull)
72 return err
73 }
74 if t.FeedPostgate_DisableRule != nil {
75 return t.FeedPostgate_DisableRule.MarshalCBOR(w)
76 }
77 return fmt.Errorf("cannot cbor marshal empty enum")
78}
79func (t *FeedPostgate_EmbeddingRules_Elem) UnmarshalCBOR(r io.Reader) error {
80 typ, b, err := util.CborTypeExtractReader(r)
81 if err != nil {
82 return err
83 }
84
85 switch typ {
86 case "app.bsky.feed.postgate#disableRule":
87 t.FeedPostgate_DisableRule = new(FeedPostgate_DisableRule)
88 return t.FeedPostgate_DisableRule.UnmarshalCBOR(bytes.NewReader(b))
89
90 default:
91 return nil
92 }
93}