~james/core

core/api/org_tangled/feedcomment.go -rw-r--r-- 4.6 KiB
452f17b7 — james chore(import): snapshot james.dad.town/core at f70c71c7696a 15 hours ago
                                                                                
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
// Code generated by cmd/lexgen (see Makefile's lexgen); DO NOT EDIT.

package org_tangled

// schema: org.tangled.feed.comment

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"
)

const (
	FeedCommentNSID = "org.tangled.feed.comment"
)

func init() {
	util.RegisterType("org.tangled.feed.comment", &FeedComment{})
} //
// RECORDTYPE: FeedComment
type FeedComment struct {
	LexiconTypeID string                         `json:"$type,const=org.tangled.feed.comment" cborgen:"$type,const=org.tangled.feed.comment"`
	Body          *FeedComment_Body              `json:"body" cborgen:"body"`
	CreatedAt     string                         `json:"createdAt" cborgen:"createdAt"`
	Embed         *FeedComment_Embed             `json:"embed,omitempty" cborgen:"embed,omitempty"`
	ReplyTo       *comatprototypes.RepoStrongRef `json:"replyTo,omitempty" cborgen:"replyTo,omitempty"`
	Subject       *FeedComment_Subject           `json:"subject" cborgen:"subject"`
}

type FeedComment_Body struct {
	MarkupMarkdown *MarkupMarkdown
}

func (t *FeedComment_Body) MarshalJSON() ([]byte, error) {
	if t.MarkupMarkdown != nil {
		t.MarkupMarkdown.LexiconTypeID = "org.tangled.markup.markdown"
		return json.Marshal(t.MarkupMarkdown)
	}
	return nil, fmt.Errorf("cannot marshal empty enum")
}
func (t *FeedComment_Body) UnmarshalJSON(b []byte) error {
	typ, err := util.TypeExtract(b)
	if err != nil {
		return err
	}

	switch typ {
	case "org.tangled.markup.markdown":
		t.MarkupMarkdown = new(MarkupMarkdown)
		return json.Unmarshal(b, t.MarkupMarkdown)

	default:
		return nil
	}
}

func (t *FeedComment_Body) MarshalCBOR(w io.Writer) error {

	if t == nil {
		_, err := w.Write(cbg.CborNull)
		return err
	}
	if t.MarkupMarkdown != nil {
		return t.MarkupMarkdown.MarshalCBOR(w)
	}
	return fmt.Errorf("cannot cbor marshal empty enum")
}
func (t *FeedComment_Body) UnmarshalCBOR(r io.Reader) error {
	typ, b, err := util.CborTypeExtractReader(r)
	if err != nil {
		return err
	}

	switch typ {
	case "org.tangled.markup.markdown":
		t.MarkupMarkdown = new(MarkupMarkdown)
		return t.MarkupMarkdown.UnmarshalCBOR(bytes.NewReader(b))

	default:
		return nil
	}
}

type FeedComment_Embed struct {
	EmbedCommit *EmbedCommit
}

func (t *FeedComment_Embed) MarshalJSON() ([]byte, error) {
	if t.EmbedCommit != nil {
		t.EmbedCommit.LexiconTypeID = "org.tangled.embed.commit"
		return json.Marshal(t.EmbedCommit)
	}
	return nil, fmt.Errorf("cannot marshal empty enum")
}
func (t *FeedComment_Embed) UnmarshalJSON(b []byte) error {
	typ, err := util.TypeExtract(b)
	if err != nil {
		return err
	}

	switch typ {
	case "org.tangled.embed.commit":
		t.EmbedCommit = new(EmbedCommit)
		return json.Unmarshal(b, t.EmbedCommit)

	default:
		return nil
	}
}

func (t *FeedComment_Embed) MarshalCBOR(w io.Writer) error {

	if t == nil {
		_, err := w.Write(cbg.CborNull)
		return err
	}
	if t.EmbedCommit != nil {
		return t.EmbedCommit.MarshalCBOR(w)
	}
	return fmt.Errorf("cannot cbor marshal empty enum")
}
func (t *FeedComment_Embed) UnmarshalCBOR(r io.Reader) error {
	typ, b, err := util.CborTypeExtractReader(r)
	if err != nil {
		return err
	}

	switch typ {
	case "org.tangled.embed.commit":
		t.EmbedCommit = new(EmbedCommit)
		return t.EmbedCommit.UnmarshalCBOR(bytes.NewReader(b))

	default:
		return nil
	}
}

type FeedComment_Subject struct {
	RepoStrongRef *comatprototypes.RepoStrongRef
}

func (t *FeedComment_Subject) MarshalJSON() ([]byte, error) {
	if t.RepoStrongRef != nil {
		t.RepoStrongRef.LexiconTypeID = "com.atproto.repo.strongRef"
		return json.Marshal(t.RepoStrongRef)
	}
	return nil, fmt.Errorf("cannot marshal empty enum")
}
func (t *FeedComment_Subject) UnmarshalJSON(b []byte) error {
	typ, err := util.TypeExtract(b)
	if err != nil {
		return err
	}

	switch typ {
	case "com.atproto.repo.strongRef":
		t.RepoStrongRef = new(comatprototypes.RepoStrongRef)
		return json.Unmarshal(b, t.RepoStrongRef)

	default:
		return nil
	}
}

func (t *FeedComment_Subject) MarshalCBOR(w io.Writer) error {

	if t == nil {
		_, err := w.Write(cbg.CborNull)
		return err
	}
	if t.RepoStrongRef != nil {
		return t.RepoStrongRef.MarshalCBOR(w)
	}
	return fmt.Errorf("cannot cbor marshal empty enum")
}
func (t *FeedComment_Subject) UnmarshalCBOR(r io.Reader) error {
	typ, b, err := util.CborTypeExtractReader(r)
	if err != nil {
		return err
	}

	switch typ {
	case "com.atproto.repo.strongRef":
		t.RepoStrongRef = new(comatprototypes.RepoStrongRef)
		return t.RepoStrongRef.UnmarshalCBOR(bytes.NewReader(b))

	default:
		return nil
	}
}