Skip to main content

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]. twitter is normalized to x.
  • 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: image without replacing.
    • Multiple images: Passed through; not downscaled here (provider may reject based on limits).
  • Scheduling: If scheduledTime is in the future, an orchestrator Cloud Task delays fan-out; otherwise immediate.
  • Idempotency: Per-provider runs/{platform} guard against duplicates; provider code checks prior succeeded before re-post.
  • Auth states:
    • Missing integration → 400 at provider function; run marked failed.
    • Expired tokens → refresh paths for X/TikTok/YouTube; failure recorded if refresh fails.
  • Outcomes:
    • All success → post visible under users/{uid}/posts per provider logic.
    • Partial failure → mixed run statuses; submission remains dispatched with per-run results.

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