From e61e4eb56be213718a3576dbe40e69cc1334cd4d Mon Sep 17 00:00:00 2001 From: Matthias Guillitte Date: Wed, 13 Aug 2025 15:15:47 +0200 Subject: [PATCH] Fix signin skip --- .../Jobs/Instagram/InstagramAbstractJob.php | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/app/Browser/Jobs/Instagram/InstagramAbstractJob.php b/app/Browser/Jobs/Instagram/InstagramAbstractJob.php index dde54e0..d477079 100644 --- a/app/Browser/Jobs/Instagram/InstagramAbstractJob.php +++ b/app/Browser/Jobs/Instagram/InstagramAbstractJob.php @@ -53,8 +53,12 @@ abstract class InstagramAbstractJob extends BrowserJob implements ShouldBeUnique protected function signin(Browser $browser) { - if ($browser->assertSee("Search", true)) { - return; // Already signed in, skip some waiting for non existing text + // Verify if already signed in so we can skip + try { + $browser->waitForText("Search", 1); + } catch (\Exception $e) { + Log::debug("Not already signed in, continue with the signin process"); + // Not already signed in, continue with the signin process } try { @@ -75,6 +79,18 @@ abstract class InstagramAbstractJob extends BrowserJob implements ShouldBeUnique $browser->waitForText("Search", 15, true); $this->removePopups($browser); } catch (\Exception $e) { + // Incorrect password + try { + $browser->waitForText("Sorry, your password was incorrect. Please double-check your password.", 1, true); + Log::error("Instagram login failed: Incorrect password."); + $browser->screenshot(JobDebugScreenshot::getFileName($this->jobId)); + AllNotification::send(new JobDebugNotification($this->jobId, "Instagram login failed: Incorrect password.")); + // Stop the job run + throw new \Exception("Instagram login failed: Incorrect password."); + } catch (\Exception $e) { + // Not the expected error, continue + } + Log::error("Failed to sign in: " . $e->getMessage()); $browser->screenshot(JobDebugScreenshot::getFileName($this->jobId)); AllNotification::send(new JobDebugNotification($this->jobId, "Failed to sign in: " . $e->getMessage()));