Skip to content

Commit 41761f9

Browse files
committed
fix: image uploads failing to post
1 parent 2549efe commit 41761f9

2 files changed

Lines changed: 13 additions & 8 deletions

File tree

bluesky/blueskyapi.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -88,11 +88,11 @@ type PostReason struct {
8888
}
8989

9090
type Embed struct {
91-
Type string `json:"$type"`
92-
Images []Image `json:"images,omitempty"`
93-
External ExternalImage `json:"external,omitempty"`
94-
Media MoreImages `json:"media"`
95-
Video `json:",omitempty"`
91+
Type string `json:"$type"`
92+
Images []Image `json:"images,omitempty"`
93+
External *ExternalImage `json:"external,omitempty"`
94+
Media *MoreImages `json:"media,omitempty"`
95+
*Video `json:",omitempty"`
9696
}
9797

9898
type MoreImages struct {

twitterv1/post_viewing.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,12 @@ func TranslatePostToTweet(tweet blueskyapi.Post, replyMsgBskyURI string, replyUs
364364
// Quote replies are different for some reason, app.bsky.embed.recordWithMedia
365365

366366
// Images
367-
for _, image := range append(tweet.Record.Embed.Images, tweet.Record.Embed.Media.Images...) {
367+
368+
bskyimages := tweet.Record.Embed.Images
369+
if tweet.Record.Embed.Media != nil {
370+
bskyimages = append(bskyimages, tweet.Record.Embed.Media.Images...)
371+
}
372+
for _, image := range bskyimages {
368373
// Add the image "url" to the text
369374
startLen, endLen := 0, 0
370375
formattedImageURL := configData.ImgURLText
@@ -556,7 +561,7 @@ func TranslatePostToTweet(tweet blueskyapi.Post, replyMsgBskyURI string, replyUs
556561
}
557562

558563
// GIFs
559-
if tweet.Record.Embed.Type == "app.bsky.embed.external" && strings.HasPrefix(tweet.Record.Embed.External.Uri, "https://media.tenor.com/") {
564+
if tweet.Record.Embed.External != nil && tweet.Record.Embed.Type == "app.bsky.embed.external" && strings.HasPrefix(tweet.Record.Embed.External.Uri, "https://media.tenor.com/") {
560565
startLen, endLen := 0, 0
561566
formattedImageURL := configData.GifURLText
562567
displayURL := configData.GifDisplayText
@@ -834,7 +839,7 @@ func TranslatePostToTweet(tweet blueskyapi.Post, replyMsgBskyURI string, replyUs
834839
// Videos.
835840
// I am 99% sure twitter API 1.0 did not have proper video uploads, so we embed it as a link.
836841

837-
if tweet.Record.Embed.Video.Video != nil {
842+
if tweet.Record.Embed.Video != nil && tweet.Record.Embed.Video.Video != nil {
838843
video := tweet.Record.Embed.Video // i don't want to refrence it forever
839844

840845
// Adding the URL into the text of the tweet

0 commit comments

Comments
 (0)