diff --git a/api/bsky/draftdefs.go b/api/bsky/draftdefs.go index 4faca1c1..42bd5c9a 100644 --- a/api/bsky/draftdefs.go +++ b/api/bsky/draftdefs.go @@ -43,8 +43,9 @@ type DraftDefs_DraftEmbedExternal struct { // DraftDefs_DraftEmbedImage is a "draftEmbedImage" in the app.bsky.draft.defs schema. type DraftDefs_DraftEmbedImage struct { - Alt *string `json:"alt,omitempty" cborgen:"alt,omitempty"` - LocalRef *DraftDefs_DraftEmbedLocalRef `json:"localRef" cborgen:"localRef"` + LexiconTypeID string `json:"$type" cborgen:"$type,const=app.bsky.draft.defs#draftEmbedImage"` + Alt *string `json:"alt,omitempty" cborgen:"alt,omitempty"` + LocalRef *DraftDefs_DraftEmbedLocalRef `json:"localRef" cborgen:"localRef"` } // DraftDefs_DraftEmbedLocalRef is a "draftEmbedLocalRef" in the app.bsky.draft.defs schema. @@ -70,15 +71,44 @@ type DraftDefs_DraftEmbedVideo struct { // One of the posts that compose a draft. type DraftDefs_DraftPost struct { EmbedExternals []*DraftDefs_DraftEmbedExternal `json:"embedExternals,omitempty" cborgen:"embedExternals,omitempty"` - EmbedImages []*DraftDefs_DraftEmbedImage `json:"embedImages,omitempty" cborgen:"embedImages,omitempty"` - EmbedRecords []*DraftDefs_DraftEmbedRecord `json:"embedRecords,omitempty" cborgen:"embedRecords,omitempty"` - EmbedVideos []*DraftDefs_DraftEmbedVideo `json:"embedVideos,omitempty" cborgen:"embedVideos,omitempty"` + // embedGallery: The schema-level maxLength of 20 is a future-proof ceiling. Clients should currently enforce a soft limit of 10 items in authoring UIs. + EmbedGallery []*DraftDefs_DraftPost_EmbedGallery_Elem `json:"embedGallery,omitempty" cborgen:"embedGallery,omitempty"` + EmbedImages []*DraftDefs_DraftEmbedImage `json:"embedImages,omitempty" cborgen:"embedImages,omitempty"` + EmbedRecords []*DraftDefs_DraftEmbedRecord `json:"embedRecords,omitempty" cborgen:"embedRecords,omitempty"` + EmbedVideos []*DraftDefs_DraftEmbedVideo `json:"embedVideos,omitempty" cborgen:"embedVideos,omitempty"` // labels: Self-label values for this post. Effectively content warnings. Labels *DraftDefs_DraftPost_Labels `json:"labels,omitempty" cborgen:"labels,omitempty"` // text: The primary post content. It has a higher limit than post contents to allow storing a larger text that can later be refined into smaller posts. Text string `json:"text" cborgen:"text"` } +type DraftDefs_DraftPost_EmbedGallery_Elem struct { + DraftDefs_DraftEmbedImage *DraftDefs_DraftEmbedImage +} + +func (t *DraftDefs_DraftPost_EmbedGallery_Elem) MarshalJSON() ([]byte, error) { + if t.DraftDefs_DraftEmbedImage != nil { + t.DraftDefs_DraftEmbedImage.LexiconTypeID = "app.bsky.draft.defs#draftEmbedImage" + return json.Marshal(t.DraftDefs_DraftEmbedImage) + } + return nil, fmt.Errorf("can not marshal empty union as JSON") +} + +func (t *DraftDefs_DraftPost_EmbedGallery_Elem) UnmarshalJSON(b []byte) error { + typ, err := lexutil.TypeExtract(b) + if err != nil { + return err + } + + switch typ { + case "app.bsky.draft.defs#draftEmbedImage": + t.DraftDefs_DraftEmbedImage = new(DraftDefs_DraftEmbedImage) + return json.Unmarshal(b, t.DraftDefs_DraftEmbedImage) + default: + return nil + } +} + // Self-label values for this post. Effectively content warnings. type DraftDefs_DraftPost_Labels struct { LabelDefs_SelfLabels *comatproto.LabelDefs_SelfLabels diff --git a/lexicons/app/bsky/draft/defs.json b/lexicons/app/bsky/draft/defs.json index 9062cd44..85278e7b 100644 --- a/lexicons/app/bsky/draft/defs.json +++ b/lexicons/app/bsky/draft/defs.json @@ -95,6 +95,12 @@ "items": { "type": "ref", "ref": "#draftEmbedImage" }, "maxLength": 4 }, + "embedGallery": { + "type": "array", + "items": { "type": "union", "refs": ["#draftEmbedImage"] }, + "maxLength": 20, + "description": "The schema-level maxLength of 20 is a future-proof ceiling. Clients should currently enforce a soft limit of 10 items in authoring UIs." + }, "embedVideos": { "type": "array", "items": { "type": "ref", "ref": "#draftEmbedVideo" },