Bluesky app fork with some witchin' additions 💫 witchsky.app
bluesky fork client

Use video thumbnail as og:image for posts with video embeds (#9877)

authored by samuel.fm and committed by

GitHub 90d650de 79e27e30

+34 -16
+21 -14
bskyweb/README.md
··· 6 6 environment set up. Either follow the top-level README, or something quick 7 7 like: 8 8 9 - # install nodejs 10 - nvm install 11 - nvm use 12 - npm install --global yarn 9 + ```bash 10 + # install nodejs 11 + nvm install 12 + nvm use 13 + npm install --global yarn 13 14 14 - # setup tools and deps (in top level of this repo) 15 - yarn install --frozen-lockfile 15 + # setup tools and deps (in top level of this repo) 16 + yarn install --frozen-lockfile 16 17 17 - # run yarn web dev server, if you wanted 18 - yarn web 18 + # run yarn web dev server, if you wanted 19 + yarn web 20 + ``` 19 21 20 22 Then build and copy over the big 'ol `bundle.web.js` file: 21 23 22 - # in the top level of this repo 23 - yarn build-web 24 + 25 + ```bash 26 + # in the top level of this repo 27 + yarn build-web 28 + ``` 24 29 25 30 ### Golang Daemon 26 31 ··· 28 33 29 34 In this directory (`bskyweb/`): 30 35 31 - # re-build and run daemon 32 - go run ./cmd/bskyweb serve 36 + ```bash 37 + # re-build and run daemon 38 + go run ./cmd/bskyweb serve 33 39 34 - # build and output a binary 35 - go build -o bskyweb ./cmd/bskyweb/ 40 + # build and output a binary 41 + go build -o bskyweb ./cmd/bskyweb/ 42 + ``` 36 43 37 44 The easiest way to configure the daemon is to copy `example.env` to `.env` and 38 45 fill in auth values there.
+13 -2
bskyweb/cmd/bskyweb/server.go
··· 574 574 575 575 if postView.Embed != nil && !isEmbedHidden { 576 576 hasImages := postView.Embed.EmbedImages_View != nil 577 - hasMedia := postView.Embed.EmbedRecordWithMedia_View != nil && postView.Embed.EmbedRecordWithMedia_View.Media != nil && postView.Embed.EmbedRecordWithMedia_View.Media.EmbedImages_View != nil 577 + hasVideo := postView.Embed.EmbedVideo_View != nil 578 + hasMedia := postView.Embed.EmbedRecordWithMedia_View != nil && postView.Embed.EmbedRecordWithMedia_View.Media != nil 579 + hasMediaImages := hasMedia && postView.Embed.EmbedRecordWithMedia_View.Media.EmbedImages_View != nil 580 + hasMediaVideo := hasMedia && postView.Embed.EmbedRecordWithMedia_View.Media.EmbedVideo_View != nil 578 581 579 582 if hasImages { 580 583 var thumbUrls []string ··· 582 585 thumbUrls = append(thumbUrls, postView.Embed.EmbedImages_View.Images[i].Thumb) 583 586 } 584 587 data["imgThumbUrls"] = thumbUrls 585 - } else if hasMedia { 588 + } else if hasVideo { 589 + if postView.Embed.EmbedVideo_View.Thumbnail != nil { 590 + data["imgThumbUrls"] = []string{*postView.Embed.EmbedVideo_View.Thumbnail} 591 + } 592 + } else if hasMediaImages { 586 593 var thumbUrls []string 587 594 for i := range postView.Embed.EmbedRecordWithMedia_View.Media.EmbedImages_View.Images { 588 595 thumbUrls = append(thumbUrls, postView.Embed.EmbedRecordWithMedia_View.Media.EmbedImages_View.Images[i].Thumb) 589 596 } 590 597 data["imgThumbUrls"] = thumbUrls 598 + } else if hasMediaVideo { 599 + if postView.Embed.EmbedRecordWithMedia_View.Media.EmbedVideo_View.Thumbnail != nil { 600 + data["imgThumbUrls"] = []string{*postView.Embed.EmbedRecordWithMedia_View.Media.EmbedVideo_View.Thumbnail} 601 + } 591 602 } 592 603 } 593 604