mirror of
https://github.com/R0m1k3/Socialflow.git
synced 2026-10-21 05:58:12 +02:00
Add support for publishing posts to both feed and stories simultaneously
Introduce a new 'both' post type allowing simultaneous publishing to Facebook and Instagram feeds and stories. This includes UI updates for selecting post types, backend logic for splitting 'both' posts into separate feed and story entries, and the ability to delete scheduled posts. The changes also include a new 'Pages gérées' link in the sidebar and necessary database schema updates. Replit-Commit-Author: Agent Replit-Commit-Session-Id: ae4037a0-2a6f-4530-9bac-79b543286bda Replit-Commit-Checkpoint-Type: full_checkpoint Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/397bca8c-984f-43ff-841a-10897aeb8140/ae4037a0-2a6f-4530-9bac-79b543286bda/WuFXYmm
This commit is contained in:
1 parent
02794fecc2
commit
3971c6f912
9 files changed
+268
-24
No files matched your search
@@ -30,11 +30,26 @@ export class FacebookService {
|
||||
throw new Error('No access token found for this page');
|
||||
}
|
||||
|
||||
// If there's media, publish as photo post, otherwise as text post
|
||||
if (media) {
|
||||
return await this.publishPhotoPost(post, page, media);
|
||||
// Handle different post types
|
||||
// Note: "both" type should never reach here - new posts are split at creation
|
||||
// If it does reach here (legacy data), throw an error
|
||||
if (postType === 'both') {
|
||||
throw new Error('postType "both" is not supported. Posts should be split into separate feed and story entries at creation.');
|
||||
}
|
||||
|
||||
if (postType === 'story') {
|
||||
// Publish as story only
|
||||
if (!media) {
|
||||
throw new Error('Stories require media (photo or video)');
|
||||
}
|
||||
return await this.publishStory(post, page, media);
|
||||
} else {
|
||||
return await this.publishTextPost(post, page);
|
||||
// Default to feed
|
||||
if (media) {
|
||||
return await this.publishPhotoPost(post, page, media);
|
||||
} else {
|
||||
return await this.publishTextPost(post, page);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -165,6 +180,30 @@ export class FacebookService {
|
||||
const data = await response.json() as FacebookPhotoResponse;
|
||||
return data.post_id || data.id;
|
||||
}
|
||||
|
||||
private async publishStory(post: Post, page: SocialPage, media: Media): Promise<string> {
|
||||
// Use vertical format for stories (Instagram Story URL 1080x1920)
|
||||
const photoUrl = media.instagramStoryUrl || media.originalUrl;
|
||||
|
||||
const params = new URLSearchParams({
|
||||
access_token: page.accessToken!,
|
||||
url: photoUrl,
|
||||
});
|
||||
|
||||
const url = `${this.baseUrl}/${page.pageId}/photo_stories?${params.toString()}`;
|
||||
|
||||
const response = await fetch(url, {
|
||||
method: 'POST',
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
const error = await response.json() as FacebookError;
|
||||
throw new Error(`Facebook API error: ${error.error.message} (code: ${error.error.code})`);
|
||||
}
|
||||
|
||||
const data = await response.json() as FacebookPhotoResponse;
|
||||
return data.id;
|
||||
}
|
||||
}
|
||||
|
||||
export const facebookService = new FacebookService();
|
||||
Reference in new issue
Block a user