Open-source social media scheduler built for AI agents and the teams behind them. Create, schedule and publish posts to every network through MCP or the REST API, or write them yourself in a composer your team will love.
PHP ai-agentsblueskyfacebookinstagramlaravellinkedinmastodonmcpmcp-serveropen-sourcerest-apiself-hostedsocial-mediasocial-media-managementsocial-media-schedulerthreadstiktokvuejsxyoutube
perf(tiktok): load creator_info synchronously and cache it
Paulo Castellano0682b6503c81
diff --git a/app/Http/Controllers/App/PostController.php b/app/Http/Controllers/App/PostController.phpindex 83a695b43..e26d937db 100644--- a/app/Http/Controllers/App/PostController.php+++ b/app/Http/Controllers/App/PostController.php@@ -232,7 +232,16 @@ class PostController extends Controller}}- $tiktokAccounts = $socialAccounts->where('platform', Platform::TikTok);+ $tiktokCreatorInfos = $socialAccounts+ ->where('platform', Platform::TikTok)+ ->mapWithKeys(fn ($account) => [+ $account->id => rescue(+ fn () => app(TikTokCreatorInfo::class)->fetch($account),+ null,+ report: false,+ ),+ ])+ ->filter();return Inertia::render('posts/Edit', ['workspace' => $workspace,@@ -240,13 +249,7 @@ class PostController extends Controller'socialAccounts' => $socialAccounts,'platformConfigs' => $platformConfigs,'pinterestBoards' => $pinterestBoards,- 'tiktokCreatorInfos' => Inertia::defer(fn () => $tiktokAccounts->mapWithKeys(fn ($account) => [- $account->id => rescue(- fn () => app(TikTokCreatorInfo::class)->fetch($account),- null,- report: false,- ),- ])->filter()),+ 'tiktokCreatorInfos' => $tiktokCreatorInfos,'labels' => $labels,'signatures' => $signatures,'authUserId' => $request->user()->id,diff --git a/app/Services/Social/TikTokCreatorInfo.php b/app/Services/Social/TikTokCreatorInfo.phpindex b22378704..42a4858de 100644--- a/app/Services/Social/TikTokCreatorInfo.php+++ b/app/Services/Social/TikTokCreatorInfo.php@@ -8,6 +8,7 @@ use App\Exceptions\TokenExpiredException;use App\Models\SocialAccount;use App\Services\Social\Concerns\HasSocialHttpClient;use Illuminate\Http\Client\PendingRequest;+use Illuminate\Support\Facades\Cache;use Illuminate\Support\Facades\Http;use Illuminate\Support\Facades\Log;@@ -37,6 +38,27 @@ class TikTokCreatorInfo* }*/public function fetch(SocialAccount $account): array+ {+ return Cache::remember(+ "tiktok:creator_info:{$account->id}",+ now()->addMinutes(5),+ fn () => $this->fetchFresh($account),+ );+ }++ /**+ * @return array{+ * creator_nickname: ?string,+ * creator_username: ?string,+ * creator_avatar_url: ?string,+ * privacy_level_options: array<int, string>,+ * comment_disabled: bool,+ * duet_disabled: bool,+ * stitch_disabled: bool,+ * max_video_post_duration_sec: ?int,+ * }+ */+ private function fetchFresh(SocialAccount $account): array{if ($account->is_token_expired || $account->is_token_expiring_soon) {$this->refreshTokenWithLock($account, fn () => $this->refreshToken($account));diff --git a/lang/en/posts.php b/lang/en/posts.phpindex 11968b4a5..1f7c4cc5c 100644--- a/lang/en/posts.php+++ b/lang/en/posts.php@@ -84,7 +84,6 @@ return ['branded_cleared_private' => 'Privacy was cleared because Branded Content cannot be private.','interaction_disabled_by_creator' => 'Disabled by your TikTok account settings.','max_duration_exceeded' => 'Video is :duration s long but this account can only post videos up to :max s.',- 'creator_info_loading' => 'Loading your TikTok account settings…','processing_hint' => 'After publishing, it may take a few minutes for the content to process and appear on your TikTok profile.','brand_organic' => 'Your brand','brand_organic_hint' => 'You are promoting yourself or your own brand. This video will be classified as Brand Organic.',diff --git a/lang/es/posts.php b/lang/es/posts.phpindex 4d7d60773..f0c37f105 100644--- a/lang/es/posts.php+++ b/lang/es/posts.php@@ -84,7 +84,6 @@ return ['branded_cleared_private' => 'La visibilidad se borró porque el contenido de marca no puede ser privado.','interaction_disabled_by_creator' => 'Desactivado por la configuración de tu cuenta TikTok.','max_duration_exceeded' => 'El video dura :duration s pero esta cuenta solo permite videos de hasta :max s.',- 'creator_info_loading' => 'Cargando la configuración de tu cuenta TikTok…','processing_hint' => 'Después de publicar, puede tardar unos minutos en procesarse y aparecer en tu perfil de TikTok.','brand_organic' => 'Tu marca','brand_organic_hint' => 'Estás promocionándote a ti mismo o a tu propia marca. Este video será clasificado como Brand Organic.',diff --git a/lang/pt-BR/posts.php b/lang/pt-BR/posts.phpindex a369fa864..ee0305236 100644--- a/lang/pt-BR/posts.php+++ b/lang/pt-BR/posts.php@@ -84,7 +84,6 @@ return ['branded_cleared_private' => 'A visibilidade foi limpa porque conteúdo de marca não pode ser privado.','interaction_disabled_by_creator' => 'Desativado pelas configurações da sua conta TikTok.','max_duration_exceeded' => 'Vídeo tem :duration s mas esta conta só permite vídeos de até :max s.',- 'creator_info_loading' => 'Carregando configurações da sua conta TikTok…','processing_hint' => 'Após publicar, pode levar alguns minutos para o conteúdo ser processado e aparecer no seu perfil TikTok.','brand_organic' => 'Sua marca','brand_organic_hint' => 'Você está promovendo você mesmo ou sua própria marca. Este vídeo será classificado como Brand Organic.',diff --git a/resources/js/components/posts/editor/ScheduleTab.vue b/resources/js/components/posts/editor/ScheduleTab.vueindex 8fc366d62..ea201ecad 100644--- a/resources/js/components/posts/editor/ScheduleTab.vue+++ b/resources/js/components/posts/editor/ScheduleTab.vue@@ -266,7 +266,6 @@ const getPlatformAvatar = (pp: PostPlatform): string | null =>:social-account="pp.social_account":publish-config="getPublishConfig(pp)":creator-info="getCreatorInfo(pp)"- :creator-info-loading="tiktokCreatorInfos === undefined || tiktokCreatorInfos === null":video-duration-sec="videoDurationSec":content-type="platformContentTypes[pp.id] ?? ''":meta="platformMeta[pp.id] ?? {}"diff --git a/resources/js/components/posts/editor/TikTokSettings.vue b/resources/js/components/posts/editor/TikTokSettings.vueindex c4511ee63..940180326 100644--- a/resources/js/components/posts/editor/TikTokSettings.vue+++ b/resources/js/components/posts/editor/TikTokSettings.vue@@ -40,7 +40,6 @@ interface Props {socialAccount: SocialAccount | null;publishConfig: Record<string, any> | null;creatorInfo?: CreatorInfo | null;- creatorInfoLoading?: boolean;videoDurationSec?: number | null;contentType: string;meta: Record<string, any>;@@ -49,7 +48,6 @@ interface Props {const props = withDefaults(defineProps<Props>(), {creatorInfo: null,- creatorInfoLoading: false,videoDurationSec: null,disabled: false,});@@ -236,11 +234,6 @@ watch(</div></div>- <p v-if="creatorInfoLoading" class="flex items-center gap-2 text-xs font-medium text-foreground/60">- <span class="inline-block size-3 animate-pulse rounded-full bg-foreground/30" />- {{ $t('posts.form.tiktok.creator_info_loading') }}- </p>-<!-- Creator identity --><div v-if="socialAccount" class="flex items-center gap-3 rounded-lg bg-foreground/5 p-3"><Avatar