diff --git a/api/bsky/cbor_gen.go b/api/bsky/cbor_gen.go index 13b85793..35c50b82 100644 --- a/api/bsky/cbor_gen.go +++ b/api/bsky/cbor_gen.go @@ -2901,6 +2901,379 @@ func (t *ActorProfile) UnmarshalCBOR(r io.Reader) (err error) { return nil } +func (t *EmbedGallery) MarshalCBOR(w io.Writer) error { + if t == nil { + _, err := w.Write(cbg.CborNull) + return err + } + + cw := cbg.NewCborWriter(w) + + if _, err := cw.Write([]byte{162}); err != nil { + return err + } + + // t.LexiconTypeID (string) (string) + if len("$type") > 1000000 { + return xerrors.Errorf("Value in field \"$type\" was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("$type"))); err != nil { + return err + } + if _, err := cw.WriteString(string("$type")); err != nil { + return err + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("app.bsky.embed.gallery"))); err != nil { + return err + } + if _, err := cw.WriteString(string("app.bsky.embed.gallery")); err != nil { + return err + } + + // t.Items ([]*bsky.EmbedGallery_Items_Elem) (slice) + if len("items") > 1000000 { + return xerrors.Errorf("Value in field \"items\" was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("items"))); err != nil { + return err + } + if _, err := cw.WriteString(string("items")); err != nil { + return err + } + + if len(t.Items) > 8192 { + return xerrors.Errorf("Slice value in field t.Items was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajArray, uint64(len(t.Items))); err != nil { + return err + } + for _, v := range t.Items { + if err := v.MarshalCBOR(cw); err != nil { + return err + } + + } + return nil +} + +func (t *EmbedGallery) UnmarshalCBOR(r io.Reader) (err error) { + *t = EmbedGallery{} + + cr := cbg.NewCborReader(r) + + maj, extra, err := cr.ReadHeader() + if err != nil { + return err + } + defer func() { + if err == io.EOF { + err = io.ErrUnexpectedEOF + } + }() + + if maj != cbg.MajMap { + return fmt.Errorf("cbor input should be of type map") + } + + if extra > cbg.MaxLength { + return fmt.Errorf("EmbedGallery: map struct too large (%d)", extra) + } + + n := extra + + nameBuf := make([]byte, 5) + for i := uint64(0); i < n; i++ { + nameLen, ok, err := cbg.ReadFullStringIntoBuf(cr, nameBuf, 1000000) + if err != nil { + return err + } + + if !ok { + // Field doesn't exist on this type, so ignore it + if err := cbg.ScanForLinks(cr, func(cid.Cid) {}); err != nil { + return err + } + continue + } + + switch string(nameBuf[:nameLen]) { + // t.LexiconTypeID (string) (string) + case "$type": + + { + sval, err := cbg.ReadStringWithMax(cr, 1000000) + if err != nil { + return err + } + + t.LexiconTypeID = string(sval) + } + // t.Items ([]*bsky.EmbedGallery_Items_Elem) (slice) + case "items": + + maj, extra, err = cr.ReadHeader() + if err != nil { + return err + } + + if extra > 8192 { + return fmt.Errorf("t.Items: array too large (%d)", extra) + } + + if maj != cbg.MajArray { + return fmt.Errorf("expected cbor array") + } + + if extra > 0 { + t.Items = make([]*EmbedGallery_Items_Elem, extra) + } + + for i := 0; i < int(extra); i++ { + { + var maj byte + var extra uint64 + var err error + _ = maj + _ = extra + _ = err + + { + + b, err := cr.ReadByte() + if err != nil { + return err + } + if b != cbg.CborNull[0] { + if err := cr.UnreadByte(); err != nil { + return err + } + t.Items[i] = new(EmbedGallery_Items_Elem) + if err := t.Items[i].UnmarshalCBOR(cr); err != nil { + return xerrors.Errorf("unmarshaling t.Items[i] pointer: %w", err) + } + } + + } + + } + } + + default: + // Field doesn't exist on this type, so ignore it + if err := cbg.ScanForLinks(r, func(cid.Cid) {}); err != nil { + return err + } + } + } + + return nil +} +func (t *EmbedGallery_Image) MarshalCBOR(w io.Writer) error { + if t == nil { + _, err := w.Write(cbg.CborNull) + return err + } + + cw := cbg.NewCborWriter(w) + + if _, err := cw.Write([]byte{164}); err != nil { + return err + } + + // t.Alt (string) (string) + if len("alt") > 1000000 { + return xerrors.Errorf("Value in field \"alt\" was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("alt"))); err != nil { + return err + } + if _, err := cw.WriteString(string("alt")); err != nil { + return err + } + + if len(t.Alt) > 1000000 { + return xerrors.Errorf("Value in field t.Alt was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Alt))); err != nil { + return err + } + if _, err := cw.WriteString(string(t.Alt)); err != nil { + return err + } + + // t.LexiconTypeID (string) (string) + if len("$type") > 1000000 { + return xerrors.Errorf("Value in field \"$type\" was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("$type"))); err != nil { + return err + } + if _, err := cw.WriteString(string("$type")); err != nil { + return err + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("app.bsky.embed.gallery#image"))); err != nil { + return err + } + if _, err := cw.WriteString(string("app.bsky.embed.gallery#image")); err != nil { + return err + } + + // t.Image (util.LexBlob) (struct) + if len("image") > 1000000 { + return xerrors.Errorf("Value in field \"image\" was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("image"))); err != nil { + return err + } + if _, err := cw.WriteString(string("image")); err != nil { + return err + } + + if err := t.Image.MarshalCBOR(cw); err != nil { + return err + } + + // t.AspectRatio (bsky.EmbedDefs_AspectRatio) (struct) + if len("aspectRatio") > 1000000 { + return xerrors.Errorf("Value in field \"aspectRatio\" was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("aspectRatio"))); err != nil { + return err + } + if _, err := cw.WriteString(string("aspectRatio")); err != nil { + return err + } + + if err := t.AspectRatio.MarshalCBOR(cw); err != nil { + return err + } + return nil +} + +func (t *EmbedGallery_Image) UnmarshalCBOR(r io.Reader) (err error) { + *t = EmbedGallery_Image{} + + cr := cbg.NewCborReader(r) + + maj, extra, err := cr.ReadHeader() + if err != nil { + return err + } + defer func() { + if err == io.EOF { + err = io.ErrUnexpectedEOF + } + }() + + if maj != cbg.MajMap { + return fmt.Errorf("cbor input should be of type map") + } + + if extra > cbg.MaxLength { + return fmt.Errorf("EmbedGallery_Image: map struct too large (%d)", extra) + } + + n := extra + + nameBuf := make([]byte, 11) + for i := uint64(0); i < n; i++ { + nameLen, ok, err := cbg.ReadFullStringIntoBuf(cr, nameBuf, 1000000) + if err != nil { + return err + } + + if !ok { + // Field doesn't exist on this type, so ignore it + if err := cbg.ScanForLinks(cr, func(cid.Cid) {}); err != nil { + return err + } + continue + } + + switch string(nameBuf[:nameLen]) { + // t.Alt (string) (string) + case "alt": + + { + sval, err := cbg.ReadStringWithMax(cr, 1000000) + if err != nil { + return err + } + + t.Alt = string(sval) + } + // t.LexiconTypeID (string) (string) + case "$type": + + { + sval, err := cbg.ReadStringWithMax(cr, 1000000) + if err != nil { + return err + } + + t.LexiconTypeID = string(sval) + } + // t.Image (util.LexBlob) (struct) + case "image": + + { + + b, err := cr.ReadByte() + if err != nil { + return err + } + if b != cbg.CborNull[0] { + if err := cr.UnreadByte(); err != nil { + return err + } + t.Image = new(util.LexBlob) + if err := t.Image.UnmarshalCBOR(cr); err != nil { + return xerrors.Errorf("unmarshaling t.Image pointer: %w", err) + } + } + + } + // t.AspectRatio (bsky.EmbedDefs_AspectRatio) (struct) + case "aspectRatio": + + { + + b, err := cr.ReadByte() + if err != nil { + return err + } + if b != cbg.CborNull[0] { + if err := cr.UnreadByte(); err != nil { + return err + } + t.AspectRatio = new(EmbedDefs_AspectRatio) + if err := t.AspectRatio.UnmarshalCBOR(cr); err != nil { + return xerrors.Errorf("unmarshaling t.AspectRatio pointer: %w", err) + } + } + + } + + default: + // Field doesn't exist on this type, so ignore it + if err := cbg.ScanForLinks(r, func(cid.Cid) {}); err != nil { + return err + } + } + } + + return nil +} func (t *EmbedRecord) MarshalCBOR(w io.Writer) error { if t == nil { _, err := w.Write(cbg.CborNull) diff --git a/api/bsky/embedgallery.go b/api/bsky/embedgallery.go new file mode 100644 index 00000000..7846d9cb --- /dev/null +++ b/api/bsky/embedgallery.go @@ -0,0 +1,134 @@ +// Code generated by cmd/lexgen (see Makefile's lexgen); DO NOT EDIT. + +// Lexicon schema: app.bsky.embed.gallery + +package bsky + +import ( + "bytes" + "encoding/json" + "fmt" + "io" + + lexutil "github.com/bluesky-social/indigo/lex/util" + cbg "github.com/whyrusleeping/cbor-gen" +) + +func init() { + lexutil.RegisterType("app.bsky.embed.gallery#main", &EmbedGallery{}) +} + +// EmbedGallery is a "main" in the app.bsky.embed.gallery schema. +type EmbedGallery struct { + LexiconTypeID string `json:"$type" cborgen:"$type,const=app.bsky.embed.gallery"` + Items []*EmbedGallery_Items_Elem `json:"items" cborgen:"items"` +} + +// EmbedGallery_Image is a "image" in the app.bsky.embed.gallery schema. +type EmbedGallery_Image struct { + LexiconTypeID string `json:"$type" cborgen:"$type,const=app.bsky.embed.gallery#image"` + // alt: Alt text description of the image, for accessibility. + Alt string `json:"alt" cborgen:"alt"` + AspectRatio *EmbedDefs_AspectRatio `json:"aspectRatio" cborgen:"aspectRatio"` + Image *lexutil.LexBlob `json:"image" cborgen:"image"` +} + +// The media items in the gallery. Each item may be of a different type, but all types must be supported by the client. Max length may change in the future, and therefore applications should be prepared to handle more or fewer items than the current max length. +type EmbedGallery_Items_Elem struct { + EmbedGallery_Image *EmbedGallery_Image +} + +func (t *EmbedGallery_Items_Elem) MarshalJSON() ([]byte, error) { + if t.EmbedGallery_Image != nil { + t.EmbedGallery_Image.LexiconTypeID = "app.bsky.embed.gallery#image" + return json.Marshal(t.EmbedGallery_Image) + } + return nil, fmt.Errorf("can not marshal empty union as JSON") +} + +func (t *EmbedGallery_Items_Elem) UnmarshalJSON(b []byte) error { + typ, err := lexutil.TypeExtract(b) + if err != nil { + return err + } + + switch typ { + case "app.bsky.embed.gallery#image": + t.EmbedGallery_Image = new(EmbedGallery_Image) + return json.Unmarshal(b, t.EmbedGallery_Image) + default: + return nil + } +} + +func (t *EmbedGallery_Items_Elem) MarshalCBOR(w io.Writer) error { + + if t == nil { + _, err := w.Write(cbg.CborNull) + return err + } + if t.EmbedGallery_Image != nil { + return t.EmbedGallery_Image.MarshalCBOR(w) + } + return fmt.Errorf("can not marshal empty union as CBOR") +} + +func (t *EmbedGallery_Items_Elem) UnmarshalCBOR(r io.Reader) error { + typ, b, err := lexutil.CborTypeExtractReader(r) + if err != nil { + return err + } + + switch typ { + case "app.bsky.embed.gallery#image": + t.EmbedGallery_Image = new(EmbedGallery_Image) + return t.EmbedGallery_Image.UnmarshalCBOR(bytes.NewReader(b)) + default: + return nil + } +} + +// EmbedGallery_View is a "view" in the app.bsky.embed.gallery schema. +type EmbedGallery_View struct { + LexiconTypeID string `json:"$type" cborgen:"$type,const=app.bsky.embed.gallery#view"` + Items []*EmbedGallery_View_Items_Elem `json:"items" cborgen:"items"` +} + +// EmbedGallery_ViewImage is a "viewImage" in the app.bsky.embed.gallery schema. +type EmbedGallery_ViewImage struct { + LexiconTypeID string `json:"$type" cborgen:"$type,const=app.bsky.embed.gallery#viewImage"` + // alt: Alt text description of the image, for accessibility. + Alt string `json:"alt" cborgen:"alt"` + AspectRatio *EmbedDefs_AspectRatio `json:"aspectRatio" cborgen:"aspectRatio"` + // fullsize: Fully-qualified URL where a large version of the image can be fetched. May or may not be the exact original blob. For example, CDN location provided by the App View. + Fullsize string `json:"fullsize" cborgen:"fullsize"` + // thumbnail: Fully-qualified URL where a thumbnail of the image can be fetched. For example, CDN location provided by the App View. + Thumbnail string `json:"thumbnail" cborgen:"thumbnail"` +} + +type EmbedGallery_View_Items_Elem struct { + EmbedGallery_ViewImage *EmbedGallery_ViewImage +} + +func (t *EmbedGallery_View_Items_Elem) MarshalJSON() ([]byte, error) { + if t.EmbedGallery_ViewImage != nil { + t.EmbedGallery_ViewImage.LexiconTypeID = "app.bsky.embed.gallery#viewImage" + return json.Marshal(t.EmbedGallery_ViewImage) + } + return nil, fmt.Errorf("can not marshal empty union as JSON") +} + +func (t *EmbedGallery_View_Items_Elem) UnmarshalJSON(b []byte) error { + typ, err := lexutil.TypeExtract(b) + if err != nil { + return err + } + + switch typ { + case "app.bsky.embed.gallery#viewImage": + t.EmbedGallery_ViewImage = new(EmbedGallery_ViewImage) + return json.Unmarshal(b, t.EmbedGallery_ViewImage) + default: + return nil + } +} diff --git a/api/bsky/embedrecord.go b/api/bsky/embedrecord.go index 4a7d6f43..aa9c82f0 100644 --- a/api/bsky/embedrecord.go +++ b/api/bsky/embedrecord.go @@ -70,6 +70,7 @@ type EmbedRecord_ViewRecord struct { type EmbedRecord_ViewRecord_Embeds_Elem struct { EmbedImages_View *EmbedImages_View EmbedVideo_View *EmbedVideo_View + EmbedGallery_View *EmbedGallery_View EmbedExternal_View *EmbedExternal_View EmbedRecord_View *EmbedRecord_View EmbedRecordWithMedia_View *EmbedRecordWithMedia_View @@ -84,6 +85,10 @@ func (t *EmbedRecord_ViewRecord_Embeds_Elem) MarshalJSON() ([]byte, error) { t.EmbedVideo_View.LexiconTypeID = "app.bsky.embed.video#view" return json.Marshal(t.EmbedVideo_View) } + if t.EmbedGallery_View != nil { + t.EmbedGallery_View.LexiconTypeID = "app.bsky.embed.gallery#view" + return json.Marshal(t.EmbedGallery_View) + } if t.EmbedExternal_View != nil { t.EmbedExternal_View.LexiconTypeID = "app.bsky.embed.external#view" return json.Marshal(t.EmbedExternal_View) @@ -112,6 +117,9 @@ func (t *EmbedRecord_ViewRecord_Embeds_Elem) UnmarshalJSON(b []byte) error { case "app.bsky.embed.video#view": t.EmbedVideo_View = new(EmbedVideo_View) return json.Unmarshal(b, t.EmbedVideo_View) + case "app.bsky.embed.gallery#view": + t.EmbedGallery_View = new(EmbedGallery_View) + return json.Unmarshal(b, t.EmbedGallery_View) case "app.bsky.embed.external#view": t.EmbedExternal_View = new(EmbedExternal_View) return json.Unmarshal(b, t.EmbedExternal_View) diff --git a/api/bsky/embedrecordWithMedia.go b/api/bsky/embedrecordWithMedia.go index 74157b1e..7ce5a8ee 100644 --- a/api/bsky/embedrecordWithMedia.go +++ b/api/bsky/embedrecordWithMedia.go @@ -28,6 +28,7 @@ type EmbedRecordWithMedia struct { type EmbedRecordWithMedia_Media struct { EmbedImages *EmbedImages EmbedVideo *EmbedVideo + EmbedGallery *EmbedGallery EmbedExternal *EmbedExternal } @@ -40,6 +41,10 @@ func (t *EmbedRecordWithMedia_Media) MarshalJSON() ([]byte, error) { t.EmbedVideo.LexiconTypeID = "app.bsky.embed.video" return json.Marshal(t.EmbedVideo) } + if t.EmbedGallery != nil { + t.EmbedGallery.LexiconTypeID = "app.bsky.embed.gallery" + return json.Marshal(t.EmbedGallery) + } if t.EmbedExternal != nil { t.EmbedExternal.LexiconTypeID = "app.bsky.embed.external" return json.Marshal(t.EmbedExternal) @@ -60,6 +65,9 @@ func (t *EmbedRecordWithMedia_Media) UnmarshalJSON(b []byte) error { case "app.bsky.embed.video": t.EmbedVideo = new(EmbedVideo) return json.Unmarshal(b, t.EmbedVideo) + case "app.bsky.embed.gallery": + t.EmbedGallery = new(EmbedGallery) + return json.Unmarshal(b, t.EmbedGallery) case "app.bsky.embed.external": t.EmbedExternal = new(EmbedExternal) return json.Unmarshal(b, t.EmbedExternal) @@ -80,6 +88,9 @@ func (t *EmbedRecordWithMedia_Media) MarshalCBOR(w io.Writer) error { if t.EmbedVideo != nil { return t.EmbedVideo.MarshalCBOR(w) } + if t.EmbedGallery != nil { + return t.EmbedGallery.MarshalCBOR(w) + } if t.EmbedExternal != nil { return t.EmbedExternal.MarshalCBOR(w) } @@ -99,6 +110,9 @@ func (t *EmbedRecordWithMedia_Media) UnmarshalCBOR(r io.Reader) error { case "app.bsky.embed.video": t.EmbedVideo = new(EmbedVideo) return t.EmbedVideo.UnmarshalCBOR(bytes.NewReader(b)) + case "app.bsky.embed.gallery": + t.EmbedGallery = new(EmbedGallery) + return t.EmbedGallery.UnmarshalCBOR(bytes.NewReader(b)) case "app.bsky.embed.external": t.EmbedExternal = new(EmbedExternal) return t.EmbedExternal.UnmarshalCBOR(bytes.NewReader(b)) @@ -117,6 +131,7 @@ type EmbedRecordWithMedia_View struct { type EmbedRecordWithMedia_View_Media struct { EmbedImages_View *EmbedImages_View EmbedVideo_View *EmbedVideo_View + EmbedGallery_View *EmbedGallery_View EmbedExternal_View *EmbedExternal_View } @@ -129,6 +144,10 @@ func (t *EmbedRecordWithMedia_View_Media) MarshalJSON() ([]byte, error) { t.EmbedVideo_View.LexiconTypeID = "app.bsky.embed.video#view" return json.Marshal(t.EmbedVideo_View) } + if t.EmbedGallery_View != nil { + t.EmbedGallery_View.LexiconTypeID = "app.bsky.embed.gallery#view" + return json.Marshal(t.EmbedGallery_View) + } if t.EmbedExternal_View != nil { t.EmbedExternal_View.LexiconTypeID = "app.bsky.embed.external#view" return json.Marshal(t.EmbedExternal_View) @@ -149,6 +168,9 @@ func (t *EmbedRecordWithMedia_View_Media) UnmarshalJSON(b []byte) error { case "app.bsky.embed.video#view": t.EmbedVideo_View = new(EmbedVideo_View) return json.Unmarshal(b, t.EmbedVideo_View) + case "app.bsky.embed.gallery#view": + t.EmbedGallery_View = new(EmbedGallery_View) + return json.Unmarshal(b, t.EmbedGallery_View) case "app.bsky.embed.external#view": t.EmbedExternal_View = new(EmbedExternal_View) return json.Unmarshal(b, t.EmbedExternal_View) diff --git a/api/bsky/feeddefs.go b/api/bsky/feeddefs.go index f1b4eb7b..11997ad5 100644 --- a/api/bsky/feeddefs.go +++ b/api/bsky/feeddefs.go @@ -137,6 +137,7 @@ type FeedDefs_PostView struct { type FeedDefs_PostView_Embed struct { EmbedImages_View *EmbedImages_View EmbedVideo_View *EmbedVideo_View + EmbedGallery_View *EmbedGallery_View EmbedExternal_View *EmbedExternal_View EmbedRecord_View *EmbedRecord_View EmbedRecordWithMedia_View *EmbedRecordWithMedia_View @@ -151,6 +152,10 @@ func (t *FeedDefs_PostView_Embed) MarshalJSON() ([]byte, error) { t.EmbedVideo_View.LexiconTypeID = "app.bsky.embed.video#view" return json.Marshal(t.EmbedVideo_View) } + if t.EmbedGallery_View != nil { + t.EmbedGallery_View.LexiconTypeID = "app.bsky.embed.gallery#view" + return json.Marshal(t.EmbedGallery_View) + } if t.EmbedExternal_View != nil { t.EmbedExternal_View.LexiconTypeID = "app.bsky.embed.external#view" return json.Marshal(t.EmbedExternal_View) @@ -179,6 +184,9 @@ func (t *FeedDefs_PostView_Embed) UnmarshalJSON(b []byte) error { case "app.bsky.embed.video#view": t.EmbedVideo_View = new(EmbedVideo_View) return json.Unmarshal(b, t.EmbedVideo_View) + case "app.bsky.embed.gallery#view": + t.EmbedGallery_View = new(EmbedGallery_View) + return json.Unmarshal(b, t.EmbedGallery_View) case "app.bsky.embed.external#view": t.EmbedExternal_View = new(EmbedExternal_View) return json.Unmarshal(b, t.EmbedExternal_View) diff --git a/api/bsky/feedpost.go b/api/bsky/feedpost.go index f3004f25..1186d36c 100644 --- a/api/bsky/feedpost.go +++ b/api/bsky/feedpost.go @@ -42,6 +42,7 @@ type FeedPost struct { type FeedPost_Embed struct { EmbedImages *EmbedImages EmbedVideo *EmbedVideo + EmbedGallery *EmbedGallery EmbedExternal *EmbedExternal EmbedRecord *EmbedRecord EmbedRecordWithMedia *EmbedRecordWithMedia @@ -56,6 +57,10 @@ func (t *FeedPost_Embed) MarshalJSON() ([]byte, error) { t.EmbedVideo.LexiconTypeID = "app.bsky.embed.video" return json.Marshal(t.EmbedVideo) } + if t.EmbedGallery != nil { + t.EmbedGallery.LexiconTypeID = "app.bsky.embed.gallery" + return json.Marshal(t.EmbedGallery) + } if t.EmbedExternal != nil { t.EmbedExternal.LexiconTypeID = "app.bsky.embed.external" return json.Marshal(t.EmbedExternal) @@ -84,6 +89,9 @@ func (t *FeedPost_Embed) UnmarshalJSON(b []byte) error { case "app.bsky.embed.video": t.EmbedVideo = new(EmbedVideo) return json.Unmarshal(b, t.EmbedVideo) + case "app.bsky.embed.gallery": + t.EmbedGallery = new(EmbedGallery) + return json.Unmarshal(b, t.EmbedGallery) case "app.bsky.embed.external": t.EmbedExternal = new(EmbedExternal) return json.Unmarshal(b, t.EmbedExternal) @@ -110,6 +118,9 @@ func (t *FeedPost_Embed) MarshalCBOR(w io.Writer) error { if t.EmbedVideo != nil { return t.EmbedVideo.MarshalCBOR(w) } + if t.EmbedGallery != nil { + return t.EmbedGallery.MarshalCBOR(w) + } if t.EmbedExternal != nil { return t.EmbedExternal.MarshalCBOR(w) } @@ -135,6 +146,9 @@ func (t *FeedPost_Embed) UnmarshalCBOR(r io.Reader) error { case "app.bsky.embed.video": t.EmbedVideo = new(EmbedVideo) return t.EmbedVideo.UnmarshalCBOR(bytes.NewReader(b)) + case "app.bsky.embed.gallery": + t.EmbedGallery = new(EmbedGallery) + return t.EmbedGallery.UnmarshalCBOR(bytes.NewReader(b)) case "app.bsky.embed.external": t.EmbedExternal = new(EmbedExternal) return t.EmbedExternal.UnmarshalCBOR(bytes.NewReader(b)) diff --git a/gen/main.go b/gen/main.go index c2eb1c84..9614512c 100644 --- a/gen/main.go +++ b/gen/main.go @@ -47,6 +47,7 @@ func main() { bsky.FeedPost_ReplyRef{}, bsky.FeedPost_TextSlice{}, bsky.EmbedImages{}, bsky.EmbedExternal{}, bsky.EmbedExternal_External{}, bsky.EmbedImages_Image{}, bsky.GraphFollow{}, bsky.ActorProfile{}, + bsky.EmbedGallery{}, bsky.EmbedGallery_Image{}, bsky.EmbedRecord{}, bsky.FeedLike{}, bsky.RichtextFacet{}, bsky.RichtextFacet_ByteSlice{}, bsky.RichtextFacet_Link{}, bsky.RichtextFacet_Mention{}, bsky.RichtextFacet_Tag{}, diff --git a/lexicons/app/bsky/embed/gallery.json b/lexicons/app/bsky/embed/gallery.json new file mode 100644 index 00000000..9187bf55 --- /dev/null +++ b/lexicons/app/bsky/embed/gallery.json @@ -0,0 +1,78 @@ +{ + "lexicon": 1, + "id": "app.bsky.embed.gallery", + "description": "An assortment of media embedded in a Bluesky record (eg, a post).", + "defs": { + "main": { + "type": "object", + "required": ["items"], + "properties": { + "items": { + "type": "array", + "maxLength": 20, + "items": { + "type": "union", + "refs": ["#image"], + "description": "The media items in the gallery. Each item may be of a different type, but all types must be supported by the client. Max length may change in the future, and therefore applications should be prepared to handle more or fewer items than the current max length." + } + } + } + }, + "image": { + "type": "object", + "required": ["image", "alt", "aspectRatio"], + "properties": { + "image": { + "type": "blob", + "accept": ["image/*"], + "maxSize": 2000000 + }, + "alt": { + "type": "string", + "description": "Alt text description of the image, for accessibility." + }, + "aspectRatio": { + "type": "ref", + "ref": "app.bsky.embed.defs#aspectRatio" + } + } + }, + "view": { + "type": "object", + "required": ["items"], + "properties": { + "items": { + "type": "array", + "items": { + "type": "union", + "refs": ["#viewImage"] + } + } + } + }, + "viewImage": { + "type": "object", + "required": ["thumbnail", "fullsize", "alt", "aspectRatio"], + "properties": { + "thumbnail": { + "type": "string", + "format": "uri", + "description": "Fully-qualified URL where a thumbnail of the image can be fetched. For example, CDN location provided by the App View." + }, + "fullsize": { + "type": "string", + "format": "uri", + "description": "Fully-qualified URL where a large version of the image can be fetched. May or may not be the exact original blob. For example, CDN location provided by the App View." + }, + "alt": { + "type": "string", + "description": "Alt text description of the image, for accessibility." + }, + "aspectRatio": { + "type": "ref", + "ref": "app.bsky.embed.defs#aspectRatio" + } + } + } + } +} diff --git a/lexicons/app/bsky/embed/record.json b/lexicons/app/bsky/embed/record.json index a73200a3..4ca0f003 100644 --- a/lexicons/app/bsky/embed/record.json +++ b/lexicons/app/bsky/embed/record.json @@ -58,6 +58,7 @@ "refs": [ "app.bsky.embed.images#view", "app.bsky.embed.video#view", + "app.bsky.embed.gallery#view", "app.bsky.embed.external#view", "app.bsky.embed.record#view", "app.bsky.embed.recordWithMedia#view" diff --git a/lexicons/app/bsky/embed/recordWithMedia.json b/lexicons/app/bsky/embed/recordWithMedia.json index 5baf6850..edd76503 100644 --- a/lexicons/app/bsky/embed/recordWithMedia.json +++ b/lexicons/app/bsky/embed/recordWithMedia.json @@ -16,6 +16,7 @@ "refs": [ "app.bsky.embed.images", "app.bsky.embed.video", + "app.bsky.embed.gallery", "app.bsky.embed.external" ] } @@ -34,6 +35,7 @@ "refs": [ "app.bsky.embed.images#view", "app.bsky.embed.video#view", + "app.bsky.embed.gallery#view", "app.bsky.embed.external#view" ] } diff --git a/lexicons/app/bsky/feed/defs.json b/lexicons/app/bsky/feed/defs.json index 0a19cf31..5e462434 100644 --- a/lexicons/app/bsky/feed/defs.json +++ b/lexicons/app/bsky/feed/defs.json @@ -18,6 +18,7 @@ "refs": [ "app.bsky.embed.images#view", "app.bsky.embed.video#view", + "app.bsky.embed.gallery#view", "app.bsky.embed.external#view", "app.bsky.embed.record#view", "app.bsky.embed.recordWithMedia#view" diff --git a/lexicons/app/bsky/feed/post.json b/lexicons/app/bsky/feed/post.json index 9893a355..a4b98efc 100644 --- a/lexicons/app/bsky/feed/post.json +++ b/lexicons/app/bsky/feed/post.json @@ -32,6 +32,7 @@ "refs": [ "app.bsky.embed.images", "app.bsky.embed.video", + "app.bsky.embed.gallery", "app.bsky.embed.external", "app.bsky.embed.record", "app.bsky.embed.recordWithMedia"