// Code generated by glex; DO NOT EDIT. // Lexicon schema: place.stream.chat.message package placestream import ( "encoding/json" "io" glex "github.com/streamplace/glex/runtime" cbg "github.com/whyrusleeping/cbor-gen" comatproto "stream.place/streamplace/pkg/comatproto" ) func init() { glex.RegisterType("place.stream.chat.message", &ChatMessage{}) } // Record containing a Streamplace chat message. type ChatMessage struct { LexiconTypeID string `json:"$type,omitempty"` // createdAt: Client-declared timestamp when this message was originally created. CreatedAt string `json:"createdAt"` // facets: Annotations of text (mentions, URLs, etc) Facets []RichtextFacet `json:"facets,omitempty"` Reply *ChatMessage_ReplyRef `json:"reply,omitempty"` // streamer: The DID of the streamer whose chat this is. Streamer string `json:"streamer"` // text: The primary message content. May be an empty string, if there are embeds. Text string `json:"text"` } // RecordTypeID implements glex.Record. func (t *ChatMessage) RecordTypeID() string { return "place.stream.chat.message" } // MarshalJSON stamps the $type field, like MarshalCBOR does. The value // receiver operates on a copy, so the record is never mutated and both // ChatMessage and *ChatMessage marshal with $type. func (t ChatMessage) MarshalJSON() ([]byte, error) { t.LexiconTypeID = "place.stream.chat.message" type alias ChatMessage return json.Marshal((alias)(t)) } func (t *ChatMessage) 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 = "place.stream.chat.message" return glex.MarshalCBOR(w, &cp) } func (t *ChatMessage) UnmarshalCBOR(r io.Reader) error { return glex.UnmarshalCBOR(r, t) } // ChatMessage_ReplyRef is a "replyRef" in the place.stream.chat.message schema. type ChatMessage_ReplyRef struct { LexiconTypeID string `json:"$type,omitempty"` Parent comatproto.RepoStrongRef `json:"parent"` Root comatproto.RepoStrongRef `json:"root"` } // RecordTypeID implements glex.Record. func (t *ChatMessage_ReplyRef) RecordTypeID() string { return "place.stream.chat.message#replyRef" } func (t *ChatMessage_ReplyRef) 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 = "place.stream.chat.message#replyRef" return glex.MarshalCBOR(w, &cp) } func (t *ChatMessage_ReplyRef) UnmarshalCBOR(r io.Reader) error { return glex.UnmarshalCBOR(r, t) }