also looking at this
Queued posts carry title, link card, and image through to publish
#13
8 files
+158
-11
| @@ -3,6 +3,7 @@ import type { RequestInstance } from '@stacksjs/types' | ||
| 3 | 3 | import { Action } from '@stacksjs/actions' |
| 4 | 4 | import { response } from '@stacksjs/router' |
| 5 | 5 | import { crosspost, crosspostProviders } from '../../Services/Social/CrosspostService' |
| 6 | import { readUploadedImage } from '../../Support/Social/uploads' | |
| 6 | 7 | |
| 7 | 8 | export default new Action({ |
| 8 | 9 | name: 'Postline Crosspost Publish', |
| @@ -34,14 +35,9 @@ export default new Action({ | ||
| 34 | 35 | const imageAlt = String(request.get('image_alt') || '').trim() |
| 35 | 36 | |
| 36 | 37 | const media: NonNullable<Parameters<typeof crosspost.publish>[2]>['media'] = [] |
| 37 | const uploaded = request.file?.('image') | |
| 38 | if (uploaded?.buffer && uploaded.buffer.byteLength > 0) { | |
| 39 | media.push({ | |
| 40 | bytes: new Uint8Array(uploaded.buffer), | |
| 41 | mimeType: uploaded.mimetype || 'image/jpeg', | |
| 42 | altText: imageAlt || undefined, | |
| 43 | }) | |
| 44 | } | |
| 38 | const uploadedImage = await readUploadedImage(request.file?.('image')) | |
| 39 | if (uploadedImage) | |
| 40 | media.push({ ...uploadedImage, altText: imageAlt || undefined }) | |
| 45 | 41 | if (imageUrl) |
| 46 | 42 | media.push({ url: imageUrl, altText: imageAlt || undefined }) |
| 47 | 43 | |