Improve Facebook post publishing to support multiple images and stories

Update FacebookService to handle multi-photo carousel posts and refine story publishing logic; modify SchedulerService to pass all media for a post.

Replit-Commit-Author: Agent
Replit-Commit-Session-Id: ae4037a0-2a6f-4530-9bac-79b543286bda
Replit-Commit-Checkpoint-Type: intermediate_checkpoint
Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/397bca8c-984f-43ff-841a-10897aeb8140/ae4037a0-2a6f-4530-9bac-79b543286bda/hAPGvGl
This commit is contained in:
michaelschal committed 2025-10-09 09:21:29 +00:00
1 parent 008ed91fef
commit 168e9bf58d
2 files changed
+101 -9

No files matched your search

+10 -4
View File
@@ -67,13 +67,19 @@ export class SchedulerService {
console.log(`Publishing post ${post.id} to ${page.platform} page ${page.pageName}`);
// Get media if post has media
// Get all media for the post (for multi-photo carousels)
const postMediaList = await storage.getPostMedia(post.id);
const media = postMediaList.length > 0 ? await storage.getMediaById(postMediaList[0].mediaId) : undefined;
const mediaList: any[] = [];
for (const pm of postMediaList) {
const media = await storage.getMediaById(pm.mediaId);
if (media) {
mediaList.push(media);
}
}
// Validate that story posts have media
// Note: "both" should never reach here since they're split at creation
if (scheduledPost.postType === 'story' && !media) {
if (scheduledPost.postType === 'story' && mediaList.length === 0) {
const errorMsg = 'Les stories nécessitent un média. Ce post ne peut pas être publié.';
console.error(`Deleting invalid story post ${scheduledPost.id} without media: ${errorMsg}`);
@@ -91,7 +97,7 @@ export class SchedulerService {
let externalPostId: string;
if (page.platform === 'facebook') {
externalPostId = await facebookService.publishPost(post, page, scheduledPost.postType, media || undefined);
externalPostId = await facebookService.publishPost(post, page, scheduledPost.postType, mediaList);
} else if (page.platform === 'instagram') {
// Instagram publishing not yet implemented
console.warn(`Instagram publishing not yet implemented for post ${post.id}`);