Enforce page selection for scheduled posts to prevent errors

Add validation to ensure scheduled posts are associated with at least one page, returning a 400 error if not.

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/1VOBLTw
This commit is contained in:
michaelschal committed 2025-10-10 09:23:00 +00:00
1 parent d32b5ca306
commit b1a142e45c
1 file changed
+5
+5
View File
@@ -611,6 +611,11 @@ export async function registerRoutes(app: Express): Promise<Server> {
// Set status to "scheduled" if scheduledFor is provided, otherwise "draft"
if (postFields.scheduledFor) {
postFields.status = "scheduled";
// Validate that scheduled posts require at least one page
if (!pageIds || !Array.isArray(pageIds) || pageIds.length === 0) {
return res.status(400).json({ error: "Les posts programmés nécessitent au moins une page cible" });
}
}
// Create the post