Repost System
This guide explains the repost orchestration system that enables users to automatically republish content from source platforms to configured destination platforms.
Overviewβ
The repost system allows users to:
- Designate platforms as repost sources (where content originates)
- Enable platforms as repost destinations (where content gets republished)
- Automatically fan out reposts to all enabled destinations
Architectureβ
The system consists of:
- Repost Orchestrator: Central coordinator for repost jobs
- Platform Configuration: Per-user settings for repost behavior
- Queue System: Reliable delivery via Cloud Tasks
Current Single-Source Flow (2024)β
- Organic triggers β
apps/functions/integrations/tiktok/organic-post-trigger.jsand.../instagram/organic-post-trigger.jswatchusers/{uid}/organicPosts/{postId}. Each trigger filters bysource_platform, stamps the organic post withstatus: 'reposting_initiated', and enqueuesrepostOrchestrator. - Global target resolution β
repost-orchestrator.jsscans every provider underusers/{uid}/integrations/*/accountswhereenabled_for_repost == true, regardless of which source account produced the organic post. This yields a single destination list for all repost jobs. - Repurpose templates β
trigger-templates.jsfan-outs template automations for any account that hasenable_text_repurpose_targetorenable_image_repurpose_targettoggled on.repurposeLinksdocuments do not distinguish source platforms, so all detected organic content is eligible if the destination toggle is set. - Idempotency β The orchestrator short-circuits when it finds an existing
postSubmissionsdocument for the organic post or when the organic post is already marked asstatus: 'reposted'.
Limitations Todayβ
- Single source assumption β Because targets are derived solely from
enabled_for_repost, every organic TikTok post fans out to every enabled destination, even when a user only wants specific TikTok accounts to trigger automations. - No workflow scoping β Template automations cannot encode βTikTok Account A β Instagram Account Aβ vs βTikTok Account A β LinkedIn Account Bβ as independent workflows. All automations share the same toggles and repurpose-link collection.
- Per-source feature flags missing β There is no place to express βplatform A1 reposts when content matches template T1 but platform A2 does not.β Users must manually toggle destination accounts, which affects every source.
- Limited observability β
organicPostsonly tracks a singlestatus. We cannot see which destinations succeeded or failed per organic post without inspecting multiplepostSubmissions, making partial reruns brittle. - Scalability blockers β Adding another source (e.g., Instagram) requires duplicating trigger logic and still funnels into the same global destinations, so per-source/per-workflow business rules would require ad hoc conditionals spread across functions.
Configuration Fieldsβ
Each integration document includes repost configuration:
enabled_for_repost: boolean- Platform accepts reposts as destinationcan_be_source: boolean- Platform can trigger reposts (future)
Currently configured in auth flows:
- Facebook:
enabled_for_repost: true, can_be_source: false - Instagram:
enabled_for_repost: true, can_be_source: false - Threads:
enabled_for_repost: true, can_be_source: false - X:
enabled_for_repost: true, can_be_source: false - TikTok:
enabled_for_repost: true, can_be_source: false - YouTube:
enabled_for_repost: true, can_be_source: false - LinkedIn:
enabled_for_repost: true, can_be_source: false
Repost Orchestratorβ
Entry: apps/functions/repost-orchestrator.js
Input: { userId, postId }
Flow:
- Query user's integrations collection
- Filter by
enabled_for_repost: true - Check against supported destinations (currently: instagram, youtube)
- Enqueue repost tasks to platform-specific queues
- Return job count and target list
Supported Destinationsβ
Current repost destinations:
- Instagram: Reposts via
repost-instagramqueue - YouTube: Reposts via
repost-youtubequeue
Future destinations (configured but not active):
- Facebook, Threads, X, TikTok, LinkedIn
Queue Configurationβ
Repost queues follow the pattern repost-{platform}:
# Create repost queues
gcloud tasks queues create repost-instagram --location=us-central1
gcloud tasks queues create repost-youtube --location=us-central1
Data Flowβ
- Trigger: External system calls repost orchestrator with
userIdandpostId - Discovery: Orchestrator reads user's integration settings
- Filtering: Only platforms with
enabled_for_repost: trueare considered - Validation: Check against list of actively supported destinations
- Dispatch: Enqueue tasks to platform-specific repost handlers
- Execution: Platform handlers fetch original post and republish
Error Handlingβ
- Missing or invalid
userId/postId: Return 400 error - No enabled destinations: Return success with zero jobs
- Queue failures: Logged and surfaced via Cloud Tasks retry
Future Enhancementsβ
The system is designed to support:
- Source Detection:
can_be_sourceplatforms triggering automatic reposts - Conditional Logic: User-defined rules for when to repost
- Content Filtering: Platform-specific content adaptation
- Schedule Delays: Time-based repost scheduling
- Cross-Platform Analytics: Tracking repost performance
API Responseβ
{
"ok": true,
"jobsCreated": 2,
"targets": ["instagram", "youtube"]
}
Integrationβ
The repost orchestrator is typically called by:
- Webhook handlers detecting new posts on source platforms
- Manual repost triggers from admin interfaces
- Scheduled jobs for batch repost processing