From c98c704b164418375e8c029fafc26eb0c147b58f Mon Sep 17 00:00:00 2001 From: Matthias Guillitte Date: Sat, 7 Jun 2025 15:42:38 +0200 Subject: [PATCH] Retry posting --- .../Jobs/InstagramRepost/InstagramRepostJob.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/app/Browser/Jobs/InstagramRepost/InstagramRepostJob.php b/app/Browser/Jobs/InstagramRepost/InstagramRepostJob.php index 8947781..4db2f5b 100644 --- a/app/Browser/Jobs/InstagramRepost/InstagramRepostJob.php +++ b/app/Browser/Jobs/InstagramRepost/InstagramRepostJob.php @@ -167,6 +167,9 @@ class InstagramRepostJob extends BrowserJob implements ShouldBeUniqueUntilProces ])); // Download the reels + /** + * @var mixed[] + */ $downloadedReels = []; foreach ($toDownloadReels as $repost) { $downloadedReels[] = [ @@ -189,8 +192,11 @@ class InstagramRepostJob extends BrowserJob implements ShouldBeUniqueUntilProces $reel = $infos[0]; $videoInfo = $infos[1]; - // TODO : Avoid getting the reel from the db again, store it in the downloadedReels array - $repostedReelsCounter += $this->repostReel($browser, InstagramRepost::where('reel_id', $reel->reel_id)->first(), $videoInfo); + $repostSuccess = false; + do { + $repostSuccess = $this->repostReel($browser, $reel, $videoInfo); + } while (!$repostSuccess && $reel->repost_tries < self::MAX_REPOST_TRIES); + $repostedReelsCounter += $repostSuccess; } $this->jobRun->addArtifact(new JobArtifact([