also looking at this
feat: crossposting — media (LinkedIn/IG/Threads), OAuth token refresh, and X/Twitter
#30
28 files
+1810
-109
| @@ -1,17 +1,14 @@ | ||
| 1 | 1 | import type { CrosspostTargetResult, PublishContent, SocialProvider } from '../../Support/Social/types' |
| 2 | 2 | import { mkdir, unlink } from 'node:fs/promises' |
| 3 | 3 | import { join } from 'node:path' |
| 4 | import process from 'node:process' | |
| 5 | 4 | import { db } from '@stacksjs/database' |
| 6 | 5 | import { env } from '@stacksjs/env' |
| 6 | import { MEDIA_DIR, publicMediaUrl } from '../../Support/Social/uploads' | |
| 7 | 7 | import { crosspost, crosspostProviders } from './CrosspostService' |
| 8 | 8 | import { ensureAccount, now, uuid } from './support' |
| 9 | 9 | |
| 10 | 10 | const database = db as any |
| 11 | 11 | |
| 12 | /** Uploaded images for queued posts live here until publish. */ | |
| 13 | const MEDIA_DIR = join(process.cwd(), 'storage/app/postline-media') | |
| 14 | ||
| 15 | 12 | /** Serialized into posts.content — everything beyond the text itself. */ |
| 16 | 13 | interface StoredContent { |
| 17 | 14 | /** Only set when the composer provided an explicit title. */ |
| @@ -379,6 +376,11 @@ export class QueueService { | ||
| 379 | 376 | if (await file.exists()) { |
| 380 | 377 | media.push({ |
| 381 | 378 | bytes: new Uint8Array(await file.arrayBuffer()), |
| 379 | // Also expose a public URL so URL-only providers (Instagram, | |
| 380 | // Threads) can publish the same uploaded file; byte-upload | |
| 381 | // providers (Bluesky, LinkedIn, Mastodon) keep using `bytes`. | |
| 382 | // Null when no public base is configured — then it's bytes-only. | |
| 383 | url: publicMediaUrl(item.path) ?? undefined, | |
| 382 | 384 | mimeType: item.mimeType, |
| 383 | 385 | altText: item.altText, |
| 384 | 386 | }) |