Something went wrong. Try again.
This repository has no description
Something went wrong. Try again.
10 kB · 292 lines
Go
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293// Code generated by glex; DO NOT EDIT.
// Lexicon schema: app.bsky.feed.threadgate
package appbsky
import ( "encoding/json" "fmt" "io"
glex "github.com/streamplace/glex/runtime" cbg "github.com/whyrusleeping/cbor-gen")
func init() { glex.RegisterType("app.bsky.feed.threadgate", &FeedThreadgate{})}
// Record defining interaction gating rules for a thread (aka, reply controls). The record key (rkey) of the threadgate record must match the record key of the thread's root post, and that record must be in the same repository.type FeedThreadgate struct { LexiconTypeID string `json:"$type,omitempty"` // 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. Allow []FeedThreadgate_Allow_Elem `json:"allow,omitempty"` CreatedAt string `json:"createdAt"` // hiddenReplies: List of hidden reply URIs. HiddenReplies []string `json:"hiddenReplies,omitempty"` // post: Reference (AT-URI) to the post record. Post string `json:"post"`}
// RecordTypeID implements glex.Record.func (t *FeedThreadgate) RecordTypeID() string { return "app.bsky.feed.threadgate" }
// MarshalJSON stamps the $type field, like MarshalCBOR does. The value// receiver operates on a copy, so the record is never mutated and both// FeedThreadgate and *FeedThreadgate marshal with $type.func (t FeedThreadgate) MarshalJSON() ([]byte, error) { t.LexiconTypeID = "app.bsky.feed.threadgate" type alias FeedThreadgate return json.Marshal((alias)(t))}
func (t *FeedThreadgate) MarshalCBOR(w io.Writer) error { if t == nil { _, err := w.Write(cbg.CborNull) return err } // stamp $type on a copy so marshal never mutates the record cp := *t cp.LexiconTypeID = "app.bsky.feed.threadgate" return glex.MarshalCBOR(w, &cp)}
func (t *FeedThreadgate) UnmarshalCBOR(r io.Reader) error { return glex.UnmarshalCBOR(r, t)}
type FeedThreadgate_Allow_Elem struct { FeedThreadgate_FollowerRule *FeedThreadgate_FollowerRule FeedThreadgate_FollowingRule *FeedThreadgate_FollowingRule FeedThreadgate_ListRule *FeedThreadgate_ListRule FeedThreadgate_MentionRule *FeedThreadgate_MentionRule // Raw preserves a variant whose $type is not in this union's generated // set, so unrecognized variants still round-trip losslessly through // decode/re-encode. Nil when a known variant is set. Raw *glex.RawRecord}
// MarshalJSON emits the set variant, stamped with its $type, per the atproto// union wire format. The value receiver stamps a copy, so the variant is// never mutated and both FeedThreadgate_Allow_Elem and *FeedThreadgate_Allow_Elem marshal correctly.func (t FeedThreadgate_Allow_Elem) MarshalJSON() ([]byte, error) { if t.FeedThreadgate_FollowerRule != nil { cp := *t.FeedThreadgate_FollowerRule cp.LexiconTypeID = "app.bsky.feed.threadgate#followerRule" return json.Marshal(&cp) } if t.FeedThreadgate_FollowingRule != nil { cp := *t.FeedThreadgate_FollowingRule cp.LexiconTypeID = "app.bsky.feed.threadgate#followingRule" return json.Marshal(&cp) } if t.FeedThreadgate_ListRule != nil { cp := *t.FeedThreadgate_ListRule cp.LexiconTypeID = "app.bsky.feed.threadgate#listRule" return json.Marshal(&cp) } if t.FeedThreadgate_MentionRule != nil { cp := *t.FeedThreadgate_MentionRule cp.LexiconTypeID = "app.bsky.feed.threadgate#mentionRule" return json.Marshal(&cp) } if t.Raw != nil { if t.Raw.Encoding != "json" { return nil, fmt.Errorf("cannot marshal raw %s record as JSON in union FeedThreadgate_Allow_Elem", t.Raw.Encoding) } return t.Raw.Bytes, nil } return nil, fmt.Errorf("cannot marshal empty union FeedThreadgate_Allow_Elem as JSON")}
func (t *FeedThreadgate_Allow_Elem) UnmarshalJSON(b []byte) error { typ, err := glex.TypeExtract(b) if err != nil { return err }
switch typ { case "app.bsky.feed.threadgate#followerRule": t.FeedThreadgate_FollowerRule = new(FeedThreadgate_FollowerRule) return json.Unmarshal(b, t.FeedThreadgate_FollowerRule) case "app.bsky.feed.threadgate#followingRule": t.FeedThreadgate_FollowingRule = new(FeedThreadgate_FollowingRule) return json.Unmarshal(b, t.FeedThreadgate_FollowingRule) case "app.bsky.feed.threadgate#listRule": t.FeedThreadgate_ListRule = new(FeedThreadgate_ListRule) return json.Unmarshal(b, t.FeedThreadgate_ListRule) case "app.bsky.feed.threadgate#mentionRule": t.FeedThreadgate_MentionRule = new(FeedThreadgate_MentionRule) return json.Unmarshal(b, t.FeedThreadgate_MentionRule) default: t.Raw = &glex.RawRecord{Type: typ, Encoding: "json", Bytes: append([]byte(nil), b...)} return nil }}
// MarshalCBOR implements drisl.Marshaler, emitting the set variant (stamped// with its $type) per the atproto union wire format. go-dasl invokes this// when the union appears inside another record, so nested unions serialize// correctly.func (t FeedThreadgate_Allow_Elem) MarshalCBOR() ([]byte, error) { if t.FeedThreadgate_FollowerRule != nil { cp := *t.FeedThreadgate_FollowerRule cp.LexiconTypeID = "app.bsky.feed.threadgate#followerRule" return glex.MarshalCBORBytes(&cp) } if t.FeedThreadgate_FollowingRule != nil { cp := *t.FeedThreadgate_FollowingRule cp.LexiconTypeID = "app.bsky.feed.threadgate#followingRule" return glex.MarshalCBORBytes(&cp) } if t.FeedThreadgate_ListRule != nil { cp := *t.FeedThreadgate_ListRule cp.LexiconTypeID = "app.bsky.feed.threadgate#listRule" return glex.MarshalCBORBytes(&cp) } if t.FeedThreadgate_MentionRule != nil { cp := *t.FeedThreadgate_MentionRule cp.LexiconTypeID = "app.bsky.feed.threadgate#mentionRule" return glex.MarshalCBORBytes(&cp) } if t.Raw != nil { if t.Raw.Encoding != "cbor" { return nil, fmt.Errorf("cannot marshal raw %s record as CBOR in union FeedThreadgate_Allow_Elem", t.Raw.Encoding) } return t.Raw.Bytes, nil } return nil, fmt.Errorf("cannot marshal empty union FeedThreadgate_Allow_Elem as CBOR")}
func (t *FeedThreadgate_Allow_Elem) UnmarshalCBOR(b []byte) error { typ, err := glex.CborTypeExtract(b) if err != nil { return err }
switch typ { case "app.bsky.feed.threadgate#followerRule": t.FeedThreadgate_FollowerRule = new(FeedThreadgate_FollowerRule) return glex.UnmarshalCBORBytes(b, t.FeedThreadgate_FollowerRule) case "app.bsky.feed.threadgate#followingRule": t.FeedThreadgate_FollowingRule = new(FeedThreadgate_FollowingRule) return glex.UnmarshalCBORBytes(b, t.FeedThreadgate_FollowingRule) case "app.bsky.feed.threadgate#listRule": t.FeedThreadgate_ListRule = new(FeedThreadgate_ListRule) return glex.UnmarshalCBORBytes(b, t.FeedThreadgate_ListRule) case "app.bsky.feed.threadgate#mentionRule": t.FeedThreadgate_MentionRule = new(FeedThreadgate_MentionRule) return glex.UnmarshalCBORBytes(b, t.FeedThreadgate_MentionRule) default: t.Raw = &glex.RawRecord{Type: typ, Encoding: "cbor", Bytes: append([]byte(nil), b...)} return nil }}
// FeedThreadgate_FollowerRule is a "followerRule" in the app.bsky.feed.threadgate schema.//// Allow replies from actors who follow you.type FeedThreadgate_FollowerRule struct { LexiconTypeID string `json:"$type,omitempty"`}
// RecordTypeID implements glex.Record.func (t *FeedThreadgate_FollowerRule) RecordTypeID() string { return "app.bsky.feed.threadgate#followerRule"}
func (t *FeedThreadgate_FollowerRule) MarshalCBOR(w io.Writer) error { if t == nil { _, err := w.Write(cbg.CborNull) return err } // stamp $type on a copy so marshal never mutates the record cp := *t cp.LexiconTypeID = "app.bsky.feed.threadgate#followerRule" return glex.MarshalCBOR(w, &cp)}
func (t *FeedThreadgate_FollowerRule) UnmarshalCBOR(r io.Reader) error { return glex.UnmarshalCBOR(r, t)}
// FeedThreadgate_FollowingRule is a "followingRule" in the app.bsky.feed.threadgate schema.//// Allow replies from actors you follow.type FeedThreadgate_FollowingRule struct { LexiconTypeID string `json:"$type,omitempty"`}
// RecordTypeID implements glex.Record.func (t *FeedThreadgate_FollowingRule) RecordTypeID() string { return "app.bsky.feed.threadgate#followingRule"}
func (t *FeedThreadgate_FollowingRule) MarshalCBOR(w io.Writer) error { if t == nil { _, err := w.Write(cbg.CborNull) return err } // stamp $type on a copy so marshal never mutates the record cp := *t cp.LexiconTypeID = "app.bsky.feed.threadgate#followingRule" return glex.MarshalCBOR(w, &cp)}
func (t *FeedThreadgate_FollowingRule) UnmarshalCBOR(r io.Reader) error { return glex.UnmarshalCBOR(r, t)}
// FeedThreadgate_ListRule is a "listRule" in the app.bsky.feed.threadgate schema.//// Allow replies from actors on a list.type FeedThreadgate_ListRule struct { LexiconTypeID string `json:"$type,omitempty"` List string `json:"list"`}
// RecordTypeID implements glex.Record.func (t *FeedThreadgate_ListRule) RecordTypeID() string { return "app.bsky.feed.threadgate#listRule" }
func (t *FeedThreadgate_ListRule) MarshalCBOR(w io.Writer) error { if t == nil { _, err := w.Write(cbg.CborNull) return err } // stamp $type on a copy so marshal never mutates the record cp := *t cp.LexiconTypeID = "app.bsky.feed.threadgate#listRule" return glex.MarshalCBOR(w, &cp)}
func (t *FeedThreadgate_ListRule) UnmarshalCBOR(r io.Reader) error { return glex.UnmarshalCBOR(r, t)}
// FeedThreadgate_MentionRule is a "mentionRule" in the app.bsky.feed.threadgate schema.//// Allow replies from actors mentioned in your post.type FeedThreadgate_MentionRule struct { LexiconTypeID string `json:"$type,omitempty"`}
// RecordTypeID implements glex.Record.func (t *FeedThreadgate_MentionRule) RecordTypeID() string { return "app.bsky.feed.threadgate#mentionRule"}
func (t *FeedThreadgate_MentionRule) MarshalCBOR(w io.Writer) error { if t == nil { _, err := w.Write(cbg.CborNull) return err } // stamp $type on a copy so marshal never mutates the record cp := *t cp.LexiconTypeID = "app.bsky.feed.threadgate#mentionRule" return glex.MarshalCBOR(w, &cp)}
func (t *FeedThreadgate_MentionRule) UnmarshalCBOR(r io.Reader) error { return glex.UnmarshalCBOR(r, t)}