Monorepo for Tangled
tangled.org
1// Code generated by cmd/lexgen (see Makefile's lexgen); DO NOT EDIT.
2
3package tangled
4
5// schema: sh.tangled.feed.comment
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
18const (
19 FeedCommentNSID = "sh.tangled.feed.comment"
20)
21
22func init() {
23 util.RegisterType("sh.tangled.feed.comment", &FeedComment{})
24} //
25// RECORDTYPE: FeedComment
26type FeedComment struct {
27 LexiconTypeID string `json:"$type,const=sh.tangled.feed.comment" cborgen:"$type,const=sh.tangled.feed.comment"`
28 Body *FeedComment_Body `json:"body" cborgen:"body"`
29 CreatedAt string `json:"createdAt" cborgen:"createdAt"`
30 // pullRoundIdx: optional pull submission round index. required when subject is sh.tangled.repo.pull
31 PullRoundIdx *int64 `json:"pullRoundIdx,omitempty" cborgen:"pullRoundIdx,omitempty"`
32 ReplyTo *comatprototypes.RepoStrongRef `json:"replyTo,omitempty" cborgen:"replyTo,omitempty"`
33 Subject *comatprototypes.RepoStrongRef `json:"subject" cborgen:"subject"`
34}
35
36type FeedComment_Body struct {
37 MarkupMarkdown *MarkupMarkdown
38}
39
40func (t *FeedComment_Body) MarshalJSON() ([]byte, error) {
41 if t.MarkupMarkdown != nil {
42 t.MarkupMarkdown.LexiconTypeID = "sh.tangled.markup.markdown"
43 return json.Marshal(t.MarkupMarkdown)
44 }
45 return nil, fmt.Errorf("cannot marshal empty enum")
46}
47func (t *FeedComment_Body) UnmarshalJSON(b []byte) error {
48 typ, err := util.TypeExtract(b)
49 if err != nil {
50 return err
51 }
52
53 switch typ {
54 case "sh.tangled.markup.markdown":
55 t.MarkupMarkdown = new(MarkupMarkdown)
56 return json.Unmarshal(b, t.MarkupMarkdown)
57
58 default:
59 return nil
60 }
61}
62
63func (t *FeedComment_Body) MarshalCBOR(w io.Writer) error {
64
65 if t == nil {
66 _, err := w.Write(cbg.CborNull)
67 return err
68 }
69 if t.MarkupMarkdown != nil {
70 return t.MarkupMarkdown.MarshalCBOR(w)
71 }
72 return fmt.Errorf("cannot cbor marshal empty enum")
73}
74func (t *FeedComment_Body) UnmarshalCBOR(r io.Reader) error {
75 typ, b, err := util.CborTypeExtractReader(r)
76 if err != nil {
77 return err
78 }
79
80 switch typ {
81 case "sh.tangled.markup.markdown":
82 t.MarkupMarkdown = new(MarkupMarkdown)
83 return t.MarkupMarkdown.UnmarshalCBOR(bytes.NewReader(b))
84
85 default:
86 return nil
87 }
88}