mirror of
https://github.com/R0m1k3/Socialflow.git
synced 2026-10-22 22:48:09 +02:00
fix: ensure persistence of video data for scheduled reels and correct publication type
This commit is contained in:
1 parent
d62ecffaac
commit
c9f7f7e9ec
2 files changed
+29
-1
No files matched your search
+17
-1
@@ -356,7 +356,20 @@ reelsRouter.post('/reels', async (req: Request, res: Response) => {
|
|||||||
|
|
||||||
console.log('✅ Reel uploaded to Cloudinary:', cloudinaryResult.originalUrl);
|
console.log('✅ Reel uploaded to Cloudinary:', cloudinaryResult.originalUrl);
|
||||||
|
|
||||||
// Créer le post en base
|
// Create Media record for the processed video
|
||||||
|
const processedMedia = await storage.createMedia({
|
||||||
|
userId: user.id,
|
||||||
|
type: 'video',
|
||||||
|
cloudinaryPublicId: cloudinaryResult.publicId,
|
||||||
|
originalUrl: cloudinaryResult.originalUrl,
|
||||||
|
facebookFeedUrl: cloudinaryResult.facebookFeedUrl || null,
|
||||||
|
instagramFeedUrl: cloudinaryResult.instagramFeedUrl || null,
|
||||||
|
instagramStoryUrl: cloudinaryResult.instagramStoryUrl || null,
|
||||||
|
fileName: `reel-${Date.now()}.mp4`,
|
||||||
|
fileSize: videoBuffer.length,
|
||||||
|
});
|
||||||
|
|
||||||
|
// Creates post in DB
|
||||||
const post = await storage.createPost({
|
const post = await storage.createPost({
|
||||||
userId: user.id,
|
userId: user.id,
|
||||||
content: description || overlayText || '',
|
content: description || overlayText || '',
|
||||||
@@ -365,6 +378,9 @@ reelsRouter.post('/reels', async (req: Request, res: Response) => {
|
|||||||
scheduledFor: scheduledFor ? new Date(scheduledFor) : undefined,
|
scheduledFor: scheduledFor ? new Date(scheduledFor) : undefined,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Link media to post
|
||||||
|
await storage.updatePostMedia(post.id, [processedMedia.id]);
|
||||||
|
|
||||||
// Publier sur chaque page sélectionnée
|
// Publier sur chaque page sélectionnée
|
||||||
const results: { pageId: string; success: boolean; reelId?: string; error?: string }[] = [];
|
const results: { pageId: string; success: boolean; reelId?: string; error?: string }[] = [];
|
||||||
|
|
||||||
|
|||||||
@@ -59,6 +59,18 @@ export class FacebookService {
|
|||||||
|
|
||||||
// Return all story IDs joined together
|
// Return all story IDs joined together
|
||||||
return storyIds.join(',');
|
return storyIds.join(',');
|
||||||
|
} else if (postType === 'reel') {
|
||||||
|
// Publish as Reel
|
||||||
|
if (mediaList.length === 0) {
|
||||||
|
throw new Error('Reels require a video');
|
||||||
|
}
|
||||||
|
|
||||||
|
const videoMedia = mediaList.find(m => m.type === 'video');
|
||||||
|
if (!videoMedia) {
|
||||||
|
throw new Error('Reels require a video media');
|
||||||
|
}
|
||||||
|
|
||||||
|
return await this.publishReel(page, videoMedia.originalUrl, post.content);
|
||||||
} else {
|
} else {
|
||||||
// Default to feed
|
// Default to feed
|
||||||
const imageMedia = mediaList.filter(m => m.type === 'image');
|
const imageMedia = mediaList.filter(m => m.type === 'image');
|
||||||
|
|||||||
Reference in new issue
Block a user