ReviewOS

also looking at this

stacks/postline

feat: crossposting — media (LinkedIn/IG/Threads), OAuth token refresh, and X/Twitter

#30
Merged glennmichael123 wants to merge feat/crosspost-media-and-token-refresh into main
28 files +1810 -109
app/Services/Social/QueueService.tsmodified+6-4
Changes to app/Services/Social/QueueService.ts
@@ -1,17 +1,14 @@
11import type { CrosspostTargetResult, PublishContent, SocialProvider } from '../../Support/Social/types'
22import { mkdir, unlink } from 'node:fs/promises'
33import { join } from 'node:path'
4import process from 'node:process'
54import { db } from '@stacksjs/database'
65import { env } from '@stacksjs/env'
6import { MEDIA_DIR, publicMediaUrl } from '../../Support/Social/uploads'
77import { crosspost, crosspostProviders } from './CrosspostService'
88import { ensureAccount, now, uuid } from './support'
99
1010const database = db as any
1111
12/** Uploaded images for queued posts live here until publish. */
13const MEDIA_DIR = join(process.cwd(), 'storage/app/postline-media')
14
1512/** Serialized into posts.content — everything beyond the text itself. */
1613interface StoredContent {
1714 /** Only set when the composer provided an explicit title. */
@@ -379,6 +376,11 @@ export class QueueService {
379376 if (await file.exists()) {
380377 media.push({
381378 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,
382384 mimeType: item.mimeType,
383385 altText: item.altText,
384386 })