diff options
author | Samuel Newman <mozzius@protonmail.com> | 2025-06-28 00:02:59 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-06-28 00:02:59 +0300 |
commit | bde3fdaa42ae6f0e106f7f4c42fa4c7a5eb3debf (patch) | |
tree | 39e63fc86bf677b519be0f7e9ccec4d0d3da9649 /src/lib/api/index.ts | |
parent | 494758da11093a0aa4f67a13495bf7971f53c434 (diff) | |
download | voidsky-bde3fdaa42ae6f0e106f7f4c42fa4c7a5eb3debf.tar.zst |
Fix video aspect ratio error - "Record/embed/aspectRatio/width cannot be less than 1" (#8571)
Diffstat (limited to 'src/lib/api/index.ts')
-rw-r--r-- | src/lib/api/index.ts | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/src/lib/api/index.ts b/src/lib/api/index.ts index 7621fbb4c..20f0745d6 100644 --- a/src/lib/api/index.ts +++ b/src/lib/api/index.ts @@ -333,15 +333,27 @@ async function resolveMedia( return {lang: caption.lang, file: data.blob} }), ) + + // lexicon numbers must be floats + const width = Math.round(videoDraft.asset.width) + const height = Math.round(videoDraft.asset.height) + + // aspect ratio values must be >0 - better to leave as unset otherwise + // posting will fail if aspect ratio is set to 0 + const aspectRatio = width > 0 && height > 0 ? {width, height} : undefined + + if (!aspectRatio) { + logger.error( + `Invalid aspect ratio - got { width: ${videoDraft.asset.width}, height: ${videoDraft.asset.height} }`, + ) + } + return { $type: 'app.bsky.embed.video', video: videoDraft.pendingPublish.blobRef, alt: videoDraft.altText || undefined, captions: captions.length === 0 ? undefined : captions, - aspectRatio: { - width: videoDraft.asset.width, - height: videoDraft.asset.height, - }, + aspectRatio, } } if (embedDraft.media?.type === 'gif') { |