Fix signin skip

This commit is contained in:
2025-08-13 15:15:47 +02:00
parent e75254f930
commit e61e4eb56b

View File

@@ -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()));