E2E Publish Flow (Public API → Orchestrator → Providers)
Overview
The E2E publish flow takes a client submission through the Public API, persists a postSubmission, orchestrates fan-out via Cloud Tasks, and executes provider-specific publish functions. Runs are tracked per-platform with idempotency and status transitions.
High-level Diagram
Permutations
- Targets: Any non-empty subset of
[facebook, instagram, threads, x, tiktok, youtube, linkedin].twitteris normalized tox. - Media:
- Text-only: No normalization; providers that require media will fail validation.
- Single video: Normalized once and reused by all targets that accept video.
- Single image: Normalized once; reused. If multiple images provided, we preserve list and set
mediaType: imagewithout replacing. - Multiple images: Passed through; not downscaled here (provider may reject based on limits).
- Scheduling: If
scheduledTimeis in the future, an orchestrator Cloud Task delays fan-out; otherwise immediate. - Idempotency: Per-provider
runs/{platform}guard against duplicates; provider code checks priorsucceededbefore re-post. - Auth states:
- Missing integration →
400at provider function; run markedfailed. - Expired tokens → refresh paths for X/TikTok/YouTube; failure recorded if refresh fails.
- Missing integration →
- Outcomes:
- All success → post visible under
users/{uid}/postsper provider logic. - Partial failure → mixed run statuses; submission remains
dispatchedwith per-run results.
- All success → post visible under
References
- Orchestrator:
apps/functions/orchestrators/publish-orchestrator.js,apps/functions/orchestrators/publishing-service.js - Cloud Tasks helper:
apps/functions/orchestrators/tasks.js - Public API:
apps/docs/docs/apis/public-api.md - Providers:
apps/functions/integrations/*/post.js